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