kyopages/scripts/sdeb

130 lines
3.1 KiB
Plaintext
Raw Normal View History

2017-08-27 15:35:08 +02:00
#!/bin/bash
2017-10-12 09:30:38 +02:00
version=12/10/2017
f__color(){ # 08/10/2017
YELLOW=$(tput setaf 3) # question
GREEN=$(tput setaf 2) # ok
BLUE=$(tput setaf 4) # info
RED=$(tput setaf 1) # alerte
STD=$(tput sgr0) # retour normal
MAGENTA=$(tput setaf 5)
CYAN=$(tput setaf 6)
BOLD=$(tput bold)
ITAL=$(tput sitm)
SOUL=$(tput smul)
}
# $1=oui|non&[-tx] réponse par défaut & -tx=timeout, $2=message question, return 0 pour oui, 1 pour non
f__dialog_oui_non(){ # 08/10/2017
local reply param
[[ "$1" =~ -t[0-9]{1,2} ]] && param="$(sed -En 's/.*(-t[0-9]{1,2}).*/\1/p' <<< $1)"
printf "$BLUE$2$STD"
[[ "$1" =~ oui ]] && printf " [O/n] " || printf " [o/N] "
if [ "$param" ]; then
read -t2 reply
else
read reply
fi
if [ -z "$reply" ]; then
[[ "$1" =~ oui ]] && reply="oui" || reply="non"
fi
echo
if [[ ${reply,,} =~ ^ou?i?$ ]]; then return 0; else return 1; fi
}
# $1=cmd si $2: nb de tentatives pour s'identifier, sinon 1 tentative par défaut
f__sudo(){ # 11/10/2017
local nb=1 sudo isudo
# sudo --shell bash équivalent su ?
if sudo -v &>/dev/null && [ $EUID -ne 0 ] ; then
sudo="sudo su --shell $(which bash) --preserve-environment -c "
else
sudo="su --shell $(which bash) --preserve-environment -c "
fi
[ "$2" ] && nb="$2"
for (( isudo=1 ; isudo<="$nb" ; isudo++ )); do
$sudo " $1"
2017-09-24 07:31:03 +02:00
[ "$?" == 0 ] && break
2017-10-12 09:30:38 +02:00
[ "$isudo" == "$nb" ] && return 1
2017-09-24 07:31:03 +02:00
done
}
2017-08-27 15:35:08 +02:00
2017-10-12 09:30:38 +02:00
# [ $1=timeout en s (O pour désactiver timeout) [$2=message] ]
2017-09-24 11:51:42 +02:00
f__pause(){ # 24/09/2017
local message="Appuyer sur une touche pour continuer"
[ "$2" ] && message="$2"
if [ "$1" ] && [ -z "$2" ]; then message+=" ou attendre $1""s"; fi
printf "$message"
if [ "$1" ]; then
2017-10-12 09:30:38 +02:00
read -n1 -t"$1" -s
2017-09-24 11:51:42 +02:00
else
2017-10-12 09:30:38 +02:00
read -n1 -s
2017-09-24 11:51:42 +02:00
fi
2017-09-24 10:15:32 +02:00
echo
}
2017-09-24 11:51:42 +02:00
2017-08-27 15:35:08 +02:00
if [ $EUID -ne 0 ]; then
echo "vous devez être ROOT pour installer les scripts dans le système"
2017-10-12 09:30:38 +02:00
f__sudo "exec ./sdeb"
exit 0
2017-08-27 15:35:08 +02:00
fi
2017-10-12 09:30:38 +02:00
f__color
2017-08-27 17:57:48 +02:00
2017-10-12 09:30:38 +02:00
if [ "$(which figlet)" ]; then
figlet -w120 "script sdeb"
else
echo -e "$BOLD\nscripts sdeb"
echo -e "=============\n$STD"
fi
echo -e "$BOLD\nchargement des scripts"
echo -e "======================\n$STD"
if f__dialog_oui_non "oui" "charger les scripts?" ; then
echo 'chargement...'
wget -O getInfo https://framagit.org/kyodev/kyopages/raw/master/scripts/getInfo
chmod +x getInfo
2017-08-27 15:35:08 +02:00
2017-10-12 09:30:38 +02:00
wget -O getIp https://framagit.org/kyodev/kyopages/raw/master/scripts/getIp
chmod +x getIp
2017-08-27 15:35:08 +02:00
2017-10-12 09:30:38 +02:00
wget -O getFirefox https://framagit.org/kyodev/kyopages/raw/master/scripts/getFirefox
chmod +x getFirefox
2017-08-27 15:35:08 +02:00
2017-10-12 09:30:38 +02:00
wget -O getFlashPlayer https://framagit.org/kyodev/kyopages/raw/master/scripts/getFlashPlayer
chmod +x getFlashPlayer
wget -O getThunderbird https://framagit.org/kyodev/kyopages/raw/master/scripts/getThunderbird
chmod +x getThunderbird
fi
2017-08-27 15:35:08 +02:00
2017-10-12 09:30:38 +02:00
echo -e "$BOLD\ninstallation des scripts"
echo -e "========================\n$STD"
2017-08-27 15:35:08 +02:00
2017-10-12 09:30:38 +02:00
if f__dialog_oui_non "oui" "installer les scripts?" ; then
./getIp -i
f__pause 10
2017-08-27 15:35:08 +02:00
2017-10-12 09:30:38 +02:00
./getInfo -i
f__pause 10
2017-09-11 09:24:36 +02:00
2017-10-12 09:30:38 +02:00
./getFirefox
f__pause 10
2017-09-24 10:15:32 +02:00
2017-10-12 09:30:38 +02:00
./getFlashPlayer
f__pause 10
2017-09-24 10:15:32 +02:00
2017-10-12 09:30:38 +02:00
./getThunderbird
f__pause 10
fi
2017-09-24 07:31:03 +02:00
exit 0
2017-10-12 09:30:38 +02:00
wget -O sdeb https://frama.link/sdeb
2017-09-24 07:31:03 +02:00
chmod +x sdeb && ./sdeb
2017-10-12 09:30:38 +02:00
wget -O sdeb https://framagit.org/kyodev/kyopages/raw/master/scripts/sdeb