astrXbian_UX-et-webUI/install.sh

177 lines
7.5 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
########################################################################
# Version: 0.3
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
{
[ $(id -u) -eq 0 ] && echo "LANCEMENT root INTERDIT. Utilisez un simple utilisateur du groupe \"sudo\" SVP" && exit 1
# MAIN #
if [[ ! -f ~/.zen/secret.june ]];
then
# Check requirements
echo "AstrXbian installateur pour XBIAN (https://xbian.org) distributions DEBIAN et dérivées (https://www.linuxmint.com/)"
sudo apt-get update
#sudo apt-get install git fail2ban inotify-tools curl net-tools libsodium* python3-dev python3-pip python3-setuptools python3-wheel python3-dotenv mpack libssl-dev libffi-dev -y
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
sudo apt install -y $i
fi
done
#sudo apt-get install build-essential qrencode jq bc gawk ffmpeg sqlite dnsutils v4l-utils vlc mp3info musl-dev openssl* cargo detox httrack html2text ssmtp sudo -y
for i in build-essential qrencode jq bc gawk ffmpeg sqlite dnsutils v4l-utils vlc mp3info musl-dev openssl* cargo detox nmap httrack html2text ssmtp imagemagick ttf-mscorefonts-installer; do
if [ $(dpkg-query -W -f='${Status}' $i 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
sudo apt install -y $i
fi
done
[[ ! $(which kodi) && "$USER" != "xbian" ]] && sudo apt-get install kodi -y
sudo apt-get install python3-opencv -y ## INSTALLATION IA par reconnaissance d'images
[[ "$USER" != "xbian" ]] && sudo apt-get install x11-utils xclip zenity handbrake* -y
if [[ ! $(which apache2) ]]; then
########################################################################
## INSTALL nginx + php + mariadb + ...
# sudo apt-get install 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 -y
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
sudo apt install -y $i
fi
done
fi
## INSTALL PYTHON CRYPTO LAYER
echo 'export PATH=$PATH:$HOME/.local/bin' >> ~/.bashrc && source ~/.bashrc
python3 -m pip install -U pip
python3 -m pip install -U setuptools wheel
python3 -m pip install -U cryptography Ed25519 base58 google protobuf duniterpy
if [[ "$USER" == "pi" ]]; then ## PROPOSE QR_CODE PRINTER
echo "SOUHAITEZ VOUS AJOUTER UNE IMPRIMANTE A QR CODE? saisissez OUI, sinon tapez sur ENTREE"
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
## GIVE ACCESS TO www-data group
sudo usermod -aG www-data $USER
########################################################################
echo "Clonage git astrXbian depuis https://git.p2p.legal"
mkdir -p ~/.zen
cd ~/.zen
git clone https://git.p2p.legal/axiom-team/astrXbian.git
########################################################################
echo "IMPORT configuration ASTROPORT dans ~/.kodi"
cp -Rf ~/.zen/astrXbian/.install/.kodi ~/
########################################################################
echo "Installation de IPFS https://ipfs.io"
~/.zen/astrXbian/.install/ipfs_alone.sh
########################################################################
echo "Configuration jaklis: Centre de communication CESIUM+ GCHANGE+ & MONNAIE LIBRE (gva protocole)"
cd ~/.zen/astrXbian/zen/jaklis
./setup.sh
########################################################################
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
# 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')
# PERSONNAL DEFCON LEVEL
# cp ~/.zen/astrXbian/DEFCON ~/.zen/
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
# Disable xbian-config auto launch
echo 0 > ~/.xbian-config-start
fi
########################################################################
# CREATE ~/astroport FILESYSTEM GATE
mkdir -p ~/astroport/film
mkdir -p ~/astroport/serie
mkdir -p ~/astroport/anime
echo '${TYPE};${MEDIAID};${YEAR};${TITLE};${SAISON};${GENRES};${GROUPES};${RES};/ipfs/_IPFSREPFILEID_/$URLENCODE_FILE_NAME' > ~/astroport/ajouter_video.modele.txt
## 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
sudo chmod -R g+rw ~/astroport/www
#######################################################################
## CREATE symlinks for ~/.zen/www/swarm & me
sudo chown -R $USER:www-data ~/.zen/astrXbian/www/boris
sudo chmod -R g+rw ~/.zen/astrXbian/www/boris
ln -s /home/$USER/.zen/ipfs_swarm ~/.zen/astrXbian/www/boris/swarm
ln -s /home/$USER/.zen/ipfs ~/.zen/astrXbian/www/boris/me
## INSTALL open_with_linux.py
## https://darktrojan.github.io/openwith/webextension.html
# https://addons.mozilla.org/firefox/addon/open-with/
# https://chrome.google.com/webstore/detail/open-with/cogjlncmljjnjpbgppagklanlcbchlno
~/.zen/astrXbian/open_with_linux.py install
if [[ "$USER" != "xbian" ]]
then
## Desktop install
echo "INITIALISATIOn Astroport/KODI"
echo "Appuyez sur la touche ENTREE pour créer une nouvelle identité"
echo "sinon interrompez ici l'installation pour copier la restauration d'une sauvegarde (~/.zen & ~/.ipfs)"
read
~/.zen/astrXbian/ISOconfig.sh
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
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é) ##
else
echo "Installation déjà faite !!
========================
Astroport/KODI (Gchange)
========================
Connectez-vous sur https://gchange.fr avec vos identifiants
$(cat ~/.zen/secret.june)
https://astroport.com
"
# MAIN #
fi
}