getInfo 2.13.0

This commit is contained in:
kyodev 2017-10-22 11:14:21 +02:00
parent cf6a64677b
commit b8c01306a5
2 changed files with 169 additions and 221 deletions

View File

@ -1,14 +1,14 @@
#!/bin/bash
version=2.12.1
date="21/10/2017"
version=2.13.0
date="22/10/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getInfo"
##### license LPRAB/WTFPL
# auteur: simpledeb
# contributeurs: kyodev
# contributeurs: kyodev, saiqui, naguam
#####
# assigne $affichage_text
@ -44,6 +44,18 @@ f__architecture(){ # 08/2017 spécifique
esac
}
# $1=commande à tester, return localisation cmd si existe, return 1 si absent avec aucun message (ala debian)
# pour un test concis genre [ "$(f__cmd_exist $cmd)" ] && echo "$cmd existe"
# utilisation `type -p` pour le test, pour une bonne portabilité
f__cmd_exist(){ # 22/10/2017
# command -v
if type -p "$1" &>/dev/null ; then
echo $(type -p $1)
else
return 1
fi
}
f__color(){ # 08/10/2017
YELLOW=$(tput setaf 3) # question
GREEN=$(tput setaf 2) # ok
@ -125,20 +137,20 @@ f__log(){ # 08/09/2017
# si $2=debOnly et si paquets manquants: return 1 et $debOnlyPackages ( $1=liste paquets )
# si $2=debOnly et si paquets présent: return 0 et $debOnlyPresents ( $1=liste paquets )
# attention priorité $debOnlyPackages sur $debOnlyPresents
f__requis(){ # 17/10/2017
f__requis(){ # 22/10/2017
local dependsMissing packagesMissing command package ireq compteur pluriel
unset debOnlyPackages debOnlyPresents
for ireq in $1; do
command="$(cut -d '>' -f 1 <<< $ireq)"
package="$(cut -d '>' -f 2 <<< $ireq)"
if [ "$2" == "debOnly" ]; then
if [ "$(which dpkg)" ]; then # package only et debian
if [ "$(f__cmd_exist dpkg)" ]; then # package only et debian
LC_ALL=C dpkg --get-selections | grep -qE "^$package[[:space:]]+install" \
&& debOnlyPresents+="$package " || debOnlyPackages+="$package "
else
f__error "dpkg n'est pas disponible sur ce système"
fi
elif [ -z "$(which $command)" ]; then
elif [ -z "$(f__cmd_exist $command)" ]; then
dependsMissing+="$command "
packagesMissing+="$package "
fi
@ -191,13 +203,13 @@ f__scandir(){ # 17/10/2017
}
# $1=cmd si $2: nb de tentatives pour s'identifier, sinon 2 tentatives par défaut
f__sudo(){ # 19/10/2017
f__sudo(){ # 22/10/2017
local nb=2 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 "
sudo="sudo su --shell $(f__cmd_exist bash) --preserve-environment -c "
else
sudo="su --shell $(which bash) --preserve-environment -c "
sudo="su --shell $(f__cmd_exist bash) --preserve-environment -c "
fi
[ "$2" ] && nb="$2"
for (( isudo=1 ; isudo<="$nb" ; isudo++ )); do
@ -293,7 +305,8 @@ f__wget_test(){ # 17/10/2017
exit 0
}
# $1 variable à afficher, $2=var|cmd|sans (type titrage) [$3 titrage] [$4 commentaire titrage dans cmd]
# f_display: $1 variable à afficher, $2=var|cmd|sans (type titrage) [$3 titrage] [$4 commentaire titrage dans cmd]
# f_display "variable" "type" "titrage" "titrage_commentaire"
f_display(){ # 21/10/2017
[ "$text" ] && echo -e "$text" >> "$fileOutput" # flush avant fonction
unset text
@ -301,7 +314,7 @@ f_display(){ # 21/10/2017
[[ "$2" == "sans" || "$2" == "var" || "$2" == "cmd" ]] || text="erreur script \$2 ($1 $2 $3)"
[ "$2" == "var" ] && text="**$3** \n"
[ "$2" == "cmd" ] && text="\`$3\` \n"
[[ "$2" == "cmd" && "$4" ]] && text="\`$3\` $4 \n"
[[ "$2" == "cmd" && "$4" ]] && text="\`$3\` **$4** \n"
text+='``` \n'
text+="${!1} \n"
text+='``` \n\n'
@ -359,27 +372,30 @@ EOF
echo -e "$STD\n plus d'infos: $GREEN$urlNotice\n$STD"
}
fi_batt(){ #v2 21/10/2017
fi_batt(){ # 22/10/2017
local pluriel
[ "$fget_batt_nb" ] || figet_batt # appel figet_battery si pas déjà fait par fi_systeme
[[ "$fget_batt_nb" == "-1" || "$fget_batt_nb" -gt 0 ]] || return 0
text="## batterie(s) \n\n"
[ "$fget_batt_nb" -gt 1 ] && pluriel="s" || unset pluriel
text="## batterie$pluriel \n\n"
f_display "fget_batt" "sans"
}
fi_cpu(){ #v2 21/10/2017
fi_cpu(){ # 22/10/2017
#manuellement: lscpu (util-linux)
local cpu_flags text
local cpu_flags text pluriel
cpu_flags="$(sed -n 's/^flags.*: \(.*\)$/\1/p;' /proc/cpuinfo | sed -n '1p')"
[ "$fget_cpu" ] || figet_cpu
###
text="## processeur \n\n"
[ ${fget_cpu:0:1} -gt 1 ] && pluriel="s" || unset pluriel
text="## processeur$pluriel \n\n"
f_display "fget_cpu" "sans"
f_display "cpu_flags" "var" "flags cpu:"
}
fi_disk(){ #v2 21/10/2017
fi_disk(){ # 22/10/2017
local disk_lsblk disk_df disk_df_i fstab resume idResume idSwap alert_uuidResume text pluriel
local dd_temp dd_temp_alert dd_temp idisk tempodd
local dd_temp dd_temp_alert dd_temp idisk tempodd
disk_lsblk="$(lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID)"
disk_df="$(df -h --output=source,target,fstype,size,used,avail,pcent --exclude=tmpfs --exclude=devtmpfs | grep -Ev 'devpts|none|proc|sys|tmpfs|udev')"
disk_df_i="$(df -i --exclude=tmpfs --exclude=devtmpfs | grep -Ev 'devpts|none|proc|sys|tmpfs|udev')"
@ -400,7 +416,7 @@ fi_disk(){ #v2 21/10/2017
alert_uuidResume+="vous pouvez utiliser _RESUME=auto_ ou _RESUME=/dev/sdx_, voir supprimer ce fichier"
fi
[ "$fget_nb_disk" ] || figet_disk # appel figet_disk si pas déjà fait par fi_systeme
if [ "$(which hddtemp)" ]; then
if [ "$(f__cmd_exist hddtemp)" ]; then
unset dd_temp dd_temp_alert
for idisk in $fget_disk_fixe; do
[ -r "/dev/$idisk" ] || continue
@ -412,8 +428,8 @@ fi_disk(){ #v2 21/10/2017
dd_temp_alert=${dd_temp_alert::-1} # suppression dernier $'\n'
fi
###
# f_display "variable(sans $)" "type=var|cmd|sans" "titrage" "comment_titrage"
text="## disque(s) \n\n"
[ "$fget_nb_disk" -gt 1 ] && pluriel="s" || unset pluriel
text="## disque$pluriel \n\n"
text+='``` \n'
# espace des partitions fixes montées
text+="$fget_disk_part_fix_tot \n\n"
@ -465,7 +481,7 @@ fi_disk(){ #v2 21/10/2017
echo -e "$text" >> "$fileOutput"
}
fi_dmesg(){ #v2 21/10/2017
fi_dmesg(){ # 22/10/2017
local dmesg_err dmesg_warn dmesg_crit file text nb_lignes=25
file="/tmp/$$-$RANDOM-dmesg"
[ "$EUID" -eq 0 ] || echo
@ -496,17 +512,16 @@ fi_dmesg(){ #v2 21/10/2017
rm "$file-"*
###
text="## dmesg kernel (emergency, alerte, erreur, warning ou critique) \n\n"
# f_display "variable(sans $)" "type=var|cmd|sans" "titrage" "comment_titrage"
f_display "dmesg_emerg" "cmd" "dmesg -l emerg" "(**emergency**, $nb_lignes premières lignes)"
f_display "dmesg_alert" "cmd" "dmesg -l alert" "(**alerte**, $nb_lignes premières lignes)"
f_display "dmesg_crit" "cmd" "dmesg -l crit" "(**critique**, $nb_lignes premières lignes)"
f_display "dmesg_err" "cmd" "dmesg -l err" "(**erreur**, $nb_lignes premières lignes)"
f_display "dmesg_warn" "cmd" "dmesg -l warn" "(**warning**, $nb_lignes premières lignes)"
f_display "dmesg_emerg" "cmd" "dmesg -l emerg" "(emergency, $nb_lignes premières lignes)"
f_display "dmesg_alert" "cmd" "dmesg -l alert" "(alerte, $nb_lignes premières lignes)"
f_display "dmesg_crit" "cmd" "dmesg -l crit" "(critique, $nb_lignes premières lignes)"
f_display "dmesg_err" "cmd" "dmesg -l err" "(erreur, $nb_lignes premières lignes)"
f_display "dmesg_warn" "cmd" "dmesg -l warn" "(warning, $nb_lignes premières lignes)"
text+="**les $nb_lignes premières lignes commencent à la date la plus ancienne encore dans les logs kernel** \n\n"
echo -e "$text" >> "$fileOutput"
}
fi_graph(){ #v2 21/10/2017
fi_graph(){ # 22/10/2017
local slotGraphCards graphCards openGl resolutions logXorg modules text
# graphCards="$(lspci -nnk | grep -iEA 3 'vga|display|3d')"
# graphCards="$(lspci -nnv | grep -iEA 13 '^[0-9]+.*vga|display|3d')"
@ -516,7 +531,7 @@ fi_graph(){ #v2 21/10/2017
done
unset ig
graphCards=${graphCards::-1} # suppression dernier $'\n'
[ "$(which glxinfo)" ] && openGl="$(glxinfo | grep 'OpenGL version')"
[ "$(f__cmd_exist glxinfo)" ] && openGl="$(glxinfo | grep 'OpenGL version')"
resolutions="$(xrandr --query | grep '^ *[0-9]' | head -n 10)"
modules="$(lsmod | grep -iE 'amdgpu|ati|i915|nouveau|nvidia|radeon|video|gma')"
[ "$fget_resolution" ] || figet_gpu
@ -537,16 +552,16 @@ fi_graph(){ #v2 21/10/2017
f_display "modules" "sans"
}
fi_hw(){ #v2 21/10/2017
fi_hw(){ # 21/10/2017
figet_hw
text="## hardware monitor ACPI \n\n"
f_display "fget_hw" "sans"
}
fi_journal(){ #v2 21/10/2017
fi_journal(){ # 22/10/2017
local jctl_alert_k jctl_crit_k jctl_err_k jctl_warn_k file text nb_lignes=25
local jctl_warn_nok
[ -x "$(which journalctl)" ] || fi_dmesg # pas systemd, appel dmesg
[ "$(f__cmd_exist journalctl)" ] || fi_dmesg # pas systemd, appel dmesg
file="/tmp/$$-$RANDOM-journalctl"
[ "$EUID" -eq 0 ] || echo
f__sudo "LC_ALL=C journalctl --no-hostname --boot 0 -k -p 1 > $file-alert ; \
@ -578,34 +593,33 @@ fi_journal(){ #v2 21/10/2017
###
# kernel
text="## journalctl kernel (emergency, alert, erreur, warning ou critique) \n\n"
# f_display "variable(sans $)" "type=var|cmd|sans" "titrage" "comment_titrage"
f_display "jctl_alert_k" "cmd" "journalctl --no-hostname --boot 0 -k -p 1" \
"(**kernel emergency 0 & alerte 1**, $nb_lignes premières lignes)"
"(kernel emergency 0 & alerte 1, $nb_lignes premières lignes)"
f_display "jctl_crit_k" "cmd" "journalctl --no-hostname --boot 0 -k -p 2..2" \
"(**kernel critique**, $nb_lignes premières lignes)"
"(kernel critique, $nb_lignes premières lignes)"
f_display "jctl_err_k" "cmd" "journalctl --no-hostname --boot 0 -k -p 3..3" \
"(**kernel erreur**, $nb_lignes premières lignes)"
"(kernel erreur, $nb_lignes premières lignes)"
f_display "jctl_warn_k" "cmd" "journalctl --no-hostname --boot 0 -k -p 4..4" \
"(**kernel warning**, $nb_lignes premières lignes)"
"(kernel warning, $nb_lignes premières lignes)"
# non kernel
text+="## journalctl hors kernel (emergency, alert, erreur, warning ou critique) \n\n"
f_display "jctl_alert_nok" "cmd" "journalctl --no-hostname --boot 0 -p 1 | grep -v kernel:" \
"(**hors kernel emergency 0 & alerte 1**, $nb_lignes premières lignes)"
"(hors kernel emergency 0 & alerte 1, $nb_lignes premières lignes)"
f_display "jctl_crit_nok" "cmd" "journalctl --no-hostname --boot 0 -p 2..2 | grep -v kernel:" \
"(**hors kernel critique**, $nb_lignes premières lignes)"
"(hors kernel critique, $nb_lignes premières lignes)"
f_display "jctl_err_nok" "cmd" "journalctl --no-hostname --boot 0 -p 3..3 | grep -v kernel:" \
"(**hors kernel erreur**, $nb_lignes premières lignes)"
"(hors kernel erreur, $nb_lignes premières lignes)"
f_display "jctl_warn_nok" "cmd" "journalctl --no-hostname --boot 0 -p 4..4 | grep -v kernel:" \
"(**hors kernel warning**, $nb_lignes premières lignes)"
"(hors kernel warning, $nb_lignes premières lignes)"
text+="**les $nb_lignes premières lignes commencent à la date du dernier boot** \n\n"
echo -e "$text" >> "$fileOutput"
}
fi_locale(){ # 11/10/2017
fi_locale(){ # 22/10/2017
local locale timezone keymap keyboard timedatectl alert_Rtc alert_Rtc_info alert_NTP alert_Ntp_info text
locale="$(grep -Ev '#|^$' /etc/default/locale)"
timezone="$(< /etc/timezone)"
if [ "$(which timedatectl)" ]; then
if [ "$(f__cmd_exist timedatectl)" ]; then
timedatectl="$(timedatectl status --no-pager)"
grep -q 'RTC in local TZ: yes' <<< "$timedatectl" && alert_Rtc="Attention RTC in local TZ"
alert_Rtc_info="**Lhorloge système doit être en UTC** pour que les applications de date et heure fonctionnent
@ -647,7 +661,7 @@ et/ou installer le démon Ntp: apt install ntp \n"
echo -e "$text" >> "$fileOutput"
}
fi_log_xorg(){ #v2 21/10/2017
fi_log_xorg(){ # 21/10/2017
local logXorg xfile extract text nb_lignes=50
# Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice,
# (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown (WW) warning, (EE) erreur
@ -671,13 +685,12 @@ fi_log_xorg(){ #v2 21/10/2017
logXorg="${logXorg::-2}"
###
text="## journaux Xorg \n\n"
# f_display "variable(sans $)" "type=var|cmd|sans" "titrage" "comment_titrage"
f_display "logXorg" "cmd" \
"grep -Es '\(WW\)|\(EE\)|\(\?\?\)' /var/log/Xorg.?.log /home/<user>/.local/share/xorg/Xorg.?.log" \
"(Xorg.log)"
}
fi_mem(){ #v2 21/10/2017
fi_mem(){ # 21/10/2017
local swappiness text tempo
swappiness="$(cat /proc/sys/vm/swappiness 2>/dev/null)"
figet_mem "mem" #options possibles mem swap total notitle nocoltitle
@ -690,65 +703,51 @@ fi_mem(){ #v2 21/10/2017
f_display "tempo" "sans"
}
fi_nm(){ # 11/10/2017
[ -x "$(which nmcli)" ] || return 0 # nécessite root sur autre que debian?
fi_nm(){ # 22/10/2017
[ "$(f__cmd_exist nmcli)" ] || return 0 # nécessite root sur autre que debian?
local nm_etat nm_conf text
nm_etat="$(grep -Ev '#|^$' /var/lib/NetworkManager/NetworkManager.state)"
nm_conf="$(grep -Ev '#|^$' /etc/NetworkManager/NetworkManager.conf)"
###
text="## Network Manager \n\n"
text+='`'"grep -Ev '#|^$' /var/lib/NetworkManager/NetworkManager.state"'` \n'
text+='```\n'
text+="$nm_etat \n"
text+='```\n\n'
text+='`'"grep -Ev '#|^$' /etc/NetworkManager/NetworkManager.conf"'` \n'
text+='```\n'
text+="$nm_conf \n"
text+='```\n\n'
echo -e "$text" >> "$fileOutput"
f_display "nm_etat" "cmd" "grep -Ev '#|^$' /var/lib/NetworkManager/NetworkManager.state"
f_display "nm_conf" "cmd" "grep -Ev '#|^$' /etc/NetworkManager/NetworkManager.conf"
}
fi_nm_wifis(){ # 09/10/2017
[ -x "$(which nmcli)" ] || return 0
fi_nm_wifis(){ # 22/10/2017
[ "$(f__cmd_exist nmcli)" ] || return 0
local nm_wifis nm_connected text
nm_wifis="$(nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list)"
nm_connected="$(LC_ALL=C nmcli -f SSID,ACTIVE,IN-USE device wifi list | gawk '/yes[[:space:]]+\*/ {print $1}')"
###
text="## wifis à proximité \n\n"
text+='`'"nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list"'` \n'
text+='```\n'
text+="$nm_wifis \n"
text+='```\n'
echo -e "$text" >> "$fileOutput"
f_display "nm_wifis" "cmd" "nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list"
}
fi_nonFree(){ # 25/09/2017
local vrmsOut text
if [ "$(which vrms)" ]; then
vrmsOut="$(vrms)"
fi_nonFree(){ # 22/09/2017
local vrms text tempo tempo1 tempo2 pluriel
if [ "$(f__cmd_exist vrms)" ]; then
vrms="$(vrms)"
else
vrmsOut="les paquets non-free ou contrib ne peuvent être détectés sans l'installation de vrms"
vrms="les paquets non-free ou contrib ne peuvent être détectés sans l'installation de vrms"
fi
###
text="## Paquets non-libres \n\n"
if [ "$(which vrms)" ]; then
text+='`vrms` \n'
text+='```\n'
fi
text+="$vrmsOut \n"
[ "$(which vrms)" ] && text+='```\n'
echo -e "$text" >> "$fileOutput"
tempo1=$(grep -o '.*non-free packages' <<< "$vrms" | xargs)
tempo2=$(grep -o '.*contrib packages' <<< "$vrms" | xargs)
tempo=$(( ${tempo1:0:1} + ${tempo2:0:1} ))
[[ "$tempo1" && "$tempo" -gt 1 ]] && pluriel="s" || unset pluriel
text="## paquet$pluriel non-libre$pluriel \n\n"
f_display "vrms" "cmd" "vrms"
}
fi_reseau(){ # 19/10/2017
local slotNetCards netCards ip_a iwconfig interfaces route resolv liste_canaux_wifi inet text
fi_reseau(){ # 22/10/2017
local slotNetCards netCards ip_a iwconfig interfaces route resolv liste_canaux_wifi ifx text pluriel
# netCards="$(lspci -nnk | grep -iEA 5 'network|ethernet')"
# netCards="$(lspci -nnv | grep -iEA 15 'network|ethernet')"
slotNetCards="$(lspci | grep -iE 'network|ethernet' | sed -En 's/^([0-9.:]+).*$/\1/gp')"
for in in $slotNetCards; do
netCards+="$(lspci -s $in -nnv)"$'\n'
for ifx in $slotNetCards; do
netCards+="$(lspci -s $ifx -nnv)"$'\n'
done
unset in
netCards=${netCards::-1} # suppression dernier $'\n'
ip_a="$(ip a | sed '/link\/ether/d; /valid_lft/d')" # filtre sur adr MAC & bail
# ip_a="$(sed '/inet6.*scope global/d; /inet6.*scope link/d' <<< $ip_a)" # filtre sur inet6 scope global & scope link (fe80::)
@ -757,94 +756,68 @@ fi_reseau(){ # 19/10/2017
interfaces="$(grep -Evrs '#|^$' /etc/network/interfaces*)"
interfaces="$(sed -E 's/wpa-psk [[:graph:]]+/wpa-psk <WPA key removed>/; s/:/: /' <<< $interfaces )"
resolv="$(grep -Ev '#|^$' /etc/resolv.conf)"
if [ "$(which iwlist)" ]; then #paquet wireless-tools requis
if [ "$(f__cmd_exist iwlist)" ]; then #paquet wireless-tools requis
iwconfig="$(iwconfig 2>&1 | grep -v 'no wireless extensions' | grep -v '^$')"
fi
if [ "$(which iwlist)" ]; then # liste canaux wifi; paquet wireless-tools requis
if [ "$(f__cmd_exist iwlist)" ]; then # liste canaux wifi; paquet wireless-tools requis
liste_canaux_wifi="$(iwlist chan 2>&1 | grep -Ev 'no frequency information|^$')"
fi
netmgrpaths=("/usr/sbin/NetworkManager" "/usr/sbin/wicd" "/usr/sbin/connmand") # thanks wireless-info
netmgrnames=("NetworkManager" "Wicd" "ConnMan") # thanks wireless-info
for inet in "${!netmgrpaths[@]}"; do
if [ -f "${netmgrpaths[$inet]}" ]; then netmgrinst+="${netmgrnames[$inet]}"; fi
if [ "$(ps -ef | grep -c ${netmgrpaths[$inet]})" -ge 2 ]; then
netmgrrun+="$(ps -ef | grep -o "${netmgrpaths[$inet]}.*$" | head -n 1)"
netmgrpaths=("/usr/sbin/NetworkManager" "/usr/sbin/wicd" "/usr/sbin/connmand")
netmgrnames=("NetworkManager" "Wicd" "ConnMan")
for ifx in "${!netmgrpaths[@]}"; do
if [ -f "${netmgrpaths[$ifx]}" ]; then netmgrinst+="${netmgrnames[$ifx]}"; fi
if [ "$(ps -ef | grep -c ${netmgrpaths[$ifx]})" -ge 2 ]; then
netmgrrun+="$(ps -ef | grep -o "${netmgrpaths[$ifx]}.*$" | head -n 1)"
fi
done
figet_ip
figet_mod_net
###
text="## réseau \n\n"
text+='`'"lspci -nnv | grep -iEA 15 'network|ethernet"'` \n'
text+='```\n'
text+="$netCards \n"
text+='```\n\n'
text+="**IP locale(s):** \n"
text+='```\n'
text+="$ip_local_type \n"
text+='```\n\n'
text="## réseau \n\n"
f_display "netCards" "cmd" "lspci -nnv | grep -iEA 15 'network|ethernet"
f_display "ip_local_type" "var" "IP locale(s):"
text+="* les adresses Mac peut être affichées avec "'`./getInfo --mac` ou `getInfo --mac`'" (script installé) \n"
text+="* l'IP publique peut être connue avec: "'`./getInfo --ip` ou `getInfo --ip` (script installé) \n\n'
if grep -q 'wlx' <<< "$ifnames"; then
text+="**Attention:** une interface wifi est en erreur: $(grep -o 'wlx' <<< $ifnames) \n"
text+="l'interface n'est pas reconnue et est donc mal nommée \n"
text+="au pire, changer le renommage: https://kyodev.frama.io/kyopages/trucs/interfaces-nommage-classique/ \n\n"
text+="**Attention:** une interface wifi est en erreur: $(grep -o 'wlx' <<< $ifnames) \n"
text+="l'interface n'est pas reconnue et est donc mal nommée \n"
text+="au pire, changer le renommage: "
text+="https://kyodev.frama.io/kyopages/trucs/interfaces-nommage-classique/ \n\n"
fi
text+="**Passerelle(s):** \n"
text+='```\n'
text+="$gateways \n"
text+='```\n\n'
f_display "gateways" "var" "Passerelle(s):"
if [ "$(wc -w <<< $ifnames)" -gt 1 ]; then # si plus d'une interface réseau
text+="**interface prioritaire** \n"
text+='```\n'
text+="$if_prioritaire \n"
text+='```\n\n'
f_display "if_prioritaire" "var" "interface prioritaire"
fi
text+='`ip address`'" (sans ipV6 et sans adresses MAC) \n"
text+='```\n'
text+="$ip_a \n"
text+='```\n\n'
text+='`ip route show` \n'
text+='```\n'
text+="$route \n"
text+='```\n\n'
text+='`'"grep -Evrs '#|^$' /etc/network/interfaces*"'` \n'
text+='```\n'
text+="$interfaces \n"
text+='```\n\n'
text+='`cat /etc/resolv.conf` (serveurs de noms DNS utilisés) \n'
text+='```\n'
text+="$resolv \n"
text+='```\n\n'
f_display "ip_a" "cmd" "ip address" "(sans ipV6 et sans adresses MAC)"
f_display "route" "cmd" "ip route show"
f_display "interfaces" "cmd" "grep -Evrs '#|^$' /etc/network/interfaces*"
f_display "resolv" "cmd" "cat /etc/resolv.conf" "(serveurs de noms DNS utilisés)"
if [ "$iwconfig" ]; then
text+='`iwconfig` \n'
text+='```\n'
text+="$iwconfig \n"
text+='```\n\n'
f_display "iwconfig" "cmd" "iwconfig"
fi
if [ "$liste_canaux_wifi" ]; then
text+='`iwlist chan` \n'
text+='```\n'
text+="$liste_canaux_wifi \n"
text+='```\n\n'
text+="* la configuration ssid utilisé peut être connue (si NetworkManager utilisé) avec "'`./getInfo --ssid` ou `getInfo --ssid`'" (script installé) \n\n"
f_display "liste_canaux_wifi" "cmd" "iwlist chan"
text+="* la configuration ssid utilisé peut être connue (si NetworkManager utilisé) avec "
text+="\`./getInfo --ssid\` ou \n \`getInfo --ssid\` (script installé) \n\n"
fi
if [ "$netmgrinst" ]; then
text+="### network managers \n\n"
[ "$netmgrinst" ] && text+="installé(s): **$netmgrinst** \n" || text+="non trouvé parmi: ${netmgrnames[@]} \n"
text+="### gestionnaire de réseau \n\n"
if [ "$netmgrinst" ]; then
[ "$(wc -w <<< $netmgrinst)" -gt 1 ] && pluriel="s" || unset pluriel
text+="installé$pluriel: **$netmgrinst** \n"
else
[ "$(wc -w <<< $netmgrnames[@])" -gt 1 ] && pluriel="s" || unset pluriel
text+="non trouvé$pluriel parmi: ${netmgrnames[@]} \n"
fi
text+="en fonctionnement: "
[ "$netmgrrun" ] && text+="**$netmgrrun** \n\n" || text+="non \n\n"
[ "$netmgrrun" ] && text+="**$netmgrrun** \n\n" || text+="aucun \n\n"
fi
figet_mod_net
text+="### modules réseau \n\n"
text+="liste non garantie complète \n"
text+='```\n'
text+="$fget_mod_net \n"
text+='```\n\n'
echo -e "$text" >> "$fileOutput"
text+="### modules réseau \n\n"
f_display "fget_mod_net" "var" "liste non garantie complète"
}
fi_sources(){ # 13/10/2017
[ "$(which dpkg)" ] || return 0
fi_sources(){ # 22/10/2017
[ "$(f__cmd_exist dpkg)" ] || return 0
local sources dateMaj nb_packages apt text pluriel
local alert_autoremove alert_nbAutoremove alert_paquetToRemove alert_httpredir alert_httpredir_text
local alert_upgradable alert_upgradable_text alert_nbUpgradable
@ -859,8 +832,8 @@ fi_sources(){ # 13/10/2017
alert_nbAutoremove="$(grep -c 'Remv' <<< $apt)"
if [ "$alert_nbAutoremove" -ne 0 ]; then
[ "$alert_nbAutoremove" -gt 1 ] && pluriel="s" || unset pluriel
alert_autoremove="**$alert_nbAutoremove paquet$pluriel installé$pluriel inutile$pluriel**, "
alert_autoremove+="vous pouvez utiliser "'`apt autoremove`'
alert_autoremove="$alert_nbAutoremove paquet$pluriel installé$pluriel inutile$pluriel, "
alert_autoremove+="vous pouvez utiliser: \`apt autoremove\`"
alert_paquetToRemove="$(sed -En 's/Remv (.*)\[[0-9.-]*\]/\1/p' <<< $apt | tr '\n' ' ')"
fi
printf "."
@ -872,14 +845,16 @@ fi_sources(){ # 13/10/2017
alert_upgradable="$(LC_ALL=C apt list --upgradable 2>/dev/null | sed '1d')"
if [ "$alert_upgradable" ]; then
alert_nbUpgradable="$(grep -c '.' <<< "$alert_upgradable")"
alert_upgradable_text="**$alert_nbUpgradable paquets devraient être mis à jour:** \n"
[ "$alert_nbUpgradable" -gt 1 ] && pluriel="s" || unset pluriel
alert_upgradable_text="$alert_nbUpgradable paquet$pluriel à mettre à jour, "
alert_upgradable_text+='`apt list --upgradable`:'
fi
printf "."
alert_paquetBiz="$(dpkg -l | gawk 'FNR>5 && ! /^i/ {print $1, $2, $3}')"
if [ "$alert_paquetBiz" ]; then
[ "$(grep -c '.' <<< "$alert_paquetBiz")" -gt 1 ] && pluriel="s" || unset pluriel
alert_paquetBiz_text0="$(grep -c '.' <<< "**$alert_paquetBiz") paquet$pluriel dans un état non installé**"
alert_paquetBiz_text0="$(grep -c '.' <<< \
"$alert_paquetBiz") paquet$pluriel dans un état non installé"
[[ ${alert_paquetBiz,,} =~ ^. ]] && alert_paquetBiz_text="* **État souhaité** "$'\n'
[[ ${alert_paquetBiz,,} =~ ^h ]] && alert_paquetBiz_text+=" * **h**old (à garder) "$'\n'
[[ ${alert_paquetBiz,,} =~ ^i ]] && alert_paquetBiz_text+=" * **i**nstall (à installer) "$'\n'
@ -899,43 +874,21 @@ fi_sources(){ # 13/10/2017
alert_paquetBiz_text=${alert_paquetBiz_text::-1} # suppression dernier $'\n'
fi
###
text="## sources list \n\n"
text+='`'"grep -Evrs '^#|^$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list"'` \n'
text+='```\n'
text+="$sources \n"
text+='```\n\n'
text="## sources liste \n\n"
f_display "sources" "cmd" "grep -Evrs '^#|^$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list"
text+="nombre de paquets installés: **$nb_packages** \n\n"
text+="dernière mise à jour apt: **$dateMaj** \n\n"
if [ "$alert_autoremove" ] ; then
text+="$alert_autoremove \n"
text+='```\n'
text+="$alert_paquetToRemove \n"
text+='```\n\n'
fi
if [ "$alert_httpredir" ]; then
text+="$alert_httpredir_text \n"
text+='```\n'
text+="$alert_httpredir \n"
text+='```\n\n'
fi
if [ "$alert_upgradable" ]; then
text+="$alert_upgradable_text \n"
text+='```\n'
text+="$alert_upgradable \n"
text+='```\n\n'
fi
[ "$alert_autoremove" ] && f_display "alert_paquetToRemove" "var" "$alert_autoremove"
[ "$alert_httpredir" ] && f_display "alert_httpredir" "var" "$alert_httpredir_text"
[ "$alert_upgradable" ] && f_display "alert_upgradable" "var" "$alert_upgradable_text"
if [ "$alert_paquetBiz" ]; then
text+="$alert_paquetBiz_text0 \n"
text+='```\n'
text+="$alert_paquetBiz \n"
text+='```\n\n'
f_display "alert_paquetBiz" "var" "$alert_paquetBiz_text0"
text+="$alert_paquetBiz_text"' \n\n'
fi
echo -e "$text" >> "$fileOutput"
}
fi_ssid(){ # 11/10/2017
[ "$(which nmcli)" ] || f__error "il manque NetworkManager"
fi_ssid(){ # 22/10/2017
[ "$(f__cmd_exist nmcli)" ] || f__error "il manque NetworkManager"
local nm_ssid file="/tmp/$$-$RANDOM-fi_ssid" text
# nm_ssid="$(grep -Ev '#|^$' /etc/NetworkManager/system-connections/*)"
[ "$EUID" -eq 0 ] || echo
@ -958,23 +911,19 @@ fi_ssid(){ # 11/10/2017
echo -e "$text"
}
fi_system_analyse(){ # 25/09/2017
[ -x "$(which systemd-analyze)" ] || return 0 # pas systemd
fi_system_analyse(){ # 22/10/2017
[ "$(f__cmd_exist systemd-analyze)" ] || return 0 # pas systemd
local bootTime bootBlame text
bootTime="$(systemd-analyze time)"
bootBlame="$(systemd-analyze blame | head -n 20)"
###
text="## analyse boot \n\n"
text+="$(sed 's/Startup finished in /**durée de boot:** /; s/userspace/espace utilisateur/; s/= \(.*\)$/= **\1**/' <<< $bootTime) \n\n"
text+='`systemd-analyze blame | head -n 20` \n'
text+='```\n'
text+="$bootBlame \n"
text+='```\n\n'
echo -e "$text" >> "$fileOutput"
f_display "bootBlame" "cmd" "systemd-analyze blame | head -n 20"
}
fi_systeme(){ # 21/10/2017
local mbr description uname bootImage xorg shells lastboot uptime pluriel charge text
fi_systeme(){ # 22/10/2017
local mbr description uname bootImage initDaemon xorg shells lastboot uptime charge pluriel text
[ -d /sys/firmware/efi ] && mbr="**EFI**" || mbr="**Legacy (mbr)**"
[ -x "/usr/bin/lsb_release" ] && description="$(lsb_release -ds)" #dépend de apt install lsb-release, sur debian, en standard, juste : lsb-base
uname="$(uname -rmo)"
@ -990,8 +939,6 @@ fi_systeme(){ # 21/10/2017
lastboot="$(date -r /var/run/utmp '+%d/%m/%Y %H:%M %z')"
uptime="$(uptime -p | sed 's/up/depuis/; s/week/semaine/; s/weeks/semaines/; s/days/jours/; s/day/jour/; s/hour[s]*/h/; s/minute[s]*/mn/')"
charge="$(uptime | sed -En 's/.*load average: (.*), (.*), (.*)/\1 \2 \3/; s/,/./gp')"
cores="$(sort -u /proc/cpuinfo | grep -c '^core id')"
thread="$(grep -c "^processor" /proc/cpuinfo)"
figet_batt
figet_cpu
figet_de
@ -1037,25 +984,18 @@ fi_systeme(){ # 21/10/2017
echo -e "$text" >> "$fileOutput"
}
fi_usb(){ # 25/09/2017
fi_usb(){ # 22/10/2017
local lsusb lsusb_t text
lsusb="$(lsusb)"
lsusb_t="$(lsusb -t)"
###
text="## périphériques USB \n\n"
text+='`lsusb` \n'
text+='```\n'
text+="$lsusb \n"
text+='```\n\n'
text+='`lsusb -t` \n'
text+='```\n'
text+="$lsusb_t \n"
text+='```\n\n'
echo -e "$text" >> "$fileOutput"
text="## USB \n\n"
f_display "lsusb" "cmd" "lsusb"
f_display "lsusb_t" "cmd" "lsusb -t"
}
# informations batterie(s), assigne $fget_batt_nb $fget_batt
figet_batt(){ #v2 17/10/2017
figet_batt(){ #v2 22/10/2017
local batt_detail batt_nb batt_alim batt_unit batt_capa_design batt_capa_full batt_capa_now batt_conso
local batt_volt_min batt_volt_now batt_status batt_cycle batt_sn alert_batt_alarm
local batt_sante batt_restant tempo batRep ibat uevent
@ -1095,7 +1035,7 @@ figet_batt(){ #v2 17/10/2017
batt_volt_now="$(gawk -F '=' '/POWER_SUPPLY_VOLTAGE_NOW=/ {printf "%.2f", $2/1000000}' <<< $uevent)" # V
batt_status="$(gawk -F '=' '/POWER_SUPPLY_STATUS=/ {print $2}' <<< $uevent)"
batt_cycle="$(gawk -F '=' '/POWER_SUPPLY_CYCLE_COUNT=/ {print $2}' <<< $uevent)"
batt_sn="$(gawk -F '=' '/POWER_SUPPLY_SERIAL_NUMBER=/ {print $2}' <<< $uevent)"
batt_sn="$(gawk -F '=' '/POWER_SUPPLY_SERIAL_NUMBER=/ {sub(/^ | $/,"",$2); print $2}' <<< $uevent)"
alert_batt_alarm="$(cat $batRep/$ibat/alarm 2>/dev/null)"
[ "$alert_batt_alarm" == "0" ] && unset alert_batt_alarm || alert_batt_alarm="$ibat: $alert_batt_alarm"
# calculs
@ -1422,9 +1362,9 @@ figet_hw(){ #v2 20/10/2017
# assigne $ip_local, $gateways, $gateways_type, $gateway, $gateway_type, $if_prioritaire
# $ip_local, $ip_local_type, $ifnames, $ifnames_type, $mac_address, mac_address_type
figet_ip(){ # 16/10/2017
figet_ip(){ # 22/10/2017
local ifn
[ -z "$(which ip)" ] && return 1
[ "$(f__cmd_exist ip)" ] || return 1
ip_local="$(sed '/[[:digit:]]:[[:blank:]]lo.*inet/d; /inet6.*scope/d' <<< $(ip -o a) | gawk '{print " ",$4,"(",$2,")"}')"
ip_local_type="$(sed -E 's/(^.*wl.*)/\1 (wifi)/;s/(^.*en.*|^.*eth.*)/\1 (ethernet)/' <<< $ip_local)"
gateways="$(LC_ALL=C ip -4 route | gawk '/default via/ {print " ",$3,"(",$5,")"}')"
@ -1446,7 +1386,7 @@ figet_ip(){ # 16/10/2017
}
# $1=4|6, assigne $ip_public
figet_ip_public(){ # 17/10/2017
figet_ip_public(){ # 22/10/2017
local dig_test ip_test iip
list_ip4(){
ip_test+=" http://whatismyip.akamai.com"
@ -1497,14 +1437,14 @@ figet_ip_public(){ # 17/10/2017
ip_telnet=6.ifcfg.me
fi
if [ "$(which dig)" ] && [ -z "$ip_public" ]; then
if [ "$(f__cmd_exist dig)" ] && [ -z "$ip_public" ]; then
for iip in $dig_test ; do
ip_public="$(dig +short $(sed 's;/; ;g' <<< $iip))"
[ "$ip_public" ] && break
done
fi
if [ "$(which wget)" ] && [ -z "$ip_public" ]; then
if [ "$(f__cmd_exist wget)" ] && [ -z "$ip_public" ]; then
cmd="wget --quiet --timeout=5 -O - "
for iip in $ip_test ; do
ip_public="$($cmd $iip)"
@ -1512,7 +1452,7 @@ figet_ip_public(){ # 17/10/2017
done
fi
if [ "$(which curl)" ] && [ -z "$ip_public" ]; then
if [ "$(f__cmd_exist curl)" ] && [ -z "$ip_public" ]; then
cmd="curl --silent --location --retry 0 --max-time 5" #--location pour aider redirections
for iip in $ip_test ; do
ip_public="$($cmd $iip)"
@ -1520,11 +1460,11 @@ figet_ip_public(){ # 17/10/2017
done
fi
if [ "$(which telnet)" ] && [ -z "$ip_public" ]; then
if [ "$(f__cmd_exist telnet)" ] && [ -z "$ip_public" ]; then
ip_public="$(telnet $ip_telnet 23 2>/dev/null | grep $1 | cut -d ' ' -f 4)"
fi
if [ "$(which nc)" ] && [ -z "$ip_public" ] && [ "$1" != "IPv6" ]; then
if [ "$(f__cmd_exist nc)" ] && [ -z "$ip_public" ] && [ "$1" != "IPv6" ]; then
ip_public="$(nc $ip_telnet 23 2>/dev/null | grep $1 | cut -d ' ' -f 4)"
fi
@ -1644,7 +1584,7 @@ figet_shell(){ # thanks neofetch, assigne $fget_shell # 04/10/2017
fget_shell="$shell"
}
figet_test_batt(){ # 21/10/2017
figet_test_batt(){ # 22/10/2017
local text var_temp
# matériel
figet_dmi
@ -1653,7 +1593,7 @@ figet_test_batt(){ # 21/10/2017
###
text+="## batterie test \n\n"
# acpi éventuel
if [ "$(which acpi)" ]; then
if [ "$(f__cmd_exist acpi)" ]; then
var_temp=$(acpi -abi)
f_display "var_temp" "cmd" "acpi -abi"
fi
@ -1676,7 +1616,7 @@ figet_test_dmi(){ # 21/10/2017
f_display "fget_dmi" "var" "figet_dmi"
}
figet_test_hw(){ # 21/10/2017
figet_test_hw(){ # 22/10/2017
local text var_temp
# matériel
figet_dmi
@ -1685,11 +1625,11 @@ figet_test_hw(){ # 21/10/2017
###
text+="## hwmon test \n\n"
# sensors et acpi éventuel
if [ "$(which sensors)" ]; then
if [ "$(f__cmd_exist sensors)" ]; then
var_temp=$(sensors -u)
f_display "var_temp" "cmd" "sensors -u"
fi
if [ "$(which acpi)" ]; then
if [ "$(f__cmd_exist acpi)" ]; then
var_temp=$(acpi -V | grep -E 'Thermal|Cooling')
f_display "var_temp" "cmd" "acpi -V"
fi
@ -2045,7 +1985,7 @@ for j in $options; do
case $j in
-t | --test )
prg_1 "$*"
fi_mem
fi_nonFree
prg_3
exit ;; # test seulement
-c* | all )

View File

@ -5,18 +5,26 @@
* placer ln dans /usr/local/bin au lieu de /usr/bin ?
* réseau réviser, interface name: virbr0
* "alertifier" fi-reseau
* désactiver wifi si pas de carte réseau
* bug fedora: which à supprimer/émuler
* bug fedora: journaux xorg
* bug fedora: identification distrib
* bug fedora: localisation
* bug: acpi, power_supply si vieille tour
* bug ssh: setxkbmap : commande introuvable, Can't open display??
* bug à confirmer? tableau gpu
---
* f__requis f__wget_test fscript_get_version fscript_update fscript_cronAnacron
* f__cmd_exist f__sudo f__requis
## 2.13.0 22/10/2017
* nouveau: f__cmd_exist, émule et remplace which
* bug fedora: which à supprimer/émuler
* révision affichage avec f_display, fin pour tous les fi_
* pluriel sur titrages markdown
## 2.12.1 21/10/2017