mirror of https://framagit.org/kyodev/kyopages.git
getIp 2.11.0
This commit is contained in:
parent
b5a9dffa3b
commit
b6fb922d1c
204
scripts/getIp
204
scripts/getIp
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
version=2.10.0
|
||||
date="11/02/2018"
|
||||
version=2.11.0
|
||||
date="03/03/2018"
|
||||
projet="simpledeb"
|
||||
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
|
||||
script="getIp"
|
||||
|
@ -11,29 +11,38 @@ script="getIp"
|
|||
# contributeurs: kyodev
|
||||
#####
|
||||
|
||||
f__color(){ # 31/01/2018
|
||||
f__color(){ # 03/03/2018
|
||||
|
||||
BLACK=$(tput setaf 0)
|
||||
RED=$(tput setaf 1) # alerte
|
||||
GREEN=$(tput setaf 2) # ok
|
||||
YELLOW=$(tput setaf 3) # question
|
||||
BLUE=$(tput setaf 4) # info
|
||||
CYAN=$(tput setaf 6)
|
||||
MAGENTA=$(tput setaf 5)
|
||||
STD=$(tput sgr0) # retour "normal"
|
||||
BOLD=$(tput bold)
|
||||
ITAL=$(tput sitm)
|
||||
SOUL=$(tput smul)
|
||||
if type -p tput &>/dev/null && tput setaf 1 &>/dev/null; then
|
||||
BLACK=$(tput setaf 0)
|
||||
RED=$(tput setaf 1) # alerte
|
||||
GREEN=$(tput setaf 2) # ok
|
||||
YELLOW=$(tput setaf 3) # question
|
||||
BLUE=$(tput setaf 4) # info
|
||||
CYAN=$(tput setaf 6)
|
||||
MAGENTA=$(tput setaf 5)
|
||||
STD=$(tput sgr0) # retour "normal"
|
||||
BOLD=$(tput bold)
|
||||
ITAL=$(tput sitm)
|
||||
SOUL=$(tput smul)
|
||||
else
|
||||
YELLOW=$( echo -n "\033[0;33m" ) # ?
|
||||
GREEN=$( echo -n "\033[0;32m" ) # ok
|
||||
BLUE=$( echo -n "\033[0;34m" ) # info
|
||||
RED=$( echo -n "\033[0;31m" ) # alerte
|
||||
COLOR=$( echo -n "\033[0m" ) # standard
|
||||
STD=$( echo -n "\033[0m" ) # standard
|
||||
fi
|
||||
}
|
||||
|
||||
# $1=-c|-l|-lc, $2 répertoire, [$3] motif exclusion sur nom fichier, affiche 0|null si répertoire inexistant
|
||||
# -c: compte du nombre de fichiers dans un répertoire
|
||||
# -l: liste inline des noms de fichiers seuls
|
||||
# -lc: liste en colonne des noms de fichiers seuls
|
||||
# -l: liste inline des noms de fichiers seuls (sans chemin) (similaire ls)
|
||||
# -lc: liste en colonne des noms de fichiers seuls (sans chemin) (similaire ls -1)
|
||||
# si joker (*?) sur chemin, le motif d'exclusion ne s'applique pas à un répertoire listé, juste sur le nom du fichier
|
||||
# attention, les jokers sont interprétés à l'appel de la fonction
|
||||
# exemple: f__dir -l "$dir" "lock|partial" ou "\.list"
|
||||
f__dir(){ # 12/12/2017
|
||||
f__dir(){ # 22/02/2017
|
||||
local i=0 action="-c" stock=''
|
||||
|
||||
[[ "$1" =~ - ]] && action="$1" || action="-c" # si option en erreur: -c
|
||||
|
@ -43,9 +52,8 @@ f__dir(){ # 12/12/2017
|
|||
[ -z "$REPLY" ] && continue # ligne vide, on passe
|
||||
((i++))
|
||||
stock+="$REPLY "
|
||||
#echo "$REPLY $i"
|
||||
fi
|
||||
done <<< $( ls $2 2>/dev/null )
|
||||
done <<< "$( ls $2 2>/dev/null )"
|
||||
if [ "$action" == "-c" ]; then
|
||||
echo "$i"
|
||||
elif [ "$action" == "-l" ]; then
|
||||
|
@ -70,11 +78,11 @@ f__error(){ # 18/12/2017
|
|||
}
|
||||
|
||||
# affichage en bleu, si $1=raw pas de ligne vide à la fin, si $1=log alors uniquement $2 logué, combiné: $1="log:raw"
|
||||
f__info(){ # 26/12/2017
|
||||
f__info(){ # 22/02/2018
|
||||
local depart=1 i
|
||||
|
||||
[[ "$1" =~ "raw" || "$1" =~ "log" ]] && depart=2
|
||||
[[ "$1" =~ "log" ]] && f__log "$(sed -E 's/\\t//;s/\\n// ' <<< $2 | xargs )"
|
||||
[[ "$1" =~ "log" ]] && f__log "$( sed -E 's/\\t//;s/\\n// ' <<< "$2" | xargs )"
|
||||
for (( i=$depart ; i<=$# ; i++ )); do
|
||||
echo -e " $BLUE${!i}$STD"
|
||||
done
|
||||
|
@ -139,10 +147,12 @@ f__requis(){ # 26/01/2018
|
|||
[ "$commandsMissing" ] && return 1 || return 0
|
||||
}
|
||||
|
||||
# $@=cmd à lancer en root avec su ou sudo. si $@ contient :x: x=nombre de tentatives, sinon 2 tentatives par défaut
|
||||
# $@=cmd à lancer en root avec su ou sudo. si $@ contient [':x:'] x=nombre de tentatives, 3 par défaut
|
||||
# si sudo si possible sera utilisé.
|
||||
# si su &2 redirigé sur &1
|
||||
# si bash inexistant, return 2
|
||||
f__sudo(){ # 26/01/2018
|
||||
local nb sudo isudo toBash options nbDefault=2
|
||||
f__sudo(){ # 24/02/2018
|
||||
local nb sudo isudo toBash options nbDefault=3
|
||||
|
||||
# détermination sudo possible
|
||||
type -p bash &>/dev/null && toBash=$( type -p bash ) || return 2
|
||||
|
@ -164,17 +174,22 @@ f__sudo(){ # 26/01/2018
|
|||
options="$@"
|
||||
fi
|
||||
# lancement cmds
|
||||
for (( isudo=1 ; isudo<="$nb" ; isudo++ )); do
|
||||
$sudo " $options"
|
||||
[ "$?" == 0 ] && break
|
||||
[ "$isudo" == "$nb" ] && return 1
|
||||
done
|
||||
if [[ "$sudo" =~ ^sudo ]]; then
|
||||
$sudo "$options"
|
||||
else
|
||||
for (( isudo=1 ; isudo<="$nb" ; isudo++ )); do
|
||||
echo -n "[su] Root, "
|
||||
$sudo "$options" 2>&1 # redirection demande pass (et erreur) sur &1 (utile quand &2 est redirigé en amont)
|
||||
[ "$?" == 0 ] && break
|
||||
[ "$isudo" == "$nb" ] && return 1
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# user ayant initié la session graphique, assigne $fu_user
|
||||
# return 1 sur échec identification user, return 2 sur absence home/
|
||||
# gestion variable environnement user avec: USER_INSTALL=<user> script
|
||||
f__user(){ # 25/01/2018
|
||||
f__user(){ # 24/02/2018
|
||||
local user userid test root_login
|
||||
|
||||
root_login="$(grep ':0:' /etc/passwd | cut -d':' -f1)" || root_login="root"
|
||||
|
@ -192,21 +207,21 @@ f__user(){ # 25/01/2018
|
|||
if [ "$SUDO_UID" ]; then
|
||||
userid="$SUDO_UID";
|
||||
elif grep -qEo '[0-9]+' <<< "$XDG_RUNTIME_DIR" ; then
|
||||
userid="$(grep -Eo '[0-9]+' <<< $XDG_RUNTIME_DIR | cut -d'/' -f4)"
|
||||
userid=$( grep -Eo '[0-9]+' <<< "$XDG_RUNTIME_DIR" | cut -d'/' -f4 )
|
||||
elif grep -qEo '[0-9]+' <<< "$XAUTHORITY" ; then
|
||||
userid="$(grep -Eo '[0-9]+' <<< $XAUTHORITY | cut -d'/' -f4)"
|
||||
userid=$( grep -Eo '[0-9]+' <<< "$XAUTHORITY" | cut -d'/' -f4 )
|
||||
fi
|
||||
[ "$userid" ] && user="$(grep $userid /etc/passwd | cut -d ":" -f 1 )"
|
||||
[ "$userid" ] && user=$( grep $userid /etc/passwd | cut -d ":" -f 1 )
|
||||
if [ "$user" ] && [ "$user" != "$root_login" ]; then
|
||||
fu_user="$user"
|
||||
return 0
|
||||
else
|
||||
if [ "$SUDO_USER" ] && [ "$SUDO_USER" != "$root_login" ]; then
|
||||
user="$SUDO_USER";
|
||||
elif grep -qv 'root' <<< "$(who)"; then
|
||||
user="$(grep -v 'root' <<< $(who) | head -n1 | cut -d ' ' -f1)"; # grep -v 'root' <<< $(who) | awk 'FNR==1{print $1}'
|
||||
elif who | grep -qv 'root'; then
|
||||
user=$( who | grep -v 'root' | head -n1 | cut -d ' ' -f1 ); # who | grep -v 'root' | awk 'FNR==1{print $1}'
|
||||
elif grep -q 'hourly.*get[A-Z].*\.anacrontab.*\.config/anacron/spool' /etc/crontab; then
|
||||
user="$(grep 'hourly.*get[A-Z].*\.anacrontab.*\.config/anacron/spool' /etc/crontab | head -n1 | cut -d' ' -f2)"; # grep 'hourly.*get[A-Z].*\.anacrontab.*\.config/anacron/spool' /etc/crontab | awk 'FNR==1{print $2}
|
||||
user=$( grep 'hourly.*get[A-Z].*\.anacrontab.*\.config/anacron/spool' /etc/crontab | head -n1 | cut -d' ' -f2 ); # grep 'hourly.*get[A-Z].*\.anacrontab.*\.config/anacron/spool' /etc/crontab | awk 'FNR==1{print $2}
|
||||
fi
|
||||
fi
|
||||
fu_user="$user"
|
||||
|
@ -219,11 +234,18 @@ f__user(){ # 25/01/2018
|
|||
# $1='-w' comptage dans variable $2 des mots
|
||||
# $1='-wv' comptage dans variable $2, des mots $3, affiche quantité
|
||||
# f__wcv -l $var ; f__wcv -w $var ; f__wcv -wv $var "mot"
|
||||
f__wcv(){ # 09/11/2017
|
||||
f__wcv(){ # 28/02/2018
|
||||
|
||||
[[ "$1" =~ -l|-wv|-w ]] || display="erreur f__wcv \$1 ($1) incorrect \n"
|
||||
[ "$1" == "-l" ] && echo "$2" | grep -cEv '^[[:space:]]*$' # (wc -l compterait 1 pour une variable vide)
|
||||
[ "$1" == "-w" ] && echo "$(xargs <<< $2) " | grep -o " " | grep -c . # echo $(( $(grep -c .)+1 ))
|
||||
[ "$1" == "-wv" ] && echo "$2" | grep -o "$3" | grep -c .
|
||||
if [ "$1" == "-l" ]; then
|
||||
grep -cEv '^[[:space:]]*$' <<< "$2" # (wc -l compterait 1 pour une variable vide)
|
||||
elif [ "$1" == "-w" ]; then
|
||||
result=$( xargs <<< "$2" | grep -o '[[:graph:]][[:blank:]][[:graph:]]' | grep -c ' ' )
|
||||
[ "$result" -ne 0 ] && result=$(( result+1 ))
|
||||
echo "$result"
|
||||
elif [ "$1" == "-wv" ]; then
|
||||
grep -o "$3" <<< "$2" | grep -c .
|
||||
fi
|
||||
}
|
||||
|
||||
# test wget, $1=url à tester, $2=''|print|loc|test
|
||||
|
@ -231,7 +253,7 @@ f__wcv(){ # 09/11/2017
|
|||
# si $2=print affiche url testée & entêtes http & location, return 0
|
||||
# si $2=loc affiche seulement location, return 0
|
||||
# si $2=test return 0 si ok, return 1 si KO
|
||||
f__wget_test(){ # 16/01/2018
|
||||
f__wget_test(){ # 22/02/2018
|
||||
local file_test_wget="/tmp/testWget-$script" retourWget retourHttp location
|
||||
|
||||
wget -Sq --timeout=5 --tries=2 --user-agent="$user_agent" --spider --save-headers "$1" &>"$file_test_wget"
|
||||
|
@ -249,7 +271,7 @@ f__wget_test(){ # 16/01/2018
|
|||
if [ "$2" == "test" ]; then
|
||||
rm -f "$file_test_wget"
|
||||
# spécial maintenance frama.link, pas de redirection sur page status framalink
|
||||
grep -q '303' <<< $retourHttp && return 1 # 303 See Other
|
||||
grep -q '303' <<< "$retourHttp" && return 1 # 303 See Other
|
||||
[ "$retourWget" == "0" ] && return 0 || return 1
|
||||
fi
|
||||
if [ "$2" == "print" ]; then
|
||||
|
@ -272,7 +294,7 @@ f__wget_test(){ # 16/01/2018
|
|||
echo -e "$RED erreur wget, $retourWget \n $1 \n $YELLOW$retourHttp \n $location$STD" # pour les diags
|
||||
return 1
|
||||
fi
|
||||
if grep -q '200' <<< $retourHttp; then
|
||||
if grep -q '200' <<< "$retourHttp"; then
|
||||
echo -e "$GREEN\ntout est ok, réessayer$STD\n"
|
||||
fi
|
||||
rm -f "$file_test_wget"
|
||||
|
@ -349,7 +371,7 @@ f_help(){ # 24/01/2018
|
|||
# "[ \"$1\" != \"notitre\" ]" ou "[ $1 != notitre ]" (attention au manque de ")
|
||||
# flush (f_pr flush) inutile si f_d(x) final
|
||||
# $1 type, $2 texte, [$3] test /!\ assigne la variable parent $text
|
||||
f_pr(){ # 10/12/2017
|
||||
f_pr(){ # 03/03/2018
|
||||
local preline='' line='' endline=" \n"
|
||||
|
||||
[[ "$1" == 'titre1' ]] && preline=" $GREEN"
|
||||
|
@ -357,9 +379,9 @@ f_pr(){ # 10/12/2017
|
|||
[[ "$1" == 'titre2' ]] && preline+="$BOLD"
|
||||
[[ "$1" == 'titre2' ]] && endline+="$STD"
|
||||
# [[ "$1" =~ titre ]] && endline+="\n"
|
||||
[[ "$1" == 'l1' ]] && line="$( sed -E 's/(.*)/\1/ ' <<<$2 )"
|
||||
[[ "$1" == 'l2' ]] && line="$( sed -E 's/(.*)/ \1/ ' <<<$2 )"
|
||||
[[ "$1" == 'l3' ]] && line="$( sed -E 's/(.*)/ \1/ ' <<<$2 )"
|
||||
[[ "$1" == 'l1' ]] && line="$( sed -E 's/(.*)/\1/ ' <<< "$2" )"
|
||||
[[ "$1" == 'l2' ]] && line="$( sed -E 's/(.*)/ \1/ ' <<< "$2" )"
|
||||
[[ "$1" == 'l3' ]] && line="$( sed -E 's/(.*)/ \1/ ' <<< "$2" )"
|
||||
[[ "$line" ]] || line="$2" # utilisation $2 sans traitement à faire
|
||||
|
||||
if [[ "$3" ]]; then
|
||||
|
@ -389,51 +411,51 @@ fi_ip_pub(){ #v 14/12/2017
|
|||
done
|
||||
}
|
||||
|
||||
# $1=-4|-6, assigne $fg_ip, $fg_gws6, $fg_ifn, $fg_mac, fg_ip_deprec (ipv6)
|
||||
figet_ip(){ # 09/02/2018
|
||||
# $1=-4|-6, assigne $fg_ip, $fg_gws, $fg_ifn, $fg_mac, fg_ip_deprec (ipv6)
|
||||
figet_ip(){ # 02/03/2018
|
||||
local target ifn
|
||||
unset fg_ip fg_ip_deprec fg_gws fg_ifn_prior fg_ifn fg_mac
|
||||
|
||||
x_ip=1
|
||||
[ $( f__which ip ) ] || return 1
|
||||
[ "$1" ] && proto="$1" || proto="-4"
|
||||
|
||||
# adresses ip
|
||||
fg_ip=$(
|
||||
awk -v proto="$proto" '
|
||||
BEGIN { if (proto == -6) esp=41; else esp=16 }
|
||||
fg_ip=$( ip $proto -o address | awk -v proto="$proto" '
|
||||
BEGIN { if (proto == -6) larg=41; else larg=16 }
|
||||
/scope global/ {
|
||||
sub(/wl.*/,$2" (wifi)",$2); sub(/.*en.*|.*eth.*/,$2" (ethernet)",$2);
|
||||
match($0,/scope .*\\/); scope=substr($0,RSTART,RLENGTH)
|
||||
sub(/scope /,"",scope); sub(/\\/,"",scope)
|
||||
match($0,/preferred_lft .*sec/); lft=substr($0,RSTART,RLENGTH)
|
||||
sub(/sec/,"s",lft); sub(/preferred_lft/,"lft",lft)
|
||||
printf "%-17s: %-"esp"s (%s) %s \n",$2,$4,lft,scope }
|
||||
printf "%-17s: %-"larg"s ",$2,$4
|
||||
if (proto == -6) {
|
||||
match($0,/scope .*\\/); scope=substr($0,RSTART,RLENGTH)
|
||||
sub(/scope /,"",scope); sub(/\\/,"",scope)
|
||||
match($0,/preferred_lft .*sec/); lft=substr($0,RSTART,RLENGTH)
|
||||
sub(/sec/,"s",lft); sub(/preferred_lft/,"lft",lft)
|
||||
printf "(%s) %s \n",lft,scope }
|
||||
else printf "\n" }
|
||||
/fe80::/ {
|
||||
sub(/wl.*/,$2" (wifi)",$2)
|
||||
match($0,/scope .* \\/); scope=substr($0,RSTART,RLENGTH); sub(/scope /,"",scope); sub(/ \\/,"",scope)
|
||||
link=link"\n"sprintf("%-17s: %-22s %s",$2,$4,scope) }
|
||||
/ lo / { lo=sprintf("%s (loopback) : %s",$2,$4) }
|
||||
END { printf "%s\n%s",link,lo }
|
||||
' <<< $( ip $proto -o address )
|
||||
)
|
||||
' )
|
||||
# ipv6, traitemenent adresses dynamiques
|
||||
if [ "$proto" == "-6" ]; then
|
||||
fg_ip_deprec=$( sed -n '/temporary deprecated dynamic/p' <<< $fg_ip )
|
||||
fg_ip=$( sed '/temporary deprecated dynamic/d; /preferred_lft 0sec/d' <<< $fg_ip )
|
||||
fg_ip_deprec=$( sed -n '/temporary deprecated dynamic/p' <<< "$fg_ip" )
|
||||
fg_ip=$( sed '/temporary deprecated dynamic/d; /preferred_lft 0sec/d' <<< "$fg_ip" )
|
||||
fi
|
||||
|
||||
# passerelles
|
||||
fg_gws=$(
|
||||
awk '
|
||||
BEGIN { if (proto == -6) esp=42; else esp=12 }
|
||||
/default via/ { printf "%-"esp"s (%s)\n",$3,$5 }
|
||||
' <<< $( ip $proto route )
|
||||
)
|
||||
fg_gws=$( ip $proto route | awk '
|
||||
BEGIN { if (proto == -6) larg=42; else larg=12 }
|
||||
/default via/ { printf "%-"larg"s (%s)\n",$3,$5 }
|
||||
' )
|
||||
# interface sortante
|
||||
if [ "$proto" == "-6" ]; then
|
||||
target=$( awk '/proto ra / { print $1; exit}' <<< $( ip $proto -o route ) )
|
||||
fg_ifn_prior=$( ip $proto route get $target )
|
||||
fg_ifn_prior=$( ip $proto route get $target | sed -En 's/.*dev (.*) proto.*src ([0-9a-f:]+).*/\1 (\2)/p' )
|
||||
target=$( ip $proto -o route | awk '/proto ra / { print $1; exit}' )
|
||||
if [ "$target" ]; then
|
||||
fg_ifn_prior=$( ip $proto route get $target | sed -En 's/.*dev (.*) proto.*src ([0-9a-f:]+).*/\1 (\2)/p' )
|
||||
fi
|
||||
else
|
||||
fg_ifn_prior=$( ip $proto route get 255.255.255.255 | sed -En 's/.*dev (.*) src ([0-9.]+) .*/\1 (\2)/p' )
|
||||
fi
|
||||
|
@ -450,10 +472,10 @@ figet_ip(){ # 09/02/2018
|
|||
}
|
||||
|
||||
# $1=-4|-6, assigne $fg_ip_pub
|
||||
figet_ip_pub(){ #v 24/12/2017
|
||||
figet_ip_pub(){ # 03/03/2018
|
||||
local dig_test ip_test iip
|
||||
|
||||
list_ip4(){ # testé 11/12/2017
|
||||
list_ip4(){ # testé 11/12/2017
|
||||
|
||||
ip_test=( # pas de https
|
||||
http://whatismyip.akamai.com
|
||||
|
@ -479,7 +501,7 @@ figet_ip_pub(){ #v 24/12/2017
|
|||
)
|
||||
}
|
||||
|
||||
list_ip6(){ # testé 11/12/2017
|
||||
list_ip6(){ # testé 11/12/2017
|
||||
|
||||
ip_test=(
|
||||
http://ipv6.whatismyip.akamai.com
|
||||
|
@ -503,16 +525,19 @@ figet_ip_pub(){ #v 24/12/2017
|
|||
}
|
||||
|
||||
x_ip_pub=1
|
||||
|
||||
option="$1"
|
||||
unset fg_ip_pub
|
||||
#
|
||||
# assignation variables
|
||||
if [ "$1" == "-4" ]; then
|
||||
ping -4 -c1 conncheck.opensuse.org &>/dev/null || ping -4 -c1 free.fr &>/dev/null || return 1 # test connectivité
|
||||
ping -c1 conncheck.opensuse.org &>/dev/null || ping -c1 free.fr &>/dev/null || return 1 # test connectivité
|
||||
list_ip4_dig
|
||||
list_ip4
|
||||
ip_telnet=4.ifcfg.me
|
||||
elif [ "$1" == "-6" ]; then
|
||||
ping -6 -c1 conncheck.opensuse.org &>/dev/null || ping -6 -c1 free.fr &>/dev/null || return 1 # test connectivité
|
||||
[ -h $( which ping6 ) ] && ping6="ping -6 " || ping6="ping6"
|
||||
"$ping6" -c1 conncheck.opensuse.org &>/dev/null || "$ping6" -c1 free.fr &>/dev/null || return 1 # test connectivité
|
||||
list_ip6_dig
|
||||
list_ip6
|
||||
ip_telnet=6.ifcfg.me
|
||||
|
@ -619,13 +644,12 @@ fscript_get_version(){ # 24/01/2018
|
|||
}
|
||||
|
||||
# installation du script dans le système
|
||||
fscript_install(){ # 26/01/2018
|
||||
fscript_install(){ # 24/02/2018
|
||||
|
||||
if grep -q 'bin' <<< "$( dirname $0 )" ; then
|
||||
f__info "$RED""l'installation dans le système doit se faire depuis un script local $GREEN(./$script -i )"
|
||||
if grep -Eq "$script_install|/usr/bin/$script" <<< "$0"; then
|
||||
f__info "$RED""l'installation dans le système doit se faire depuis le script non installé $GREEN(./$script -i )"
|
||||
return 1
|
||||
fi
|
||||
|
||||
type -t fscript_install_special &>/dev/null && fscript_install_special # test, si fonction spécifique, appel
|
||||
f__requis "wget anacron cron" || exit 1
|
||||
# install /opt
|
||||
|
@ -645,9 +669,9 @@ fscript_install(){ # 26/01/2018
|
|||
}
|
||||
|
||||
# suppression du script dans le système
|
||||
fscript_remove(){ # 26/01/2018
|
||||
fscript_remove(){ # 24/02/2018
|
||||
|
||||
if ! grep -q 'bin' <<< "$( dirname $0 )" ; then
|
||||
if ! grep -Eq "$script_install|/usr/bin/$script" <<< "$0"; then
|
||||
f__info "$RED""cette fonction doit être appelée depuis le script installé dans le système $GREEN($script -r)"
|
||||
return 1
|
||||
fi
|
||||
|
@ -657,7 +681,7 @@ fscript_remove(){ # 26/01/2018
|
|||
fi
|
||||
|
||||
type -t fscript_remove_special &>/dev/null && fscript_remove_special # test, si fonction spécifique, appel
|
||||
# suppression de /opt lien /usr/bin
|
||||
# suppression /opt, lien /usr/bin
|
||||
rm -f "$script_install"
|
||||
unlink "/usr/bin/$script" &>/dev/null
|
||||
# cron/anacron remove
|
||||
|
@ -667,11 +691,11 @@ fscript_remove(){ # 26/01/2018
|
|||
}
|
||||
|
||||
# mise à jour script, [$1 != "" si upgrade en place, $1 dans message info]
|
||||
fscript_update(){ # 26/01/2018
|
||||
fscript_update(){ # 01/03/2018
|
||||
local dirTemp="/tmp/$script-maj" upgradeEnPlace="$1"
|
||||
|
||||
type -t fscript_update_special &>/dev/null && fscript_update_special # test, si fonction spécifique, appel
|
||||
if [ -z "$upgradeEnPlace" ] && ! grep -q 'bin' <<< "$( dirname $0 )" ; then
|
||||
if [ -z "$upgradeEnPlace" ] && ! grep -Eq "$script_install|/usr/bin/$script" <<< "$0"; then
|
||||
f__info "$RED""cette fonction doit être appelée depuis le script installé dans le système $GREEN($script -u)"
|
||||
return 1
|
||||
fi
|
||||
|
@ -744,7 +768,7 @@ testuser(){ # 4/12/2017
|
|||
fi
|
||||
}
|
||||
|
||||
prg_init(){ # 25/01/2018
|
||||
prg_init(){ # 03/03/2018
|
||||
|
||||
PATH='/usr/sbin:/usr/bin:/sbin:/bin'
|
||||
TERM=xterm
|
||||
|
@ -752,11 +776,9 @@ prg_init(){ # 25/01/2018
|
|||
IFS=$' \t\n'
|
||||
export PATH TERM IFS
|
||||
|
||||
# whereis script retourne vide si installé
|
||||
DIRNAME=$( dirname $0 )
|
||||
DIRNAME=${DIRNAME#/usr/bin} # suppression /usr/bin éventuel au début ( lien )
|
||||
DIRNAME=${DIRNAME#/opt/bin} # suppression /opt/bin éventuel au début ( install )
|
||||
[ "$DIRNAME" ] && DIRNAME+="/"
|
||||
# options bash figées
|
||||
shopt -s checkwinsize complete_fullquote extglob extquote interactive_comments sourcepath
|
||||
shopt -u force_fignore execfail failglob
|
||||
|
||||
# test bash v4
|
||||
[ "$BASH_VERSINFO" == 4 ] || f__error "bash v4 requis" "version installée: $BASH_VERSION"
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
# changelog getIp
|
||||
|
||||
|
||||
## getIp 2.11.0 03/03/2018
|
||||
|
||||
* synchro fscript_install, fscript_remove, fscript_update
|
||||
* révision: f__color, f__sudo, f__wcv, figet_ip, prg_init
|
||||
* cosmétique, obsolescence bash/ubuntu 16.04: f__dir, f__info, f__user, f__wget_test,
|
||||
* fix: figet_ip_pub, ubuntu 16.04
|
||||
|
||||
## getIp 2.10.0 11/02/2018
|
||||
|
||||
* synchro: f__color
|
||||
|
@ -39,15 +46,15 @@
|
|||
|
||||
## getIp 2.3.0 29/12/2017
|
||||
|
||||
* syncro composants
|
||||
* synchro composants
|
||||
|
||||
## getIp 2.2.0 26/12/2017
|
||||
|
||||
révision, syncro: f__info, option combinée raw:log
|
||||
révision, synchro: f__info, option combinée raw:log
|
||||
|
||||
## getIp 2.1.0 24/12/2017
|
||||
|
||||
* syncro: nouveau composants scripts
|
||||
* synchro: nouveau composants scripts
|
||||
* révision: figet_ip_pub, wget, définition logs, pour cause de bug wget? sur testing
|
||||
* fix: f__wget_test, incompatible avec redirection logs
|
||||
|
||||
|
@ -58,7 +65,7 @@ révision, syncro: f__info, option combinée raw:log
|
|||
## getIp 1.20.0 14/12/2017
|
||||
|
||||
* révision: figer_ip + f__dir
|
||||
* syncro getInfo
|
||||
* synchro getInfo
|
||||
|
||||
## getIp 1.19.0 11/12/2017
|
||||
|
||||
|
@ -78,7 +85,7 @@ révision, syncro: f__info, option combinée raw:log
|
|||
|
||||
* nouveau: option - ( ou -46 ), ipv4 & ipv6
|
||||
* nouveau: prg_init
|
||||
* révision: syncro fonctions communes
|
||||
* révision: synchro fonctions communes
|
||||
* révision: renommage $user_
|
||||
* révision: démarrage
|
||||
* révision: fscript_cronAnacron, fscript_install, fscript_remove, fscript_update
|
||||
|
@ -123,7 +130,7 @@ révision, syncro: f__info, option combinée raw:log
|
|||
* révision figet_ip figet_ip_public
|
||||
* test bash4 au démarrage
|
||||
* révision f__color: utilisation terminfo pour retour au std (et non noir), donc modifs:
|
||||
* f__color f__error f__info f__wget_test f__dialog_oui_non
|
||||
* f__color f__error f__info f__wget_test
|
||||
* fscript_get_version fscript_install fscript_remove fscript_update
|
||||
* intégration f__sudo dans install & remove script
|
||||
|
||||
|
|
Loading…
Reference in New Issue