diff --git a/.install/.kodi/userdata/addon_data/plugin.video.vstream/Cookie_www_zt-za_com.txt b/.install/.kodi/userdata/addon_data/plugin.video.vstream/Cookie_www_zt-za_com.txt deleted file mode 100644 index 3d46abf..0000000 --- a/.install/.kodi/userdata/addon_data/plugin.video.vstream/Cookie_www_zt-za_com.txt +++ /dev/null @@ -1 +0,0 @@ -swp_token=1605043494:0cb63ecc71f6d029418e827aed3e7c9f:c8201b8ffdb3703b1d01884bce4f7584 \ No newline at end of file diff --git a/.install/.kodi/userdata/addon_data/plugin.video.vstream/Cookie_zt-protect_com.txt b/.install/.kodi/userdata/addon_data/plugin.video.vstream/Cookie_zt-protect_com.txt deleted file mode 100644 index ec58db7..0000000 --- a/.install/.kodi/userdata/addon_data/plugin.video.vstream/Cookie_zt-protect_com.txt +++ /dev/null @@ -1 +0,0 @@ -swp_token=1603922533:31aac141fc8c1f57a856ac4be928d2c0:067e0bd7719ed36e424bd1d672ebecdb \ No newline at end of file diff --git a/.install/.kodi/userdata/addon_data/plugin.video.vstream/Cookie_zt-protect_net.txt b/.install/.kodi/userdata/addon_data/plugin.video.vstream/cookie_zt-protect_net.txt similarity index 100% rename from .install/.kodi/userdata/addon_data/plugin.video.vstream/Cookie_zt-protect_net.txt rename to .install/.kodi/userdata/addon_data/plugin.video.vstream/cookie_zt-protect_net.txt diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5ba1166 --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +MYOS ?= ../myos +-include $(MYOS)/make/include.mk +.PHONY: all default install shellcheck shellcheck-% shellspec shellspec-% tests uninstall + +SHELL_FILES ?= $(wildcard .*/*.sh */*.sh */*/*.sh) + +$(MYOS): + git clone https://git.p2p.legal/aya/myos $(MYOS) + +default: tests + +all: install tests + +install: + ./install.sh + +tests: shellcheck shellspec + +shellcheck: + shellcheck $(SHELL_FILES) ||: + +shellcheck-%: + shellcheck $*/*.sh + +shellspec: shellspec-specs + +shellspec-%: + shellspec -f tap $* + +uninstall: diff --git a/include.sh b/include.sh new file mode 100644 index 0000000..c39653a --- /dev/null +++ b/include.sh @@ -0,0 +1,132 @@ +#!/bin/bash +[ "${DEBUG}" ] && set -x + +check_requirements() { + [[ ! $(which ipfs) ]] && echo "=== installez ipfs !!" && echo "https://docs.ipfs.io/install/command-line/#official-distributions" && exit 1 + echo "astrxbian installateur pour distributions debian et dérivées : linuxmint (https://www.linuxmint.com/) ou xbian (https://xbian.org) recommandées" + echo "appuyez sur entrer pour commencer."; read test; [[ "$test" != "" ]] && echo "sortie" && exit 0 ## ajouter confirmation à chaque nouvelle étape (+explications) + echo ; echo "mise à jour des dépots de votre distribution..." + sudo apt-get update + + [[ "$user" != "xbian" ]] &&\ + for i in x11-utils xclip zenity handbrake*; do\ + [ $(dpkg-query -w -f='${status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ] &&\ + echo ">>> installation $i <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<";\ + sudo apt install -y $i; + done + + for i in git fail2ban netcat-traditional inotify-tools curl net-tools libsodium* python3-dev python3-pip python3-setuptools python3-wheel python3-dotenv mpack libssl-dev libffi-dev; do + if [ $(dpkg-query -w -f='${status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then + echo ">>> installation $i <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" + sudo apt install -y $i + fi + done + + for i in build-essential qrencode jq bc file gawk yt-dlp ffmpeg sqlite dnsutils v4l-utils vlc mp3info musl-dev openssl* cargo detox nmap httrack html2text ssmtp imagemagick ttf-mscorefonts-installer libcurl4-openssl-dev; do + if [ $(dpkg-query -w -f='${status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then + echo ">>> installation $i <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" + sudo apt install -y $i + fi + done + + [[ ! $(which kodi) && "$user" != "xbian" ]] &&\ + echo ">>> installation kodi + vstream = votre videotheque ! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<";\ + sudo apt-get install kodi -y;\ + ${MY_PATH}/.install/kodi_uqload_downloader.sh + + echo "## INSTALLATION AstroGEEK OpenCV = 'Intelligence Amie' " + sudo apt-get install python3-opencv -y + + ## Correct PDF restrictions for imagemagick + echo "# Correction des droits export PDF imagemagick" + if [[ $(cat /etc/ImageMagick-6/policy.xml | grep PDF) ]]; then + cat /etc/ImageMagick-6/policy.xml | grep -Ev PDF > /tmp/policy.xml + sudo cp /tmp/policy.xml /etc/ImageMagick-6/policy.xml + fi + + echo "###########################" + echo "## INSTALL PYTHON CRYPTO LAYER " + echo "###########################" + echo 'export PATH=$PATH:$HOME/.local/bin' >> ~/.bashrc && source ~/.bashrc; echo ">>> PATH=$PATH" + python3 -m pip install -U pip + python3 -m pip install -U setuptools wheel + python3 -m pip install -U cryptography Ed25519 base58 google duniterpy pynacl pgpy + python3 -m pip install -U nicotine-plus silkaj + python3 -m pip install -U protobuf==3.19.0 + + + if [[ "$USER" == "pi" ]]; then ## PROPOSE QR_CODE PRINTER SUR RPI + echo "Ambassade? Souhaitez vous ajouter imprimante 'brother_ql'? Saisissez OUI, sinon laissez vide et tapez sur ENTRER" + read saisie + if [[ $saisie != "" ]]; then + sudo apt install printer-driver-all cups -y + sudo pip3 install brother_ql + sudo cupsctl --remote-admin + sudo usermod -aG lpadmin pi + sudo usermod -a -G gammu pi + fi + fi + + # python3 -m pip install -U silkaj + ## python -> python3 link + sudo ln -f -s /usr/bin/python3 /usr/bin/python +} + +i_am() { + echo 'v0.5.0' +} + +i_am_root() { + [ $(id -u) -eq 0 ] +} + +i_am_xbian() { + [[ "$USER" == "xbian" ]] +} + +i_should_install() { +[[ ! -f ~/.zen/secret.dunikey ]] +} + +import_astrXbian() { + echo "=== Clonage git CODE 'astrXbian' + 'Astroport.ONE' depuis https://git.p2p.legal" + mkdir -p ~/.zen + cd ~/.zen + # TODO INSTALL FROM IPFS / IPNS + git clone https://git.p2p.legal/axiom-team/astrXbian.git + git clone https://git.p2p.legal/qo-op/Astroport.ONE.git +} + +import_astroport() { + echo "INITIALISATIOn Astroport/KODI" + echo "Appuyez sur la touche ENTREE pour démarrer le mode Aventure" + echo "sinon interrompez ici l'installation, et activez votre Ambassade ~/.zen/Astroport.ONE/start.sh" + read + ~/.zen/Astroport.ONE/adventure.sh + # ~/.zen/astrXbian/ISOconfig.sh +} + +import_ipfs() { + ## Scripts pour systemd ou InitV (xbian) + echo "=== Activation SYSTEM IPFS" + ~/.zen/astrXbian/.install/ipfs_alone.sh +} + +import_jaklis() { + echo "=== Configuration jaklis: Centre de communication CESIUM+ GCHANGE+" + cd ~/.zen/astrXbian/zen/jaklis + ./setup.sh +} + +import_kodi() { + echo "=== IMPORT configuration ASTROPORT dans ~/.kodi" + cp -Rf ~/.zen/astrXbian/.install/.kodi ~/ +} + +prepare_next_boot() { + cat /etc/rc.local | grep -Ev "exit 0" > /tmp/new.rc.local ## REMOVE "exit 0" + # PREPARE NEXT BOOT - Network config - NEXTBOOT - ISOConfig - NEXTBOOT - OK + echo "su - xbian -c '~/.zen/astrXbian/FirstBOOT.sh'" >> /tmp/new.rc.local + echo "exit 0" >> /tmp/new.rc.local + sudo cp -f /tmp/new.rc.local /etc/rc.local +} diff --git a/install.sh b/install.sh index b661679..81f4c74 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,7 @@ #!/bin/bash +. ./include.sh ######################################################################## -# Version: 0.3 +# Version: 0.5.0 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ######################################################################## { @@ -8,122 +9,41 @@ MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized ME="${0##*/}" -[ $(id -u) -eq 0 ] && echo "LANCEMENT root INTERDIT. Utilisez un simple utilisateur du groupe \"sudo\" SVP" && exit 1 - - -######################################################################## -[[ ! $(which ipfs) ]] && echo "=== Installez IPFS !!" && echo "https://docs.ipfs.io/install/command-line/#official-distributions" && exit 1 +i_am_root && echo "LANCEMENT root INTERDIT. Utilisez un simple utilisateur du groupe \"sudo\" SVP" && exit 1 # MAIN # SI AUCUNE CLEF DE STATION... -if [[ ! -f ~/.zen/secret.dunikey ]]; +if i_should_install; then -# Check requirements -echo "AstrXbian installateur pour distributions DEBIAN et dérivées : LinuxMint (https://www.linuxmint.com/) ou XBIAN (https://xbian.org) recommandées" -echo "Appuyez sur ENTRER pour commencer."; read TEST; [[ "$TEST" != "" ]] && echo "SORTIE" && exit 0 ## Ajouter confirmation à chaque nouvelle étape (+explications) -echo ; echo "Mise à jour des dépots de votre distribution..." -sudo apt-get update +# Install requirements +check_requirements -[[ "$USER" != "xbian" ]] &&\ - for i in x11-utils xclip zenity handbrake*; do\ - [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ] &&\ - echo ">>> Installation $i <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<";\ - sudo apt install -y $i; - done +# Clone astrXbian and Astroport.One +import_astrXbian -for i in git fail2ban netcat-traditional inotify-tools curl net-tools libsodium* python3-dev python3-pip python3-setuptools python3-wheel python3-dotenv mpack libssl-dev libffi-dev; do - if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then - echo ">>> Installation $i <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" - sudo apt install -y $i - fi -done +# Init ipfs +import_ipfs -for i in build-essential qrencode jq bc file gawk yt-dlp ffmpeg sqlite dnsutils v4l-utils vlc mp3info musl-dev openssl* cargo detox nmap httrack html2text ssmtp imagemagick ttf-mscorefonts-installer libcurl4-openssl-dev; do - if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then - echo ">>> Installation $i <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" - sudo apt install -y $i - fi -done +# Copy astroport config in kodi +import_kodi -[[ ! $(which kodi) && "$USER" != "xbian" ]] &&\ - echo ">>> Installation Kodi + Vstream = VOTRE VIDEOTHEQUE ! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<";\ - sudo apt-get install kodi -y;\ - ${MY_PATH}/.install/kodi_uqload_downloader.sh - -echo "## INSTALLATION AstroGEEK OpenCV = 'Intelligence Amie' " -sudo apt-get install python3-opencv -y - -## Correct PDF restrictions for imagemagick -echo "# Correction des droits export PDF imagemagick" -if [[ $(cat /etc/ImageMagick-6/policy.xml | grep PDF) ]]; then - cat /etc/ImageMagick-6/policy.xml | grep -Ev PDF > /tmp/policy.xml - sudo cp /tmp/policy.xml /etc/ImageMagick-6/policy.xml -fi - -echo "###########################" -echo "## INSTALL PYTHON CRYPTO LAYER " -echo "###########################" -echo 'export PATH=$PATH:$HOME/.local/bin' >> ~/.bashrc && source ~/.bashrc; echo ">>> PATH=$PATH" -python3 -m pip install -U pip -python3 -m pip install -U setuptools wheel -python3 -m pip install -U cryptography Ed25519 base58 google duniterpy pynacl pgpy -python3 -m pip install -U nicotine-plus silkaj -python3 -m pip install -U protobuf==3.19.0 - - -if [[ "$USER" == "pi" ]]; then ## PROPOSE QR_CODE PRINTER SUR RPI - echo "Ambassade? Souhaitez vous ajouter imprimante 'brother_ql'? Saisissez OUI, sinon laissez vide et tapez sur ENTRER" - read saisie - if [[ $saisie != "" ]]; then - sudo apt install printer-driver-all cups -y - sudo pip3 install brother_ql - sudo cupsctl --remote-admin - sudo usermod -aG lpadmin pi - sudo usermod -a -G gammu pi - fi -fi - -# python3 -m pip install -U silkaj -## python -> python3 link -sudo ln -f -s /usr/bin/python3 /usr/bin/python - - -######################################################################## -echo "=== Clonage git CODE 'astrXbian' + 'Astroport.ONE' depuis https://git.p2p.legal" -mkdir -p ~/.zen -cd ~/.zen -git clone https://git.p2p.legal/axiom-team/astrXbian.git -git clone https://git.p2p.legal/qo-op/Astroport.ONE.git -# TODO INSTALL FROM IPFS / IPNS - - -## Scripts pour systemd ou InitV (xbian) -echo "=== Activation SYSTEM IPFS" -~/.zen/astrXbian/.install/ipfs_alone.sh - -######################################################################## -echo "=== IMPORT configuration ASTROPORT dans ~/.kodi" -cp -Rf ~/.zen/astrXbian/.install/.kodi ~/ - -######################################################################## -echo "=== Configuration jaklis: Centre de communication CESIUM+ GCHANGE+" -cd ~/.zen/astrXbian/zen/jaklis -./setup.sh +# Jaklis setup +import_jaklis ######################################################################## echo "=== Sécurisation DEFCON SUDOERS FAIL2BAN" ## XBIAN fail2ban ERROR correction ## #[....] Starting authentication failure monitor: fail2ban No file(s) found for glob /var/log/auth.log -[[ "$USER" == "xbian" ]] && sudo sed -i "s/auth.log/faillog/g" /etc/fail2ban/paths-common.conf +i_am_xbian && sudo sed -i "s/auth.log/faillog/g" /etc/fail2ban/paths-common.conf # NODE activates fail2ban IN zen/ipfs_SWARM_refresh.sh ### MODIFIYING /etc/sudoers ### -[[ "$USER" == "xbian" ]] && echo "xbian ALL=(ALL) NOPASSWD:ALL" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/astroport') +i_am_xbian && echo "xbian ALL=(ALL) NOPASSWD:ALL" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/astroport') # PERSONNAL DEFCON LEVEL # cp ~/.zen/astrXbian/DEFCON ~/.zen/ -if [[ "$USER" == "xbian" ]] +if i_am_xbian then echo "enabling ipfs initV service autostart" cd /etc/rc2.d && sudo ln -s ../init.d/ipfs S02ipfs @@ -158,26 +78,17 @@ echo ">>> INFO : Ajoutez l'extension 'OpenWith' à votre navigateur !! # https://addons.mozilla.org/firefox/addon/open-with/ # https://chrome.google.com/webstore/detail/open-with/cogjlncmljjnjpbgppagklanlcbchlno" -if [[ "$USER" != "xbian" ]] +if ! i_am_xbian then - ## Desktop install - echo "INITIALISATIOn Astroport/KODI" - echo "Appuyez sur la touche ENTREE pour démarrer le mode Aventure" - echo "sinon interrompez ici l'installation, et activez votre Ambassade ~/.zen/Astroport.ONE/start.sh" - read - ~/.zen/Astroport.ONE/adventure.sh - # ~/.zen/astrXbian/ISOconfig.sh + ## Desktop install + import_astroport else - ## Rpi Xbian install. - cat /etc/rc.local | grep -Ev "exit 0" > /tmp/new.rc.local ## REMOVE "exit 0" - # PREPARE NEXT BOOT - Network config - NEXTBOOT - ISOConfig - NEXTBOOT - OK - echo "su - xbian -c '~/.zen/astrXbian/FirstBOOT.sh'" >> /tmp/new.rc.local - echo "exit 0" >> /tmp/new.rc.local - sudo cp -f /tmp/new.rc.local /etc/rc.local + ## Rpi Xbian install. + prepare_next_boot - echo "STOP!! Redémarrer Xbian pour continuer la configuration de votre station Astroport/KODI" - echo "Faites une ISO : sudo xbian-config" - exit 0 + echo "STOP!! Redémarrer Xbian pour continuer la configuration de votre station Astroport/KODI" + echo "Faites une ISO : sudo xbian-config" + exit 0 fi # MAIN # -f ~/.zen/secret.june (ISOConfig déjà lancé) ## diff --git a/specs/astrXbian_spec.sh b/specs/astrXbian_spec.sh new file mode 100644 index 0000000..9776938 --- /dev/null +++ b/specs/astrXbian_spec.sh @@ -0,0 +1,54 @@ +#shellcheck shell=sh + +Describe 'AstrXbian' + Describe 'install.sh' + Include ./include.sh + It 'should check it applies to me' + When call i_am + The output should eq 'v0.5.0' + End + It 'should check I am not superuser' + When call i_am_root + The status should not be success + End + It 'should check I need to install' + When call i_should_install + The status should be success + End + It 'should check requirements, but not tested' + Skip "You should implement check_requirements tests" + When run check_requirements + The status should be success + End + It 'should import astrXbian, but not tested' + Skip "You should implement import_astrXbian tests" + When run import_astrXbian + The status should be success + End + It 'should import astroport, but not tested' + Skip "You should implement import_astroport tests" + When run import_astroport + The status should be success + End + It 'should import IPFS, but not tested' + Skip "You should implement import_ipfs tests" + When run import_ipfs + The status should be success + End + It 'should import Jaklis, but not tested' + Skip "You should implement import_jaklis tests" + When run import_jaklis + The status should be success + End + It 'should import Kodi, but not tested' + Skip "You should implement import_kodi tests" + When run import_kodi + The status should be success + End + It 'should prepare astrXbian for first boot, but not tested' + Skip "You should implement prepare_next_boot tests" + When run prepare_next_boot + The status should be success + End + End +End