diff --git a/docs/scripts/getIp.md b/docs/scripts/getIp.md index 54d23ed..04c2383 100644 --- a/docs/scripts/getIp.md +++ b/docs/scripts/getIp.md @@ -19,7 +19,7 @@ chmod +x getIp getIp 0.7.0 ---------------------------------------------------------------------- - ./getIo : exécution normale + ./getIp : exécution normale getIp : exécution normale si script installé dans le système ce script requiert une des commandes suivantes pour déterminer l'ip publique : diff --git a/scripts/getIp b/scripts/getIp index 3480f87..e03013a 100755 --- a/scripts/getIp +++ b/scripts/getIp @@ -1,6 +1,6 @@ #!/bin/bash -version=0.7.2 +version=0.7.3 date="18/08/2017" projet="simpledeb" contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues" @@ -81,7 +81,7 @@ fscript_cronAnacron(){ # v18/08/2017 # table anacron echo "7 01 $script nice /opt/bin/$script --upgrade" > "$fileAnacron" ## dev: anacron journalier: - [ "$LOGNAME" == "$lognameDev" ] && echo "1 01 $script test nice /opt/bin/$script --upgrade 1>/dev/null" >> "$fileAnacron" + [ "$user_" == "$lognameDev" ] && echo "1 01 $script test nice /opt/bin/$script --upgrade 1>/dev/null" >> "$fileAnacron" # création spool anacron utilisateur mkdir -p "$dirSpool" chown -R "$user_": "$dirAnacron" "$dirSpool" @@ -198,6 +198,7 @@ EOF } get_ip() { # $ip_local, $gateway, $gateway_type, $gateway_one, $ip_local, $ip_local_type, $ifname, $ifname_type + [ -z "$(which ip)" ] && return 1 ip_local="$(sed '/lo.*inet/d; /inet6.*scope global/d' <<< "$(ip -o a)" | awk '{print $4,"(",$2,")"}')" ip_local_type="$(sed -E 's/(^.*wl.*)/\1 (wifi)/;s/(^.*en.*|^.*eth.*)/\1 (ethernet)/' <<< $ip_local)" gateway="$(LC_ALL=C ip -4 route | awk '/default via/ {print $3,"(",$5,")"}'; LC_ALL=C ip -6 route | awk '/default via/ {print $3,"(",$5,")"}')" @@ -207,7 +208,6 @@ get_ip() { # $ip_local, $gateway, $gateway_type, $gateway_one, $ip_local, $ip_lo ifname_type="$(sed -E 's/(^wl.*)/\1 (wifi)/;s/(^en.*|^eth.*)/\1 (ethernet)/' <<< $ifname)" } - get_ip_public(){ # $1=IPv4|IPv6, assigne $ip_public list_ip4(){ @@ -313,27 +313,27 @@ fileLogs="/var/log/sdeb_$script.log" options="$@" for i in "$options"; do case $i in - --install | -i ) f__user && fscript_install ;; # installation du script dans le système - --remove | -r ) f__user && fscript_remove ;; # suppression du script dans le système + --install | -i ) f__user && fscript_install ;; # installation du script dans le système + --remove | -r ) f__user && fscript_remove ;; # suppression du script dans le système --upgrade | -u ) opType="upgrade" f__user || f__error "user indéterminé ou home inexistant" fscript_get_version - fscript_dl ;; # upgrade script si maj possible + fscript_dl ;; # upgrade script si maj possible --ip4 | -4 ) get_ip_public "IPv4" - echo "$ip_public" ;; # affiche ip v4 public + echo "$ip_public" ;; # affiche ip v4 public --ip6 | -6 ) get_ip_public "IPv6" - echo "$ip_public" ;; # affiche ip v6 public + echo "$ip_public" ;; # affiche ip v6 public --local | "" ) - get_ip + get_ip || f__error "iproute2 doit être installé" "il remplace net-tools qui n'est plus développé" echo -e "\tip locale(s):\n$ip_local_type" echo -e "\tpasserelle(s):\n$gateway_type" ;; # affiche ip locales --version | -v ) f__info "$GREEN""version script en cours: $version" - fscript_get_version ;; # version du script, en ligne et exécuté - --help | -h | * ) f_help ;; # affichage help + fscript_get_version ;; # version du script, en ligne et exécuté + --help | -h | * ) f_help ;; # affichage help esac done diff --git a/scripts/getIp_changelog b/scripts/getIp_changelog index ca45bf1..f5fb86c 100644 --- a/scripts/getIp_changelog +++ b/scripts/getIp_changelog @@ -1,9 +1,12 @@ # changelog getIp -## 0.7.2 18/08/2017 + + +## 0.7.3 18/08/2017 * maj fscript_cronAnacron pour dev * révision ip locales +* protection absence iproute ## 0.7.1 17/08/2017