getInfo 2.30.0

This commit is contained in:
kyodev 2017-11-10 21:06:23 +01:00
parent c521955148
commit 1585ea597e
2 changed files with 131 additions and 111 deletions

View File

@ -1,6 +1,6 @@
#!/bin/bash
version=2.29.0
version=2.30.0
date="10/11/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
@ -320,7 +320,9 @@ f__wget_test(){ # 06/11/2017
# $1 variable à afficher, $2=var|cmd|sans (type titre) [$3 titre] [$4 commentaire en gras si cmd]
# $2: cmd->`titre`, var->**titre**, sans: pas de titre
# un test si variable $1 est vide ou non est fait
# passage en paramètre variable et pas $variable
# un test si variable $1 est vide est fait
# un test si variable $1 contient 'nofile', non trouvé par f_grep_file
# f_display "variable" "type" "titrage" "titrage_commentaire"
f_display(){ # 10/11/2017
# flush, avant fonction, de text parent
@ -334,13 +336,18 @@ f_display(){ # 10/11/2017
[ "$2" == "cmd" ] && display="\`$3\`" # type cms, titre entre `
[ "$4" ] && display+=$'\xc2\xa0'$'\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0'" ($4)" # +$4 en gras avec 5 espaces insécables avant
[ "$2" == "sans" ] || display+=" \n"
display+='``` \n'
display+="${!1} \n"
display+='``` \n'
if [[ "${!1}" =~ "nofile" ]]; then
display+="\n* fichier $1 non trouvé \n"
else
display+='``` \n'
display+="${!1} \n"
display+='``` \n'
fi
echo -en "$display \n" >> "$fileOutput" # flush fonction
}
# $1 variable à afficher en alerte/info, [$2 alert|info] type de message, alert par défaut
# passage en paramètre variable et pas $variable
# un test si variable $1 est vide ou non est fait
f_dspl_alert(){ # 10/11/2017
# flush, avant fonction, de text parent
@ -349,18 +356,14 @@ f_dspl_alert(){ # 10/11/2017
# coeur fonction
local display type
[ "${!1}" ] || return 0 # test si contenu dans $1
[[ "$2" =~ alert|info ]] && type="$2" || type="alert"
[ "$type" == "alert" ] && display="\n> ❗ ${!1} \n\n"
[ "$type" == "info" ] && display="\n ☛ ${!1} \n\n"
echo -en "$display \n" >> "$fileOutput" # flush fonction
[[ "$2" =~ "info" ]] && type="info"
[[ "$2" =~ alert ]] && type="alert"
[ "$type" == "alert" ] && display="\n> ❗ ${!1} \n"
[ "$type" == "info" ] && display="\n ☛ ${!1} \n"
echo -en "$display \n" >> "$fileOutput" # flush fonction
}
# $1 fichier testé
f_dspl_file_KO(){ # 03/11/2017
echo -e "* fichier **$1** non trouvé ou absent \n" >> "$fileOutput"
}
# epure markdown pour affichage en console, $1 file à parser
# conversion markdown pour affichage en console, $1 file à parser
# tout en bash pour regex par défaut non-greedy (non gourmand) comme sed ou gawk
# contrainte markdown:
# l'italique avec _ ou * n'est pas géré, trop d'interférences potentielles
@ -432,19 +435,24 @@ f_dspl_scandir(){ # 21/10/2017
echo -e "$text" >> "$fileOutput" # flush fonction
}
# $1=liste fichier(s) à greper, [$2]: largeur 1ere colonne | file si un seul fichier
f_grep_file(){ # 07/11/2017
local file var_temp
# $1=liste fichier(s) à grepper, [$2]: largeur 1ere colonne | file si un seul fichier
# si 'file' pas d'énumération de fichier greppé, si aucun fichier retour 'nofile'
f_grep_file(){ # 10/11/2017
local file var_temp display
for file in $1; do
var_temp="$(grep -Ersv '^[[:blank:]]*#|^[[:blank:]]*$' $file)"
[[ "$2" != "file" && "$var_temp" ]] && echo " $file"
if [[ "$2" =~ [0-9] ]]; then
gawk -v "larg=$2" '{printf "%-"larg"s",$1; s1=""; printf "%s\n",$0}' <<< "$var_temp"
[ -d "$file" ] && file+='/' # si répertoire, ajout /
var_temp="${var_temp//$file}" # pour esthétique, suppression de $file dans les noms de fichiers
[[ "$2" != "file" && "$var_temp" ]] && display+=" $file \n" # nom fichier si pas 'file' dans $2
if [[ "$2" =~ [0-9] ]]; then # si $2 contient des chiffres, largeur, gawk
display+=$(gawk -v "larg=$2" '{printf "%-"larg"s",$1; s1=""; printf "%s\n",$0}' <<< "$var_temp")
else
echo "$var_temp"
display+="$var_temp"
fi
echo
display+=$'\n\n'
done
[ "$(xargs <<< $display)" ] || display="nofile" # display vide, inscription 'nofile'
echo -e "$display"
}
f_help(){ # 06/11/2017
@ -478,19 +486,19 @@ EOF
echo -e "$STD\n plus d'infos: $GREEN$urlNotice\n$STD"
}
fi_batt(){ # 25/10/2017
fi_batt(){ # 10/11/2017
local pluriel
[ "$fg_nb_batt" ] || figet_batt
[[ "$fg_nb_batt" == "-1" || "$fg_nb_batt" -gt 0 ]] || return 0 # pas de batterie
###
[ "$fg_nb_batt" -gt 1 ] && pluriel="s" || unset pluriel
text="## batterie$pluriel \n\n"
text="## batterie"$pluriel" \n\n"
f_display "fg_batt" "sans"
printf "$text\n" >> "$fileOutput"
unset text
}
fi_cpu(){ # 07/11/2017
fi_cpu(){ # 10/11/2017
local cpu_flags text iflag var_temp text_flags="" pluriel
cpu_flags=$(sed -n 's/^flags.*: \(.*\)$/\1/p;' /proc/cpuinfo | sed -n '1p'| \
tr ' ' '\n' | sort | tr '\n' ' ' | xargs )
@ -503,11 +511,11 @@ fi_cpu(){ # 07/11/2017
[ "$fg_cpu" ] || figet_cpu
###
[ ${fg_cpu:0:1} -gt 1 ] && pluriel="s" || unset pluriel
text="## processeur$pluriel \n\n"
text="## processeur"$pluriel" \n\n"
f_display "fg_cpu" "cmd" "lscpu" # affichage proc
[ "$fg_uarch" ] && f_display "fg_uarch" "var" "µarchitecture processeur"
[ "$cpu_flags" ] && f_display "cpu_flags" "var" "flags cpu" # flags cpu bruts
[ "$text_flags" ] && f_display "text_flags" "sans" # flags cpu texte
f_display "fg_uarch" "var" "µarchitecture processeur"
f_display "cpu_flags" "var" "flags cpu" # flags cpu bruts
f_display "text_flags" "sans" # flags cpu texte
printf "$text\n" >> "$fileOutput"
unset text
}
@ -772,16 +780,17 @@ SMCA ⟷ Scalable MCA
"
}
fi_disk(){ # 09/11/2017
fi_disk(){ # 10/11/2017
local dd_temp="" disk_df disk_df_i disk_lsblk fstab resume idResume idSwap idisk text pluriel
local alert_dd_temp="" alert_file_resume alert_uuidResume
local alert_dd_temp alert_file_resume alert_uuidResume
# éventuellement hddtemp
if [ "$(f__cmd_exist hddtemp)" ]; then
unset dd_temp alert_dd_temp
for idisk in $fg_disk_fixe; do
[ -r "/dev/$idisk" ] || continue
dd_temp="$(LC_ALL=C hddtemp /dev/$idisk | cut -d ':' -f3 | sed 's/[^0-9]*//g; /not available/d')"
[ "$dd_temp" -ge 50 ] && alert_dd_temp+="$idisk: température > 50°C"$'\n'
if [ "$dd_temp" -ge 50 ]; then
alert_dd_temp+="$idisk: température > 50°C"$'\n'
fi
dd_temp+="$idisk: $dd_temp °C"$'\n'
done
[ "$dd_temp" ] && dd_temp=${dd_temp::-1} # suppression dernier $'\n'
@ -843,7 +852,7 @@ fi_disk(){ # 09/11/2017
text+="| :---: | :---: | :---: | :---: | \n"
text+="| $fg_disk_ata | $fg_disk_usb | $fg_disk_mmc | $fg_disk_nvme | \n\n"
# éventuellement hddtemp
[ "$dd_temp" ] && f_display "dd_temp" "cmd" "hddtemp /dev/sd?" "température disques"
f_display "dd_temp" "cmd" "hddtemp /dev/sd?" "température disques"
f_dspl_alert "alert_dd_temp" "info"
# df, espaces des partitions montées seules
f_display "disk_df" "cmd" \
@ -865,7 +874,7 @@ fi_disk(){ # 09/11/2017
unset text
}
fi_dmesg(){ # 08/11/2017
fi_dmesg(){ # 10/11/2017
local dmesg_err dmesg_warn dmesg_crit file text nb_lignes=25
file="/tmp/$$-$RANDOM-dmesg"
[ "$EUID" -eq 0 ] || echo
@ -907,12 +916,11 @@ fi_dmesg(){ # 08/11/2017
}
fi_graph(){ # 10/11/2017
local slots ig cmd cards glx_dev glx_dev_temp test_3D openGl providers resolutions pluriel modules text
local slots ig cmd cards glx_dev glx_dev_temp openGl providers resolutions pluriel modules text
local alert_hybrid alert_3D
# cardsManuel="$(lspci -nnk | grep -EiA 3 'vga|display|3d')" # -nn: textual and numeric ID's, k kernel
# cardsManuel="$(lspci -nnv | grep -iEA11 'vga|display|3d)" # v=verbose
# cardsManuel="lspci -nnv -s $( lspci | grep -Ei 'vga|display|3d' | cut -d" " -f1 )" si plusieurs devices possibles??
{
[ "$fg_nb_gpu" ] || figet_gpu
[ "$fg_nb_gpu" -eq 0 ] && return 0 # pas de gpu, rien à voir
# bus slots pci video
@ -939,7 +947,7 @@ fi_graph(){ # 10/11/2017
done
fi
cards=${cards::-1} # suppression dernier $'\n'
if [ $(grep -c 'Unknown header type 7f' <<< "$cards") -gt 0 ]; then
if grep -iq 'Unknown header type 7f' <<< "$cards" ; then
alert_hybrid="Une carte graphique semble désactivée actuellement, lspci n'est pas complet. \n"
alert_hybrid+="Voir DRI_PRIME, vga-switcheroo, Bumbledee...?"
fi
@ -947,8 +955,7 @@ fi_graph(){ # 10/11/2017
if [ $(f__cmd_exist glxinfo) ]; then
# devices
glx_dev="$(glxinfo | grep 'Device: ' | xargs)"
test_3D=$( glxinfo | grep -i 'direct rendering' )
if [ "$(grep -i 'no' <<< $test_openGl )" ]; then
if grep -iq 'no' <<< $( glxinfo | grep -i 'direct rendering' ) ; then
alert_3D="l'accélération 3D n'est pas activée"
fi
# openGL
@ -983,7 +990,6 @@ fi_graph(){ # 10/11/2017
modules="$(lsmod | grep -Ei 'amdgpu|ati|i915|nouveau|nvidia|radeon|video|gma')"
# fonctions externes
[ "$fg_resolution" ] || figet_screen
}
###
text="## graphisme \n\n"
[ "$fg_gpu" ] && text+="$(sed -E 's/(.*)/> \* \*\*\1\*\*/' <<< $fg_gpu) \n\n"
@ -1017,11 +1023,11 @@ fi_graph(){ # 10/11/2017
unset text
}
fi_hw(){ # 03/11/2017
fi_hw(){ # 10/11/2017
figet_hw
###
text="## hardware monitor ACPI \n\n"
[ "$fg_hw" ] && f_display "fg_hw" "sans"
f_display "fg_hw" "sans"
[ "$fg_hw" ] || text+="* **pas d'informations détectées** \n\n"
printf "$text\n" >> "$fileOutput"
unset text
@ -1029,12 +1035,12 @@ fi_hw(){ # 03/11/2017
fi_journal(){ # 10/11/2017
local jctl_boot jctl_alert_k jctl_crit_k jctl_err_k jctl_warn_k jctl_warn_nok jctl_size file
local jctl_persist alert_jctl_persist text nb_lignes=25
local alert_jctl_persist text nb_lignes=25
[ "$(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 | head | sed -n '/^-- Logs begin.*$/p' > $file-boot ; \
LC_ALL=C journalctl --no-hostname --boot -1 2>/dev/null 1> $file-persistant ; \
LC_ALL=C journalctl --no-hostname --boot -1 &>$file-persistant ; \
LC_ALL=C journalctl --no-hostname --boot 0 -k -p 1 > $file-alert ; \
LC_ALL=C journalctl --no-hostname --boot 0 -k -p 2..2 > $file-crit ; \
LC_ALL=C journalctl --no-hostname --boot 0 -p 3..3 > $file-err ; \
@ -1050,11 +1056,10 @@ fi_journal(){ # 10/11/2017
return 0
fi
jctl_boot=$(gawk -F '--|,' '{ sub(/^ /,"",$2);print $2}' <<< $(cat $file-boot))
jctl_persist=$(grep -c 'no persistent journal' $file-persistant)
if [ "$jctl_persist" -eq 0 ]; then
if grep -iq 'no persistent journal' "$file-persistant"; then
alert_jctl_persist="les journaux ne sont pas persistants, revoir les logs du précédent boot "
alert_jctl_persist+="n'est donc pas possible pour investiguation avec, par exemple,: \n"
alert_jctl_persist+="\`journalctl --no-hostname --boot -1\`"
alert_jctl_persist+="n'est donc pas possible pour investiguation avec, par exemple: \n"
alert_jctl_persist+=" \`journalctl --no-hostname --boot -1\`"
fi
jctl_alert_k=$(sed '/kernel:/!d' $file-alert | sed -n 1,"$nb_lignes"p) # emergency & alert
jctl_crit_k=$(sed '/kernel:/!d' $file-crit | sed -n 1,"$nb_lignes"p)
@ -1100,9 +1105,9 @@ fi_journal(){ # 10/11/2017
unset text
}
fi_locale(){ # 09/11/2017
fi_locale(){ # 10/11/2017
local locale localectl timezone timedatectl
local xKeyboardMap keyboard alert_Rtc alert_Rtc_info alert_NTP alert_Ntp_info text
local xKeyboardMap keyboard alert_rtc alert_ntp text
# locale
locale="$(f_grep_file "/etc/default/locale* /etc/locale.conf")"
[ "$(f__cmd_exist localectl)" ] && localectl=$(localectl --no-pager status)
@ -1110,14 +1115,19 @@ fi_locale(){ # 09/11/2017
timezone="$(f_grep_file "/etc/timezone*")"
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
correctement avec le fuseau horaire configuré sur le système. Les modifications dheure
dété/hiver peuvent être incohérentes quand lhorloge matérielle est en heure locale. \n"
grep -q 'Network time on: no' <<< "$timedatectl" && alert_NTP="Attention NTP"
alert_Ntp_info="Le système ne synchronise pas l'heure sur un serveur NTP. Si ce n'est pas voulu:
activer le service: timedatectl set-ntp true
et/ou installer le démon Ntp: apt install ntp \n"
if grep -iq 'Network time on: no' <<< "$timedatectl"; then
alert_ntp="Network time on: no \n"
alert_ntp+="Le système ne synchronise pas l'heure sur un serveur NTP. Si ce n'est pas voulu: \n"
alert_ntp+="activer le service: timedatectl set-ntp true \n"
alert_ntp+="et/ou installer le démon Ntp: apt install ntp"
fi
if grep -iq 'RTC in local TZ: yes' <<< "$timedatectl"; then
alert_rtc="RTC in local TZ: yes \n"
alert_rtc+="Lhorloge système doit être en UTC pour que les applications de date et "
alert_rtc+="heure fonctionnent correctement avec le fuseau horaire configuré sur le système. "
alert_rtc+="Les modifications dheure dété/hiver peuvent être incohérentes quand lhorloge "
alert_rtc+="matérielle est en heure locale."
fi
fi
# keyboard layout
keyboard="$(f_grep_file "/etc/default/keyboard*")"
@ -1125,18 +1135,16 @@ et/ou installer le démon Ntp: apt install ntp \n"
###
text="## localisation \n\n"
# locale
[ "$locale" ] && f_display "locale" "cmd" "grep -Esv '#|^$' /etc/default/locale* /etc/locale.conf"
[ "$localectl" ] && f_display "localectl" "cmd" "localectl --no-pager status"
f_display "locale" "cmd" "grep -Esv '#|^$' /etc/default/locale* /etc/locale.conf"
f_display "localectl" "cmd" "localectl --no-pager status"
# timezone
[ "$timezone" ] && f_display "timezone" "cmd" "grep -EHsv '#|^$' /etc/timezone*"
[ "$timezone" ] || f_dspl_file_KO "/etc/timezone*"
[ "$timedatectl" ] && f_display "timedatectl" "cmd" "timedatectl status --no-pager"
[ "$alert_Rtc" ] && text+="$alert_Rtc_info \n"
[ "$alert_Ntp" ] && text+="$alert_Ntp_info \n"
f_display "timezone" "cmd" "grep -EHsv '#|^$' /etc/timezone*"
f_display "timedatectl" "cmd" "timedatectl status --no-pager"
f_dspl_alert "alert_ntp" "info"
f_dspl_alert "alert_rtc" "alert"
# keyboard layout
[ "$keyboard" ] && f_display "keyboard" "cmd" "grep -EHv '#|^$' /etc/default/keyboard*"
[ "$keyboard" ] || f_dspl_file_KO "/etc/default/keyboard"
[ "$xKeyboardMap" ] && f_display "xKeyboardMap" "cmd" "setxkbmap -query"
f_display "keyboard" "cmd" "grep -EHv '#|^$' /etc/default/keyboard*"
f_display "xKeyboardMap" "cmd" "setxkbmap -query"
printf "$text\n" >> "$fileOutput"
unset text
}
@ -1191,7 +1199,7 @@ fi_mem(){ # 08/11/2017
unset text
}
fi_nm(){ # 09/11/2017
fi_nm(){ # 10/11/2017
[ "$(f__cmd_exist nmcli)" ] || return 0
local nm_etat nm_conf nm_wifis nm_connected text
nm_etat=$(f_grep_file "/var/lib/NetworkManager/NetworkManager.state" "file")
@ -1200,10 +1208,8 @@ fi_nm(){ # 09/11/2017
nm_connected=$(LC_ALL=C nmcli -f SSID,ACTIVE,IN-USE device wifi list | gawk '/yes[[:space:]]+\*/ {print $1}')
###
text="## NetworkManager \n\n"
[ "$nm_etat" ] && f_display "nm_etat" "cmd" "grep -Ev '#|^$' /var/lib/NetworkManager/NetworkManager.state"
[ "$nm_etat" ] || f_dspl_file_KO "/var/lib/NetworkManager/NetworkManager.state"
[ "$nm_conf" ] && f_display "nm_conf" "cmd" "grep -Ev '#|^$' /etc/NetworkManager/NetworkManager.conf"
[ "$nm_conf" ] || f_dspl_file_KO "/etc/NetworkManager/NetworkManager.conf"
f_display "nm_etat" "cmd" "grep -Ev '#|^$' /var/lib/NetworkManager/NetworkManager.state"
f_display "nm_conf" "cmd" "grep -Ev '#|^$' /etc/NetworkManager/NetworkManager.conf"
if [ "$nm_wifis" ]; then
text+="## wifis à proximité \n\n"
f_display "nm_wifis" "cmd" "nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list | head -n15"
@ -1212,7 +1218,7 @@ fi_nm(){ # 09/11/2017
unset text
}
fi_reseau(){ # 09/11/2017
fi_reseau(){ # 10/11/2017
local slots cards ip_a iwconfig interfaces route resolv canal_wifi ifx alert_wlx text pluriel
# cardsManuel="$(lspci -nnk | grep -EiA 5 'network|ethernet')"
# cardsManuel="$(lspci -nnv | grep -EiA 15 'network|ethernet')"
@ -1251,35 +1257,37 @@ fi_reseau(){ # 09/11/2017
fi
done
figet_ip
if grep -q 'wlx' <<< "$fg_ifn"; then
alert_wlx="**Attention:** une interface wifi est en erreur: $(grep -o 'wlx' <<< $fg_ifn) \n"
alert_wlx+="l'interface n'est pas reconnue et est donc mal nommée \n"
alert_wlx+="au pire, changer le renommage: "
alert_wlx+="https://kyodev.frama.io/kyopages/trucs/interfaces-nommage-classique/ \n\n"
if grep -iq 'wlx' <<< "$fg_ifn"; then
alert_wlx="Une interface wifi est en erreur: $(grep -o 'wlx' <<< $fg_ifn) \n"
alert_wlx+="l'interface n'est pas reconnue et est donc mal nommée, "
alert_wlx+="éventuellement, changer le renommage: \n"
alert_wlx+="https://kyodev.frama.io/kyopages/trucs/interfaces-nommage-classique/"
fi
figet_mod_net
[ "$fg_mod_net" ] || figet_mod_net
###
text="## réseau \n\n"
#lspci
[ "$cards" ] && f_display "cards" "cmd" "lspci -nnv | grep -EiA 15 'network|ethernet"
f_display "cards" "cmd" "lspci -nnv | grep -EiA 15 'network|ethernet"
# ip locales avec type
f_display "fg_ip_tp" "var" "IP locale(s):"
[ "$alert_wlx" ] && text+="alert_wlx \n\n"
[ $(f__wcv "-l" "$fg_ip_tp") -gt 1 ] && pluriel="s" || unset pluriel
f_display "fg_ip_tp" "var" "" "IP locale"$pluriel
f_dspl_alert "alert_wlx" "alert"
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'
# gateways
f_display "fg_gws" "var" "Passerelle(s):"
[ $(f__wcv "-l" "$fg_gws") -gt 1 ] && pluriel="s" || unset pluriel
f_display "fg_gws" "var" "" "Passerelle"$pluriel
# interface prioritaire
[ $(wc -w <<< $fg_ifn) -gt 1 ] && f_display "fg_ifn_prior" "var" "interface prioritaire"
if [ $(wc -w <<< $fg_ifn) -gt 1 ]; then
f_display "fg_ifn_prior" "var" "" "interface de sortie"
fi
# ip a & route & interface & resolv
f_display "ip_a" "cmd" "ip address" "sans ipV6 et sans adresses MAC"
f_display "route" "cmd" "ip route show"
[ "$interfaces" ] && f_display "interfaces" "cmd" "grep -EHrsv '#|^$' /etc/network/interfaces*"
[ "$interfaces" ] || f_dspl_file_KO "/etc/network/interfaces*"
[ "$resolv" ] && f_display "resolv" "cmd" "cat /etc/resolv.conf" "serveurs de noms DNS utilisés"
[ "$resolv" ] || f_dspl_file_KO "/etc/resolv.conf"
f_display "interfaces" "cmd" "grep -EHrsv '#|^$' /etc/network/interfaces*"
f_display "resolv" "cmd" "cat /etc/resolv.conf" "serveurs de noms DNS utilisés"
# iwconfig & iwlist
[ "$iwconfig" ] && f_display "iwconfig" "cmd" "iwconfig" "état carte wifi"
f_display "iwconfig" "cmd" "iwconfig" "état carte wifi"
if [ "$canal_wifi" ]; then
f_display "canal_wifi" "cmd" "iwlist chan | grep 'Current Frequency' | grep -Eio 'channel [0-9]+'" \
"canal wifi utilisé"
@ -1291,17 +1299,17 @@ fi_reseau(){ # 09/11/2017
text+="### gestionnaire de réseau \n\n"
if [ "$netmgrinst" ]; then
[ $(wc -w <<< $netmgrinst) -gt 1 ] && pluriel="s" || unset pluriel
text+="installé$pluriel: **$netmgrinst** \n"
text+="installé"$pluriel": **$netmgrinst** \n"
else
[ $(wc -w <<< $netmgrnames[@]) -gt 1 ] && pluriel="s" || unset pluriel
text+="non trouvé$pluriel parmi: ${netmgrnames[@]} \n"
text+="non trouvé"$pluriel" parmi: ${netmgrnames[@]} \n"
fi
text+="en fonctionnement: "
[ "$netmgrrun" ] && text+="**$netmgrrun** \n\n" || text+="aucun \n\n"
fi
# modules réseau
text+="### modules réseau \n\n"
[ "$fg_mod_net" ] && f_display "fg_mod_net" "var" "liste non garantie complète"
f_display "fg_mod_net" "var" "liste non garantie complète"
[ "$fg_mod_net" ] || text+="**Modules chargés non reconnus**"
printf "$text\n" >> "$fileOutput"
unset text
@ -1329,16 +1337,16 @@ fi_serial(){ # 06/11/2017
unset text
}
fi_sources(){ #v2 09/11/2017
fi_sources(){ #v2 10/11/2017
[ "$(f__cmd_exist dpkg)" ] || return 0
local sources dateMaj nb_packages upgrade upgrade_qte remove remove_qte non_ii_qte text pluriel
local alert_httpredir alert_upgrade alert_full_upgrade alert_upgrade_titre
local alert_remove alert_remove_titre alert_non_ii alert_non_ii_titre
local alert_remove alert_remove_titre alert_non_ii alert_non_ii_titre alert_non_ii_info
# sources & divers
sources=$(f_grep_file "/etc/apt/sources.list /etc/apt/sources.list.d/*.list" 8)
dateMaj="$(date -r /var/cache/apt/pkgcache.bin '+%d/%m/%Y %H:%M %z')" # /var/lib/dpkg/
nb_packages="$(dpkg -l | grep -c '^ii')"
if [ $(grep -c 'httpredir' <<< $sources) -ne 0 ]; then
if grep -iq 'httpredir' <<< $sources ; then
alert_httpredir="ces urls sont obsolètes, préférer http://deb.debian.org/ ou un miroir local: \n\n"
alert_httpredir+="$(grep 'httpredir' <<< "$sources")"
fi
@ -1349,7 +1357,7 @@ fi_sources(){ #v2 09/11/2017
upgrade_qte=($(gawk '/ newly installed/{print $1" "$10}' <<< $upgrade))
if [ "${upgrade_qte[0]}" -gt 0 ]; then # upgrade
[ "${upgrade_qte[0]}" -gt 1 ] && pluriel="s" || unset pluriel
alert_upgrade_titre="${upgrade_qte[0]} paquet$pluriel à mettre à jour"
alert_upgrade_titre="${upgrade_qte[0]} paquet"$pluriel" à mettre à jour"
alert_upgrade=$(gawk '/Inst /{
sub(/\(/,"",$4); sub(/\/.*/,"",$5); sub(/\[/,"",$3); sub(/\]/,"",$3);
printf "%-25s source: %-25s %-20s ⇉ %-20s\n",$2,$5,$3,$4 }' <<< $upgrade)
@ -1357,7 +1365,7 @@ fi_sources(){ #v2 09/11/2017
fi
if [ "${upgrade_qte[1]}" -gt 0 ]; then # dist-upgrade #10 upgraded, 0 newly installed, 0 to remove and 0 not upgraded"
[ "${upgrade_qte[1]}" -gt 1 ] && pluriel="s" || unset pluriel
alert_full_upgrade="${upgrade_qte[1]} paquet$pluriel à mettre à jour avec (\`apt full-upgrade\`)"
alert_full_upgrade="${upgrade_qte[1]} paquet"$pluriel" à mettre à jour avec (\`apt full-upgrade\`)"
fi
printf "‣"
# autoremove
@ -1366,12 +1374,12 @@ fi_sources(){ #v2 09/11/2017
remove_qte=$(gawk '/ newly installed/{print $6}' <<< $remove)
if [ "$remove_qte" -gt 0 ]; then
[ "$remove_qte" -gt 1 ] && pluriel="s" || unset pluriel
alert_remove_titre="$remove_qte paquet$pluriel non nécessaire$pluriel"
alert_remove_titre="$remove_qte paquet"$pluriel" non nécessaire"$pluriel
alert_remove="$(sed -En 's/Remv (.*)\[[0-9.-]*\]/\1/p' <<< $remove | tr '\n' ' ')"
alert_remove+="\n\n pour corriger: apt autoremove --purge"
alert_remove+="\n\nvérifier que la liste ne contient pas des applications devenues importantes \n"
alert_remove+="au besoin, les marquer comme installés manuellement avec apt-mark \n"
alert_remove+="ou les installer manuellement avec apt install paquet"
alert_remove+="ou les installer manuellement avec apt install <paquet>"
fi
printf "‣"
# paquet non ^ii
@ -1380,7 +1388,7 @@ fi_sources(){ #v2 09/11/2017
non_ii_qte=$( f__wcv -l "$alert_non_ii" )
if [ "$non_ii_qte" -gt 0 ]; then
[ "$non_ii_qte" -gt 1 ] && pluriel="s" || unset pluriel
alert_non_ii_titre="$non_ii_qte paquet$pluriel dans un état non installé"
alert_non_ii_titre="$non_ii_qte paquet"$pluriel" dans un état non installé"
[[ ${alert_non_ii,,} =~ ^. ]] && alert_non_ii+=" ‣ État souhaité "$'\n'
[[ ${alert_non_ii,,} =~ ^h ]] && alert_non_ii+=" h.. hold (à garder) "$'\n'
[[ ${alert_non_ii,,} =~ ^i ]] && alert_non_ii+=" i.. install (à installer) "$'\n'
@ -1398,17 +1406,23 @@ fi_sources(){ #v2 09/11/2017
[[ ${alert_non_ii,,} =~ ^.w ]] && alert_non_ii+=" .w. triggers-awaiting (attente déclencheurs) "$'\n'
[[ ${alert_non_ii,,} =~ ^..r ]] && alert_non_ii+=" ‣ Drapeaux d'erreur**\n ..r (réinstallation requise) "$'\n'
alert_non_ii=${alert_non_ii::-1} # suppression dernier $'\n'
if grep -iq '^rc ' <<< "$alert_non_ii"; then
alert_non_ii_info="les paquets dans un état 'rc' (fichiers de configuration restants) "
alert_non_ii_info+="peuvent être purgés avec : \n"
alert_non_ii_info+="\`dpkg --purge \$(dpkg -l | awk '/^rc/{print \$2}')\`"
fi
fi
###
text="## gestion de paquets DPKG \n\n"
f_display "sources" "cmd" "grep -Ersv '^#|^$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list"
text+="* nombre de paquets installés: **$nb_packages** \n"
text+="* dernière mise à jour apt: **$dateMaj** \n\n"
[ "$alert_httpredir" ] && f_display "alert_httpredir" "var" "httpredir obsolète"
[ "$alert_upgrade" ] && f_display "alert_upgrade" "cmd" "apt list --upgradable" "$alert_upgrade_titre"
f_dspl_alert "alert_httpredir" "info"
f_display "alert_upgrade" "cmd" "apt list --upgradable" "$alert_upgrade_titre"
[ "$alert_full_upgrade" ] && text+="* $alert_full_upgrade \n\n"
[ "$alert_remove" ] && f_display "alert_remove" "cmd" "apt autoremove --simulate" "$alert_remove_titre"
[ "$alert_non_ii" ] && f_display "alert_non_ii" "cmd" "dpkg -l | gawk '/^rc/{print \$2}" "$alert_non_ii_titre"
f_display "alert_remove" "cmd" "apt autoremove --simulate" "$alert_remove_titre"
f_display "alert_non_ii" "cmd" "dpkg -l | gawk '/^rc/{print \$2}" "$alert_non_ii_titre"
f_dspl_alert "alert_non_ii_info" "info"
printf "$text\n" >> "$fileOutput"
unset text
}
@ -1521,7 +1535,7 @@ fi_systeme(){ # 10/11/2017
[ "$alimentation" ] && text+="$alimentation \n"
if [ "$fg_batt" ]; then
[ "$fg_nb_batt" -gt "1" ] && pluriel="s" || unset pluriel
text+="$fg_nb_batt batterie$pluriel présente$pluriel: \n"
text+="$fg_nb_batt batterie"$pluriel" présente$pluriel: \n"
text+="$(sed -En 's/^BAT(.*)$/ BAT\1/p' <<< $fg_batt) \n"
fi
text+="dernier boot: $lastboot, uptime: $uptime \n"
@ -2508,7 +2522,7 @@ fipaste_curl_pastery(){ # 25/10/2017
id="$(echo $curl | cut -d '"' -f 4)"
[ "$pasteDuration" -gt 1 ] && pluriel="s" || unset pluriel
f__info "votre paste:$GREEN https://www.pastery.net/$id/" \
"(valide pendant $RED$pasteDuration jour$pluriel)"
"(valide pendant $RED$pasteDuration jour"$pluriel")"
echo -e "exporté sur https://www.pastery.net/$id/ \n\n" >> "$fileOutput"
fi
[ "$3" == "debugPaste" ] && f__info "$curl"
@ -2833,7 +2847,7 @@ for j in $options; do
case $j in
-t | --test )
prg_1 "$*"
fi_graph
fi_sources
exit ;; # test
-c* | all )
[ "$j" == "-c" ] && exec $0 "menu"

View File

@ -3,9 +3,15 @@
* f__wcv, f_display_grep, f_dspl_md, f__wget_test, fscript_get_version, fscript_update
* ! f__requis, fscript_install, f__scandir
## 2.30.0 10/11/2017
* révision fonctions affichage (f_display, f_grep_file, f_dspl_alert, suppression f_dspl_file_KO)
* fix: fi_journal, mauvaise détection journaux non persistants
## 2.29.0 10/11/2017
* nouveau: figet_gpu v3, retourne infos et nb de gpu quelques soit options lspci
* nouveau: figet_gpu v3, retourne infos et nb de gpu quelque soit options lspci
* révision: alerte curl manquant moins déroutant pour nouvel utilisateur
* révision: alertes/infos
* révision: f_disk