sdeb 1.5.0

This commit is contained in:
kyodev 2018-01-15 09:46:45 +01:00
parent bf2c3e523a
commit 8c0fd9ed18
1 changed files with 15 additions and 7 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
version=1.4.0 version=1.5.0
date=19/12/2017 date=14/01/2018
f__color(){ # 08/10/2017 f__color(){ # 08/10/2017
YELLOW=$(tput setaf 3) # question YELLOW=$(tput setaf 3) # question
@ -34,9 +34,10 @@ f__dialog_oui_non(){ # 12/12/2017
if [[ ${REPLY,,} =~ ^ou?i?$ ]]; then return 0; else return 1; fi if [[ ${REPLY,,} =~ ^ou?i?$ ]]; then return 0; else return 1; fi
} }
# $1=cmd si $2: nb de tentatives pour s'identifier, sinon 2 tentatives par défaut, suppose bash existant # $@=cmd à lancer en root avec su ou sudo. si $@ contient :x: x=nombre de tentatives, sinon 2 tentatives par défaut
f__sudo(){ # 23/12/2017 # si bash inexistant, return 2
local nb=2 sudo isudo toBash f__sudo(){ # 14/01/2018
local nb sudo isudo toBash options
type -p bash &>/dev/null && toBash=$( type -p bash ) || return 2 type -p bash &>/dev/null && toBash=$( type -p bash ) || return 2
# sudo --shell bash équivalent su ? # sudo --shell bash équivalent su ?
@ -45,9 +46,16 @@ f__sudo(){ # 23/12/2017
else else
sudo="su --shell $toBash --preserve-environment -c " sudo="su --shell $toBash --preserve-environment -c "
fi fi
[ "$2" ] && nb=$(( "$2" )) if [[ "$@" =~ :??: ]]; then
nb="$@"
nb=${nb#*:}
nb=${nb%:*}
else
nb=2
fi
options=${@//:$nb:/ }
for (( isudo=1 ; isudo<="$nb" ; isudo++ )); do for (( isudo=1 ; isudo<="$nb" ; isudo++ )); do
$sudo " $1" $sudo " $options"
[ "$?" == 0 ] && break [ "$?" == 0 ] && break
[ "$isudo" == "$nb" ] && return 1 [ "$isudo" == "$nb" ] && return 1
done done