#! /bin/bash ######################################################### # Inclusions ######################################################### # Variables partagées # releases url : https://github.com/syncthing/syncthing/releases/ archive_url="https://github.com/syncthing/syncthing/releases/download/v1.20.1/syncthing-linux-amd64-v1.20.1.tar.gz" archivename=$(echo $archive_url | grep -oE 'syncthing-(.*)\.tar\.gz') iconurl="https://raw.githubusercontent.com/syncthing/syncthing/main/assets/logo-128.png" # Fonctions partagées fonct_VerifConnexionInternet () { ping -c 1 github.com > /dev/null if [ "$?" != "0" ]; then echo "Erreur la connexion internet semble défaillante" echo "Fin du script." exit fi } fonct_PaquetInstalle () { which $1 if [ "$?" != "0" ]; then echo "$1 ne semble pas installé." echo "Fin du script." exit else echo "Le paquet $1 est bien installé." fi } fonct_TouchePourContinuer (){ read -p "Presser une touche pour continuer ou Ctrl-C pour annuler" CONT } fonct_ArretSurErreur(){ if [ "$?" != "0" ]; then echo "Le script a rencontré une erreur." exit fi } ######################################################### # Début du script ######################################################### # Vérifications fonct_VerifConnexionInternet fonct_PaquetInstalle firefox # Introduction clear cat << "EOF" ..~~+~~~.. .++++~~.~~~++++. .++~. .~++.. ~o+ ~ooo+. ~o~ +oooo +o .+++.~o+ .o+. ..~+ooo~. +o +ooo+++++++++oooo~ .++ +ooo~.. ~~oo. ~o~ ~o+ +o+~+o~ .++~. .oooo~ .~+++~~~~~~++o+o+. ..~~~~~~.. EOF echo "" echo "Syncthing remplace les logiciels de synchronisation\n\ privateurs et les services de cloud par un\n\ logiciel ouvert, de confiance et décentralisé.\n\ \n https://syncthing.net" echo "" fonct_TouchePourContinuer clear echo "Ce que fait ce script :\n\ -Télécharger et installer Syncthing de façon automatique\n\ -Créer un dossier bin dans votre home\n\ -Ajouter une entrée de démmarrage automatique pour Syncthing\n\ -Ajouter l'icone de Syncthing dans votre dossier icons\n\ -Ajouter une entrée Interface Syncthing dans votre menu principal" echo "" echo "Notes : Après l'installation l'interface web de Syncthing\n\ démmarra automatiquement à chaque session. Vous pouvez \n\ empecher cela en décochant la case "Lancer le navigateur web"\n\ dans la configuration de Syncthing." echo "" fonct_TouchePourContinuer clear mkdir -p $HOME/bin/ || echo "Error, mkdir bin failed"exit mkdir -p $HOME/.icons/ || echo "Error, mkdir icons failed";exit mkdir -p $HOME/.config/autostart/ || echo "Error, mkdir autostart failed";exit # Téléchargement syncthing wget --quiet $archive_url || echo "Error, downloading archive";exit tar -xzf $archivename -C $HOME/bin/ || echo "Error, untar archive failed";exit mv $HOME/bin/syncthing* $HOME/bin/syncthing rm $archivename echo "" echo "Syncthing a bien été installé." sleep 5 # Ajout alias au .bashrc #echo export PATH='$PATH':~/bin/syncthing >> $HOME/.bashrc sed -i '1iexport PATH='$PATH':~/bin/syncthing' $HOME/.bashrc fonct_ArretSurErreur echo "Ajout des alias au bashrc réussi." sleep 5 # Installation des fichiers desktop echo "[Desktop Entry]\n\ Encoding=UTF-8\n\ Name=Syncthing\n\ Icon=syncthing\n\ Comment="Outil de synchronisation sécurisé sans serveur central"\n\ Exec=bin/syncthing/syncthing\n\ Terminal=false\n\ Type=Application\n\ " >> $HOME/.config/autostart/syncthing-autostart.desktop fonct_ArretSurErreur echo "Ajout du lien de démmarrage automatique réussi." sleep 5 echo "[Desktop Entry]\n\ Encoding=UTF-8\n\ Name=Syncthing (Interface Web)\n\ Icon=syncthing\n\ Comment=\"Ouvrir l'interface web de Syncthing\"\n\ Exec=firefox --new-tab 127.0.0.1:8384\n\ Terminal=false\n\ Type=Application\n\ Categories=Network;\n\ " >> $HOME/.local/share/applications/syncthing-wui.desktop fonct_ArretSurErreur echo "Ajout du raccourcis vers l'interface web réussi." echo "Vous le trouverez dans le menu principal" echo "de votre distribution Rubrique Internet/Syncthing (Interface web)" sleep 5 # Installation de l'icone wget --quiet -O $HOME/.icons/syncthing.png $iconurl fonct_ArretSurErreur echo "Ajout de l'icone réussi." sleep 5 echo "" && echo "" && echo "" echo "Installation terminée." echo "Merci de relancer votre session pour terminer l'installation" echo "" && echo "" echo "Vous pouvez également installer Syncthing-GTK pour avoir les notifications de bureau et d'autres options" echo "https://github.com/syncthing/syncthing-gtk"