mirror of https://framagit.org/kyodev/kyopages.git
maj
This commit is contained in:
parent
35a91ee29f
commit
b304841b1b
134
scripts/sdeb
134
scripts/sdeb
|
@ -1,73 +1,129 @@
|
|||
#!/bin/bash
|
||||
|
||||
version=24/09/2017
|
||||
version=12/10/2017
|
||||
|
||||
# $1=cmd si $2: nb de tentatives pour s'identifier, sinon 3 tentatives par défaut
|
||||
f__sudo(){ # 24/09/2017
|
||||
local nb
|
||||
[ "$2" ] && nb="$2" || nb="3"
|
||||
for (( i=1 ; i<="$nb" ; i++ )); do
|
||||
su -c "$1"
|
||||
[ "$?" == 0 ] && break
|
||||
[ "$i" == "$nb" ] && echo " $nb échec d'authentification, recommencer"
|
||||
done
|
||||
unset i
|
||||
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=timeout en s (O pour désactiver timeout) [$2=message]]
|
||||
# $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"
|
||||
[ "$?" == 0 ] && break
|
||||
[ "$isudo" == "$nb" ] && return 1
|
||||
done
|
||||
}
|
||||
|
||||
# [ $1=timeout en s (O pour désactiver timeout) [$2=message] ]
|
||||
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
|
||||
read -n1 -t"$1" reply
|
||||
read -n1 -t"$1" -s
|
||||
else
|
||||
read -n1 reply
|
||||
read -n1 -s
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
if [ $EUID -ne 0 ]; then
|
||||
echo "vous devez être ROOT pour installer les scripts dans le système"
|
||||
f__sudo "./sdeb"
|
||||
exit 1
|
||||
f__sudo "exec ./sdeb"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo -e "\nInstallation des scripts sdeb"
|
||||
echo -e "============================="
|
||||
f__color
|
||||
|
||||
wget -O getInfo https://framagit.org/kyodev/kyopages/raw/master/scripts/getInfo
|
||||
chmod +x getInfo
|
||||
if [ "$(which figlet)" ]; then
|
||||
figlet -w120 "script sdeb"
|
||||
else
|
||||
echo -e "$BOLD\nscripts sdeb"
|
||||
echo -e "=============\n$STD"
|
||||
fi
|
||||
|
||||
wget -O getIp https://framagit.org/kyodev/kyopages/raw/master/scripts/getIp
|
||||
chmod +x getIp
|
||||
echo -e "$BOLD\nchargement des scripts"
|
||||
echo -e "======================\n$STD"
|
||||
|
||||
wget -O getFirefox https://framagit.org/kyodev/kyopages/raw/master/scripts/getFirefox
|
||||
chmod +x getFirefox
|
||||
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
|
||||
|
||||
wget -O getFlashPlayer https://framagit.org/kyodev/kyopages/raw/master/scripts/getFlashPlayer
|
||||
chmod +x getFlashPlayer
|
||||
wget -O getIp https://framagit.org/kyodev/kyopages/raw/master/scripts/getIp
|
||||
chmod +x getIp
|
||||
|
||||
wget -O getThunderbird https://framagit.org/kyodev/kyopages/raw/master/scripts/getThunderbird
|
||||
chmod +x getThunderbird
|
||||
wget -O getFirefox https://framagit.org/kyodev/kyopages/raw/master/scripts/getFirefox
|
||||
chmod +x getFirefox
|
||||
|
||||
./getFirefox
|
||||
f__pause 10
|
||||
wget -O getFlashPlayer https://framagit.org/kyodev/kyopages/raw/master/scripts/getFlashPlayer
|
||||
chmod +x getFlashPlayer
|
||||
|
||||
./getFlashPlayer
|
||||
f__pause 10
|
||||
wget -O getThunderbird https://framagit.org/kyodev/kyopages/raw/master/scripts/getThunderbird
|
||||
chmod +x getThunderbird
|
||||
fi
|
||||
|
||||
./getThunderbird
|
||||
f__pause 10
|
||||
echo -e "$BOLD\ninstallation des scripts"
|
||||
echo -e "========================\n$STD"
|
||||
|
||||
./getInfo -i
|
||||
f__pause 10
|
||||
if f__dialog_oui_non "oui" "installer les scripts?" ; then
|
||||
./getIp -i
|
||||
f__pause 10
|
||||
|
||||
./getIp -i
|
||||
f__pause 10
|
||||
./getInfo -i
|
||||
f__pause 10
|
||||
|
||||
./getFirefox
|
||||
f__pause 10
|
||||
|
||||
./getFlashPlayer
|
||||
f__pause 10
|
||||
|
||||
./getThunderbird
|
||||
f__pause 10
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
wget -O sdeb https://framagit.org/kyodev/kyopages/raw/master/scripts/sdeb
|
||||
wget -O sdeb https://frama.link/sdeb
|
||||
chmod +x sdeb && ./sdeb
|
||||
|
||||
|
||||
wget -O sdeb https://framagit.org/kyodev/kyopages/raw/master/scripts/sdeb
|
||||
|
|
Loading…
Reference in New Issue