From 60e5f9a2c7fde2c992b4a393c324e8329e60ba99 Mon Sep 17 00:00:00 2001 From: poka Date: Fri, 6 Dec 2019 19:24:50 +0100 Subject: [PATCH] Add colors --- .gitignore | 1 + .install/export_colors.sh | 33 +++++++++++++++++++++++++++++ install.sh | 44 ++++++++++++++++++++++++--------------- 3 files changed, 61 insertions(+), 17 deletions(-) create mode 100755 .install/export_colors.sh diff --git a/.gitignore b/.gitignore index d3c34be..d587935 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ history.* TAG/ .install/errors .install/log +shell/init.sh.old diff --git a/.install/export_colors.sh b/.install/export_colors.sh new file mode 100755 index 0000000..c09180f --- /dev/null +++ b/.install/export_colors.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +[[ ! -z $(cat ~/.bash_aliases | grep c_red) ]] && echo "Les couleurs sont déjà déclarés dans l'environnement" && exit 1 + +echo 'export c_blinkfast="\033[6m" +export c_light="\033[1m" +export c_white_bg="\033[47m" +export c_blue="\033[34m" +export c_red_bg="\033[41m" +export c_hide="\033[8m" +export c_purple_bg="\033[45m" +export c_yellow_bg="\033[43m" +export c_dark="\033[2m" +export c_reverse="003[7m" +export c_underline="\033[4m" +export c_blinkslow="\033[5m" +export c_red="\033[31m" +export c_white="\033[37m" +export c_cyan_bg="\033[46m" +export c_italic="\033[3m" +export c_black="\033[30m" +export c_cross="\033[9m" +export c_green="\033[32m" +export c_purple="\033[35m" +export c_="\033[0m" +export c_cyan="\033[36m" +export c_black_bg="\033[40m" +export c_yellow="\033[33m" +export c_blue_bg="\033[44m" +export c_green_bg="\033[42m"' >> ~/.bash_aliases + + +bash -i diff --git a/install.sh b/install.sh index b9facda..5c6e7e8 100755 --- a/install.sh +++ b/install.sh @@ -7,46 +7,54 @@ 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) +repOption=$1 ## Update G1sms+ code git pull -now=$(date +%Y-%m-%d) -chmod u+x .install/configure_ipfs_layer.sh .install/install_requirements.sh .install/install_optional.sh - -repOption=$1 +chmod u+x $MY_PATH/.install/*.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)" + 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 -[[ -z $(which ipfs) ]] && echo "IPFS n'a pas été détecté sur votre machine, nous allons installer tous les prérequis..." && $MY_PATH/.install/install_requirements.sh && $MY_PATH/.install/configure_ipfs_layer.sh +$MY_PATH/.install/export_colors.sh -echo "Ce script va désormais configurer votre noeud G1sms+" +## Vérifie si IPFS est installé +if [[ -z $(which ipfs) ]];then + echo -e "${c_yellow}IPFS n'a pas été détecté sur votre machine, nous allons installer tous les prérequis...$c_" + $MY_PATH/.install/install_requirements.sh + $MY_PATH/.install/configure_ipfs_layer.sh +else + echo -e "${c_green}IPFS est déjà installé, configuration du noeud ...$c_" +fi + +echo -e "${c_yellow}Ce script va désormais configurer votre noeud G1sms+$c_" IPFS=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); if [[ -f $MY_PATH/.install/templates/init.sh ]]; then - echo "Quel est l'utilisateur du système IPFS (détecté: $IPFS)?" + echo -e "${c_light}Quel est l'utilisateur du système IPFS (détecté: $IPFS)?$c_" read YOU if [[ "$YOU" == "" ]]; then YOU=$IPFS; fi - echo "Votre PSEUDO? (celui de votre Compte membre Duniter)" + echo -e "${c_light}Votre PSEUDO? (celui de votre Compte membre Duniter)$c_" read ADMINPSEUDO - if [[ "$ADMINPSEUDO" == "" ]]; then echo "IMPOSSIBLE DE CONTINUER"; exit; fi + if [[ "$ADMINPSEUDO" == "" ]]; then echo -e "${c_red}IMPOSSIBLE DE CONTINUER$c_"; exit; fi - echo "Le Numéro de téléphone SMS Admin? (Support de ce noeud) (ex +33611223344)" + echo -e "${c_light}Le Numéro de téléphone SMS Admin? (Support de ce noeud) (ex +33611223344)$c_" read ADMINPHONE - if [[ "$ADMINPHONE" == "" ]]; then echo "IMPOSSIBLE DE CONTINUER"; exit; fi + if [[ "$ADMINPHONE" == "" ]]; then echo -e "${c_red}IMPOSSIBLE DE CONTINUER$c_"; exit; fi - echo "Le numéro de la carte SIM, du module SMS. AUCUNE liaison SMS? Laissez vide (défaut: +33600000000)" + 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 if [[ "$MASTERPHONE" == "" ]]; then MASTERPHONE="+33600000000"; fi - echo "L'adresse où se trouve votre G1Node pour indiquer où venir chercher ses G1Tag (ex: au G1FabLab de Toulouse)" + 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 "LES PARAMETRES SONT BONS? Appliquer? ENTER ou CTRL-C ?" + 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 @@ -60,9 +68,11 @@ if [[ -f $MY_PATH/.install/templates/init.sh ]]; then cat $init_loc else - echo "init.sh introuvable..." + echo -e "${c_red}init.sh introuvable...$c_" exit 1 fi -[[ -z $repOption || $repOption != "no" ]] && read -p "Voulez-vous installer les modules complémentaires de copylaradio ? (o/n)" repOption +## Installation optionnel de copylaradio + +[[ -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)$ ]] && .install/install_optional.sh