astrXbian/install.sh

211 lines
8.6 KiB
Bash
Raw Normal View History

2020-12-12 01:26:39 +01:00
#!/bin/bash
2021-01-31 22:51:25 +01:00
########################################################################
# Version: 0.3
2021-01-31 22:51:25 +01:00
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
2022-05-05 03:29:21 +02:00
{
2022-04-24 17:22:32 +02:00
ME="${0##*/}"
2021-01-31 22:51:25 +01:00
[ $(id -u) -eq 0 ] && echo "LANCEMENT root INTERDIT. Utilisez un simple utilisateur du groupe \"sudo\" SVP" && exit 1
2021-02-19 15:51:10 +01:00
2022-04-24 17:22:32 +02:00
# MAIN # SI AUCUNE CLEF DE STATION...
2021-02-19 15:51:10 +01:00
if [[ ! -f ~/.zen/secret.june ]];
then
2021-01-31 22:51:25 +01:00
2020-12-12 01:26:39 +01:00
# Check requirements
2022-04-24 17:22:32 +02:00
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)
2022-04-24 17:22:32 +02:00
echo ; echo "Mise à jour des dépots de votre distribution..."
2020-12-18 02:55:21 +01:00
sudo apt-get update
2022-04-24 17:22:32 +02:00
[[ "$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
2021-08-15 20:05:53 +02:00
for i in git fail2ban 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
2022-04-24 17:22:32 +02:00
echo ">>> Installation $i <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
2021-08-15 20:05:53 +02:00
sudo apt install -y $i
fi
done
2022-04-23 02:31:40 +02:00
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
2021-08-15 20:05:53 +02:00
if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
2022-04-24 17:22:32 +02:00
echo ">>> Installation $i <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
2021-08-15 20:05:53 +02:00
sudo apt install -y $i
fi
done
2022-04-24 17:22:32 +02:00
[[ ! $(which kodi) && "$USER" != "xbian" ]] &&\
echo ">>> Installation Kodi + Vstream = VOTRE VIDEOTHEQUE ! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<";\
sudo apt-get install kodi -y;\
2022-05-05 03:29:21 +02:00
./.install/kodi_uqload_downloader.sh
2022-04-24 17:22:32 +02:00
echo "## INSTALLATION OpenCV = 'IA Amicale' "
sudo apt-get install python3-opencv -y
## Correct PDF restrictions for imagemagick
2022-04-24 17:22:32 +02:00
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
if [[ ! $(which apache2) ]]; then
2022-04-24 17:22:32 +02:00
echo "########################################################################"
echo "## INSTALL PASSERELLE HTTP(S) #######################################"; echo ;
2021-08-15 20:05:53 +02:00
for i in mariadb-server nginx python3-certbot-nginx certbot ssl-cert php-imap php-cli php-curl php-sqlite3 php-gd php-json php-xml php-mbstring php-gettext php-mysql php-fpm; do
if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
2022-04-24 17:22:32 +02:00
echo ">>> Installation $i <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
2021-08-15 20:05:53 +02:00
sudo apt install -y $i
fi
done
2022-04-24 17:22:32 +02:00
else
echo ">>> WARNING <<< Apache détecté - Vous devrez réaliser la configuration de votre passerelle par vous même..."
fi
2022-04-24 17:22:32 +02:00
## GIVE ACCESS TO www-data group
sudo usermod -aG www-data $USER
echo "###########################"
echo "## INSTALL PYTHON CRYPTO LAYER "
echo "###########################"
echo 'export PATH=$PATH:$HOME/.local/bin' >> ~/.bashrc && source ~/.bashrc; echo ">>> PATH=$PATH"
2021-03-10 05:00:46 +01:00
python3 -m pip install -U pip
python3 -m pip install -U setuptools wheel
2021-03-10 20:58:59 +01:00
python3 -m pip install -U cryptography Ed25519 base58 google protobuf duniterpy
python3 -m pip install -U nicotine-plus
2022-04-24 17:22:32 +02:00
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"
2021-08-11 20:30:53 +02:00
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
2021-07-05 19:29:13 +02:00
sudo usermod -a -G gammu pi
2021-08-11 20:30:53 +02:00
fi
fi
2022-04-24 17:22:32 +02:00
2021-03-10 20:58:59 +01:00
# python3 -m pip install -U silkaj
2021-07-20 20:03:52 +02:00
## python -> python3 link
sudo ln -f -s /usr/bin/python3 /usr/bin/python
2022-04-24 17:22:32 +02:00
2020-12-12 01:26:39 +01:00
2021-01-31 22:51:25 +01:00
########################################################################
2022-04-24 17:22:32 +02:00
echo "=== Clonage git CODE astrXbian depuis https://git.p2p.legal"
2020-12-14 00:32:04 +01:00
mkdir -p ~/.zen
2020-12-13 20:47:09 +01:00
cd ~/.zen
git clone https://git.p2p.legal/axiom-team/astrXbian.git
2021-01-31 22:51:25 +01:00
2020-12-14 00:13:39 +01:00
########################################################################
2022-04-24 17:22:32 +02:00
echo "=== IMPORT configuration ASTROPORT dans ~/.kodi"
2020-12-14 00:13:39 +01:00
cp -Rf ~/.zen/astrXbian/.install/.kodi ~/
2021-01-31 22:51:25 +01:00
2020-12-14 00:13:39 +01:00
########################################################################
2022-04-24 17:22:32 +02:00
[[ ! $(which ipfs) ]] && echo "=== Installation de IPFS https://ipfs.io"; ~/.zen/astrXbian/.install/ipfs_alone.sh
2021-01-31 22:51:25 +01:00
2020-12-14 00:13:39 +01:00
########################################################################
2022-04-24 17:22:32 +02:00
echo "=== Configuration jaklis: Centre de communication CESIUM+ GCHANGE+"
2020-12-13 20:23:50 +01:00
cd ~/.zen/astrXbian/zen/jaklis
./setup.sh
2021-01-31 22:51:25 +01:00
########################################################################
2022-04-24 17:22:32 +02:00
echo "=== Sécurisation DEFCON SUDOERS FAIL2BAN"
2021-08-11 20:30:53 +02:00
## XBIAN fail2ban ERROR correction ##
#[....] Starting authentication failure monitor: fail2ban No file(s) found for glob /var/log/auth.log
2021-01-31 22:51:25 +01:00
[[ "$USER" == "xbian" ]] && sudo sed -i "s/auth.log/faillog/g" /etc/fail2ban/paths-common.conf
# NODE activates fail2ban IN zen/ipfs_SWARM_refresh.sh
2021-01-31 22:51:25 +01:00
### MODIFIYING /etc/sudoers ###
[[ "$USER" == "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/
2020-12-13 20:23:50 +01:00
2021-01-31 16:47:27 +01:00
if [[ "$USER" == "xbian" ]]
then
echo "enabling ipfs initV service autostart"
cd /etc/rc2.d && sudo ln -s ../init.d/ipfs S02ipfs
cd /etc/rc3.d && sudo ln -s ../init.d/ipfs S02ipfs
cd /etc/rc4.d && sudo ln -s ../init.d/ipfs S02ipfs
cd /etc/rc5.d && sudo ln -s ../init.d/ipfs S02ipfs
cd /etc/rc0.d && sudo ln -s ../init.d/ipfs K01ipfs
cd /etc/rc1.d && sudo ln -s ../init.d/ipfs K01ipfs
cd /etc/rc6.d && sudo ln -s ../init.d/ipfs K01ipfs
2021-08-11 20:30:53 +02:00
# Disable xbian-config auto launch
echo 0 > ~/.xbian-config-start
2021-03-10 06:47:32 +01:00
2021-01-31 16:47:27 +01:00
fi
2021-01-31 22:51:25 +01:00
########################################################################
# CREATE ~/astroport FILESYSTEM GATE
mkdir -p ~/astroport/film
mkdir -p ~/astroport/serie
mkdir -p ~/astroport/anime
2021-09-07 14:03:39 +02:00
echo '${TYPE};${MEDIAID};${YEAR};${TITLE};${SAISON};${GENRES};${GROUPES};${RES};/ipfs/_IPFSREPFILEID_/$URLENCODE_FILE_NAME' > ~/astroport/ajouter_video.modele.txt
2021-08-11 20:30:53 +02:00
## PREPARE www EXCHANGE ZONE ~/astroport/www
wwwuser=$(ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1) || wwuser="www-data"
sudo chown -R $USER:$wwwuser ~/astroport/www
2021-08-11 20:30:53 +02:00
sudo chmod -R g+rw ~/astroport/www
2021-08-16 21:04:35 +02:00
#######################################################################
2022-04-24 17:22:32 +02:00
## CREATE symlinks for ~/.zen/www/swarm & me ## OLD PHP METHOD ## TO REMOVE...
2021-09-07 14:03:39 +02:00
sudo chown -R $USER:www-data ~/.zen/astrXbian/www/boris
sudo chmod -R g+rw ~/.zen/astrXbian/www/boris
2021-08-16 21:04:35 +02:00
ln -s /home/$USER/.zen/ipfs_swarm ~/.zen/astrXbian/www/boris/swarm
ln -s /home/$USER/.zen/ipfs ~/.zen/astrXbian/www/boris/me
2022-04-24 17:22:32 +02:00
echo "## INSTALL open_with_linux.py ##
## https://darktrojan.github.io/openwith/webextension.html"
2021-08-12 11:25:39 +02:00
~/.zen/astrXbian/open_with_linux.py install
2022-04-24 17:22:32 +02:00
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" ]]
then
## Desktop install
echo "INITIALISATIOn Astroport/KODI"
2021-07-07 23:14:53 +02:00
echo "Appuyez sur la touche ENTREE pour créer une nouvelle identité"
2021-08-11 20:30:53 +02:00
echo "sinon interrompez ici l'installation pour copier la restauration d'une sauvegarde (~/.zen & ~/.ipfs)"
read
~/.zen/astrXbian/ISOconfig.sh
else
2021-08-11 20:30:53 +02:00
## 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
echo "STOP!! Redémarrer Xbian pour continuer la configuration de votre station Astroport/KODI"
echo "Faites une ISO : sudo xbian-config"
exit 0
2021-02-19 15:51:10 +01:00
fi
# MAIN # -f ~/.zen/secret.june (ISOConfig déjà lancé) ##
else
echo "Installation déjà faite !!
========================
Astroport/KODI (Gchange)
========================
2021-08-11 20:30:53 +02:00
Connectez-vous sur https://gchange.fr avec vos identifiants
2020-12-13 20:42:15 +01:00
$(cat ~/.zen/secret.june)
2020-12-13 20:42:15 +01:00
https://astroport.com
2021-01-31 22:51:25 +01:00
"
# MAIN #
fi
2021-01-31 22:51:25 +01:00
}