From 4705cc49d1ed3285d01240730ae87266c139f21c Mon Sep 17 00:00:00 2001 From: poka Date: Fri, 6 Dec 2019 15:14:08 +0000 Subject: [PATCH] improve /install.sh --- .../{init.sh.template => templates/init.sh} | 0 .install/install.sh => install.sh | 32 +++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) rename .install/{init.sh.template => templates/init.sh} (100%) rename .install/install.sh => install.sh (56%) diff --git a/.install/init.sh.template b/.install/templates/init.sh similarity index 100% rename from .install/init.sh.template rename to .install/templates/init.sh diff --git a/.install/install.sh b/install.sh similarity index 56% rename from .install/install.sh rename to install.sh index a1b1ea0..c94fc27 100755 --- a/.install/install.sh +++ b/install.sh @@ -4,12 +4,24 @@ # Version: 0.1 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ################################################################################ +MY_PATH="`dirname \"$0\"`" # relative +MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized +init_loc="$MY_PATH/shell/init.sh" + now=$(date +%Y-%m-%d) +chmod u+x .install/configure_ipfs_layer.sh .install/install_requirements.sh + +if [ "$EUID" -eq 0 ] + then echo "Veuillez ne pas executez ce script en root. Choisissez un utilisateur pour votre serveur G1sms+ (nous recommandons l'utilisateur pi)" + exit 1 +fi echo "Ce script configure votre noeud G1sms+" -IPFS=$(ps auxf --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1); +IPFS=$(ps auxf --sort=+utime | grep -w ipfs | grep -v "color=auto" | tail -n 1 | cut -d " " -f 1); -if [[ -f .install/init.sh.template ]]; then +[[ -z $IPFS ]] && $MY_PATH/.install/install_requirements.sh && $MY_PATH/.install/configure_ipfs_layer.sh + +if [[ -f $MY_PATH/.install/templates/init.sh ]]; then echo "Quel est l'utilisateur du système IPFS (détecté: $IPFS)?" read YOU if [[ "$YOU" == "" ]]; then YOU=$IPFS; fi @@ -33,15 +45,15 @@ if [[ -f .install/init.sh.template ]]; then read [[ -f shell/init.sh ]] && mv shell/init.sh shell/init.sh.old - cp .install/init.sh.template shell/init.sh + cp $MY_PATH/.install/templates/init.sh shell/init.sh - sed -i s/pi/$YOU/g ./shell/init.sh - sed -i s/+33600000000/$MASTERPHONE/g ./shell/init.sh - sed -i s/au\ G1FabLab\ de\ Toulouse/$ADRESSE/g ./shell/init.sh - sed -i s/+33647683646/$ADMINPHONE/g ./shell/init.sh - sed -i s/Fred/$ADMINPSEUDO/g ./shell/init.sh + sed -i s/pi/$YOU/g $init_loc + sed -i s/+33600000000/$MASTERPHONE/g $init_loc + sed -i s/au\ G1FabLab\ de\ Toulouse/$ADRESSE/g $init_loc + sed -i s/+33647683646/$ADMINPHONE/g $init_loc + sed -i s/Fred/$ADMINPSEUDO/g $init_loc - cat ./shell/init.sh + cat $init_loc else - echo "init.sh.template introuvable..." + echo "init.sh introuvable..." fi