91 lines
3.9 KiB
Bash
Executable File
91 lines
3.9 KiB
Bash
Executable File
#!/bin/bash
|
|
################################################################################
|
|
# Author: Fred (support@qo-op.com)
|
|
# 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)
|
|
|
|
args="$@"
|
|
[[ $args =~ all ]] && repOption=o
|
|
[[ $args =~ noptions ]] && repOption=n
|
|
[[ $args =~ force ]] && force_req=o
|
|
[[ $args =~ noask ]] && noask=o
|
|
|
|
unset err
|
|
|
|
if [ "$EUID" -eq 0 ]
|
|
then echo -e "${c_red}Veuillez ne pas executez ce script en root. Choisissez un utilisateur pour votre serveur G1sms+ (nous recommandons l'utilisateur pi)$c_"
|
|
exit 1
|
|
fi
|
|
|
|
## Update G1sms+ code
|
|
git pull || err=1
|
|
|
|
chmod u+x $MY_PATH/.install/*.sh
|
|
|
|
$MY_PATH/.install/export_colors.sh
|
|
[[ -f ~/.bash_aliases ]] && source ~/.bash_aliases
|
|
|
|
## Vérifie si IPFS est installé
|
|
if [[ $force_req == "o" || -z $(which ipfs) || -z $(which gammu) ]];then
|
|
echo -e "${c_yellow}IPFS ou gammu n'ont pas été détectés sur votre machine, nous allons installer tous les prérequis...$c_"
|
|
$MY_PATH/.install/1-install_requirements.sh || err=1
|
|
$MY_PATH/.install/2-configure_ipfs_layer.sh || err=1
|
|
else
|
|
echo -e "${c_green}IPFS et gammu sont déjà installé !$c_"
|
|
fi
|
|
|
|
echo -e "${c_yellow}Ce script va désormais configurer votre noeud G1sms+$c_"
|
|
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
|
|
|
|
[[ -f .profile ]] && source .profile
|
|
if [[ -f $MY_PATH/.install/templates/init.sh ]]; then
|
|
[[ ! $ADMINPSEUDO ]] && echo -e "${c_light}Votre PSEUDO? (celui de votre Compte membre Duniter)$c_" && read ADMINPSEUDO
|
|
[[ "$ADMINPSEUDO" == "" ]] && echo -e "${c_red}IMPOSSIBLE DE CONTINUER$c_" && exit 1
|
|
|
|
[[ ! $ADMINPHONE ]] && echo -e "${c_light}Le Numéro de téléphone SMS Admin? (Support de ce noeud) (ex +33611223344)$c_" && read ADMINPHONE
|
|
[[ "$ADMINPHONE" == "" ]] && echo -e "${c_red}IMPOSSIBLE DE CONTINUER$c_" && exit 1
|
|
|
|
[[ ! $MASTERPHONE ]] && echo -e "${c_light}Le numéro de la carte SIM, du module SMS. AUCUNE liaison SMS? Laissez vide (défaut: +33600000000)$c_" && read MASTERPHONE
|
|
[[ "$MASTERPHONE" == "" ]] && MASTERPHONE="+33600000000"
|
|
|
|
[[ ! $ADRESSE ]] && echo -e "${c_light}L'adresse où se trouve votre G1Node pour indiquer où venir chercher ses G1Tag (ex: au G1FabLab de Toulouse)$c_" && read ADRESSE
|
|
|
|
echo -e "ADMINPSEUDO: $ADMINPSEUDO\nADMINPHONE: $ADMINPHONE\nMASTERPHONE: $MASTERPHONE\nADRESSE: $ADRESSE"
|
|
[[ $noask != "o" ]] && echo -e "${c_light}${c_blue}LES PARAMETRES SONT BONS? Appliquer? ENTER ou CTRL-C ?$c_" && read
|
|
|
|
[[ -f shell/init.sh ]] && mv shell/init.sh shell/init.sh.old
|
|
cp $MY_PATH/.install/templates/init.sh shell/init.sh || err=1
|
|
|
|
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 $init_loc || err=1
|
|
else
|
|
echo -e "${c_red}init.sh introuvable...$c_"
|
|
err=1
|
|
exit 1
|
|
fi
|
|
|
|
## Installations optionnels
|
|
|
|
repOld=$repOption
|
|
[[ -z $repOption ]] && echo -e "${c_yellow}Voulez-vous installer les modules complémentaires de copylaradio ? (o/n)$c_" && read repOption
|
|
[[ $repOption =~ ^(o|1|yes|options|a|all)$ ]] && .install/3-install_copylaradio.sh; repOption=$repOld
|
|
[[ -z $repOption ]] && echo -e "${c_yellow}Voulez-vous installer l'interface web playSMS ? (o/n)$c_" && read repOption
|
|
[[ $repOption =~ ^(o|1|yes|options|a|all)$ ]] && .install/4-install_playsms.sh; repOption=$repOld
|
|
|
|
if [[ $err ]]; then
|
|
echo -e "---\n${c_red}L'installation n'est mal déroulé =($c_"
|
|
else
|
|
echo -e "---\n${c_green}L'installation de votre noeud G1SMS est terminé !\nBienvenue à bord =)$c_"
|
|
fi
|
|
exit 0
|