getInfo 3.28.0

This commit is contained in:
kyodev 2018-03-02 06:06:51 +01:00
parent 48c6504bf5
commit 1213aea65c
2 changed files with 116 additions and 41 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
version=3.27.0 version=3.28.0
date="28/02/2018" date="01/03/2018"
projet="simpledeb" projet="simpledeb"
contact="IRC freenode.net ##sdeb ou https://framagit.org/kyodev/kyopages/issues/" contact="IRC freenode.net ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getInfo" script="getInfo"
@ -34,19 +34,28 @@ f__architecture(){ # 14/12/2017
esac esac
} }
f__color(){ # 31/01/2018 f__color(){ # 01/03/2018
BLACK=$(tput setaf 0) if type -p tput &>/dev/null && tput setaf 1 &>/dev/null; then
RED=$(tput setaf 1) # alerte BLACK=$( tput setaf 0 )
GREEN=$(tput setaf 2) # ok RED=$( tput setaf 1 ) # alerte
YELLOW=$(tput setaf 3) # question GREEN=$( tput setaf 2 ) # ok
BLUE=$(tput setaf 4) # info YELLOW=$( tput setaf 3 ) # question
CYAN=$(tput setaf 6) BLUE=$( tput setaf 4 ) # info
MAGENTA=$(tput setaf 5) CYAN=$( tput setaf 6 )
STD=$(tput sgr0) # retour "normal" MAGENTA=$( tput setaf 5 )
BOLD=$(tput bold) STD=$( tput sgr0 ) # retour "normal"
ITAL=$(tput sitm) BOLD=$( tput bold )
SOUL=$(tput smul) 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=oui|non | clear | -tx (oui|non, réponse par défaut si entrée seule), $2=message, return 0 si oui, return 1 si non # $1=oui|non | clear | -tx (oui|non, réponse par défaut si entrée seule), $2=message, return 0 si oui, return 1 si non
@ -632,7 +641,7 @@ f_policy(){ # 27/01/2018
# l1|l2|l3 ligne, indentation, avec espaces # l1|l2|l3 ligne, indentation, avec espaces
# tit1|tit2|tit3 # tit1|tit2|tit3
# quote|hl|flush # quote|hl|flush
# $2 texte à afficher # $2 texte à afficher, pas de contrôle si texte null ou présent
# $3 test éventuel, Si CONDITION ok -> affichage # $3 test éventuel, Si CONDITION ok -> affichage
# ATTENTION aux éventuelles collision $x dans ce cas: # ATTENTION aux éventuelles collision $x dans ce cas:
# "[ \"$1\" != \"notitre\" ]" ou "[ $1 != notitre ]" (attention au manque de ") # "[ \"$1\" != \"notitre\" ]" ou "[ $1 != notitre ]" (attention au manque de ")
@ -842,25 +851,24 @@ fi_batt(){ # 14/12/2017
} }
# [$1=silent], assigne $fe_nb_bluez, $fe_cards_bluez # [$1=silent], assigne $fe_nb_bluez, $fe_cards_bluez
fi_bluez(){ # 22/02/2018 fi_bluez(){ # 01/03/2018
local bluez cmd_bluez cmt_bluez mod cmd_mod cmt_mod pluriel text local bluez cmd_bluez cmt_bluez mod cmd_mod cmt_mod pluriel text
x_bluez=1 x_bluez=1
if hcitool scan &>/dev/null && [[ $( f__which hciconfig ) ]]; then if [[ $( f__which hcitool ) ]] ; then
fe_nb_bluez=$( hciconfig name 2>/dev/null ) fe_nb_bluez=$( hcitool dev | grep -c 'hci[[:digit:]]' )
fe_cards_bluez=$( grep -Eo '^hci[0-9]+' <<< "$fe_nb_bluez" ) fe_cards_bluez=$( hcitool dev | grep -Eo 'hci[0-9]+' | tr '\n' ' ' )
fe_nb_bluez=$( grep -c '^hci[0-9].*$' <<< "$fe_nb_bluez" )
fe_cards_bluez=${fe_cards_bluez//[[:cntrl:]]/ } # mise en liste inline
else else
fe_nb_bluez=0 fe_nb_bluez=-99
fe_cards_bluez="n/a"
fi fi
[[ "$1" == "silent" || "$fe_nb_bluez" -eq 0 ]] && return 0 [[ "$1" == "silent" || "$fe_nb_bluez" -le 0 ]] && return 0
### ###
# état # état
bluez=$( hciconfig -a ) bluez=$( hciconfig -a )
[ "$( grep -c '^hci[0-9]' <<< "$bluez" )" -gt 1 ] && pluriel="s" || unset pluriel [ "$fe_nb_bluez" -gt 1 ] && pluriel="s" || unset pluriel
cmd_bluez="hciconfig -a" cmd_bluez="hciconfig -a"
cmt_bluez="état périphérique"$pluriel cmt_bluez="état périphérique"$pluriel
# modules # modules
@ -1729,7 +1737,6 @@ fi_pkg_apt(){ # 28/02/2018
# essai confOnly # essai confOnly
if [ "$1" == "confOnly" ]; then if [ "$1" == "confOnly" ]; then
local apt_unUpgrd cmd_unUpgrd cmd_apt_history essai local apt_unUpgrd cmd_unUpgrd cmd_apt_history essai
# shopt -s extglob
# apt_unUpgrd=$( f_grep_file "/etc/apt/apt.conf.d/!(*.save)" "comment//" ) # apt_unUpgrd=$( f_grep_file "/etc/apt/apt.conf.d/!(*.save)" "comment//" )
apt_unUpgrd=$( f_grep_file "/etc/apt/apt.conf.d/50unattended-upgrades" "comment//" ) apt_unUpgrd=$( f_grep_file "/etc/apt/apt.conf.d/50unattended-upgrades" "comment//" )
cmd_unUpgrd="grep -Erv '^//|^$' /etc/apt/apt.conf.d/50unattended-upgrades" cmd_unUpgrd="grep -Erv '^//|^$' /etc/apt/apt.conf.d/50unattended-upgrades"
@ -2249,7 +2256,7 @@ fi_ssid(){ # 24/12/2017
rm "$file_output" rm "$file_output"
} }
fi_system(){ # 28/02/2018 fi_system(){ # 01/03/2018
local mbr uname bootImage initDaemon upstart date_install lastboot uptime uptimePure loadAverage pluriel text local mbr uname bootImage initDaemon upstart date_install lastboot uptime uptimePure loadAverage pluriel text
local enum_batt nb_desktop serverX serverType local enum_batt nb_desktop serverX serverType
local alimentation alim_total local alimentation alim_total
@ -2271,7 +2278,7 @@ fi_system(){ # 28/02/2018
(( x_shell == 1 )) || figet_shell (( x_shell == 1 )) || figet_shell
(( x_touchpad == 1 )) || fi_touchpad "silent" (( x_touchpad == 1 )) || fi_touchpad "silent"
(( x_wm == 1 )) || figet_wm (( x_wm == 1 )) || figet_wm
echo -n "ø" [ "$1" != "rc" ] && echo -n "ø"
# divers système # divers système
if [ -d /sys/firmware/efi ]; then if [ -d /sys/firmware/efi ]; then
@ -2284,6 +2291,9 @@ fi_system(){ # 28/02/2018
initDaemon=$( ps -p1 -o comm --no-headers ) # ps -p1 | awk 'FNR==2 {print $4}' initDaemon=$( ps -p1 -o comm --no-headers ) # ps -p1 | awk 'FNR==2 {print $4}'
if [[ "$initDaemon" == "systemd" && $( f__which systemd ) ]]; then if [[ "$initDaemon" == "systemd" && $( f__which systemd ) ]]; then
initDaemon=$( systemd --version | head -n1 ) initDaemon=$( systemd --version | head -n1 )
if [ "$fg_dm" == "slim" ]; then
alert_slim="SLiM est abandonné et n'est pas entièrement compatible avec systemd. voir la page archlinux sur slim"
fi
fi fi
initDaemon=${initDaemon^} # 1er car mal initDaemon=${initDaemon^} # 1er car mal
if upstart --version &>/dev/null; then # encore présent sur 16.04?? if upstart --version &>/dev/null; then # encore présent sur 16.04??
@ -2347,7 +2357,7 @@ fi_system(){ # 28/02/2018
# alimentation # alimentation
if ls -1 "/sys/class/power_supply/" | grep -iq '^AC' ; then if ls -1 "/sys/class/power_supply/" | grep -iq '^AC' ; then
alim_total=$( grep -cs 1 /sys/class/power_supply/AC*/online ) alim_total=$( grep -cs '1' /sys/class/power_supply/AC*/online )
alimentation=$( awk -v "alim_total=$alim_total" ' alimentation=$( awk -v "alim_total=$alim_total" '
{ alim_on=sprintf("%d", $1); if (alim_on>1) pllo="s" } { alim_on=sprintf("%d", $1); if (alim_on>1) pllo="s" }
END { if ( alim_total > 1 ) pllt="s"; printf alim_total " alimentation" pllt END { if ( alim_total > 1 ) pllt="s"; printf alim_total " alimentation" pllt
@ -2358,6 +2368,10 @@ fi_system(){ # 28/02/2018
# batterie(s) # batterie(s)
enum_batt=$( grep -E '[A-Z][A-Z]' <<< "$fg_batt" ) enum_batt=$( grep -E '[A-Z][A-Z]' <<< "$fg_batt" )
### ###
if [ "$1" == "rc" ]; then
fi_systemRc
return
fi
[ "$ORIGIN" ] && f_prnt tit2 "système" [ "$ORIGIN" ] && f_prnt tit2 "système"
f_prnt f_prnt
f_prnt 1 "$( sed -E 's/(.*)/**\1** /' <<< "$fg_dmi" )" # en gras f_prnt 1 "$( sed -E 's/(.*)/**\1** /' <<< "$fg_dmi" )" # en gras
@ -2381,7 +2395,7 @@ fi_system(){ # 28/02/2018
f_prnt l2 "architecture système: $fu_archi" f_prnt l2 "architecture système: $fu_archi"
f_prnt l2 "date d'installation: $date_install" f_prnt l2 "date d'installation: $date_install"
f_prnt l2 "démon d'initialisation: $initDaemon" f_prnt l2 "démon d'initialisation: $initDaemon"
f_prnt l3 "$upstart présent" '[ "$upstart" ]' f_prnt l3 "$upstart" '[ "$upstart" ]'
f_prnt l2 "shell actif: $fg_shell" f_prnt l2 "shell actif: $fg_shell"
[ "$( f__wcv -w "$fg_shells" )" -gt 1 ] && pluriel="s" || unset pluriel [ "$( f__wcv -w "$fg_shells" )" -gt 1 ] && pluriel="s" || unset pluriel
f_prnt l2 "shell"$pluriel" installé"$pluriel": $fg_shells" f_prnt l2 "shell"$pluriel" installé"$pluriel": $fg_shells"
@ -2415,7 +2429,47 @@ fi_system(){ # 28/02/2018
f_prnt f_prnt
f_prnt 1 "$( sed -E 's/^(.*: )(.*)/\1**\2**/' <<< "$fg_disk_part_fix_tot" )" '[ "$fg_disk_part_fix_tot" ]' f_prnt 1 "$( sed -E 's/^(.*: )(.*)/\1**\2**/' <<< "$fg_disk_part_fix_tot" )" '[ "$fg_disk_part_fix_tot" ]'
f_prnt 1 "dernier boot: **$lastboot**, il y a **$uptime**" f_prnt 1 "dernier boot: **$lastboot**, il y a **$uptime**"
[ "$fg_nb_threads" -gt "1" ] && pluriel="s" || unset pluriel f_prnt 1 "$loadAverage"
f_prnt flush
f_dspl_alrt "$alert_slim" "alert"
}
fi_systemRc(){
f_prnt 2 "${fg_dmi//$'\n'/ }"
f_prnt 2 "$( sed -n '1p' <<< "$fg_cpu" )"
f_prnt 2 "$fe_gpu"
f_prnt 2 "$fe_cards_reseau"
f_prnt
f_prnt l2 "distrib: $fg_distrib"
f_prnt l2 "kernel: $uname"
f_prnt l2 "boot: $mbr"
f_prnt l2 "date d'installation: $date_install"
f_prnt l2 "démon d'initialisation: $initDaemon"
f_prnt l3 "$upstart" '[ "$upstart" ]'
f_prnt l2 "shell: $fg_shell"
f_prnt l2 "${bootImage//$'\n'/ }"
f_prnt l2 "serveur d'affichage$serverType $serverX"
f_prnt l2 "nombre d'écrans: $fg_nb_screen"
[ $( f__wcv "-wv" "$fg_resolution" "pixels" ) -gt 1 ] && pluriel="s" || unset pluriel
f_prnt l2 "résolution"$pluriel": $fg_resolution"
[ $( wc -w <<< "$fg_dm" ) -gt 1 ] && pluriel="s" || unset pluriel
f_prnt l2 "display manager"$pluriel": $fg_dm"
f_prnt l2 "desktop (DE): $fg_de"
f_prnt l2 "panel: $fg_de_panel" '[ "$fg_de_panel" ]'
f_prnt l2 "window manager: $fg_wm"
f_prnt
f_prnt 1 "$fg_disk_part_fix_tot"
f_prnt 1 "dernier boot: $lastboot ($uptime)"
loadAverage=$(
LC_ALL=C uptime 2>/dev/null | awk -v threads="$fg_nb_threads" -F'(, )' '{
gsub(/ load average: /,"")
if ( threads > 1 ) th="threads"; else th="thread"
la1 = $(NF-2)
la5 = $(NF-1)
la15 = $NF
printf "charge système: %s %s %s, ", la1, la5, la15
printf "soit avec %d %s : %d%% %d%% %d%% ", threads, th, la1/2*100, la5/2*100, la15/2*100
}' )
f_prnt 1 "$loadAverage" f_prnt 1 "$loadAverage"
f_prnt flush f_prnt flush
} }
@ -2435,7 +2489,6 @@ fi_system_analyse(){ # 25/02/2018
cmd_bootTime="systemd-analyze time" cmd_bootTime="systemd-analyze time"
cmt_bootTime="durée du boot, avant interface graphique" cmt_bootTime="durée du boot, avant interface graphique"
# services en erreur # services en erreur
# srvcFail=$( systemctl --state=active,failed | grep -cE 'error|not-found|failed' )
srvcFail=$( LC_ALL=C systemctl --state=active,failed | awk ' srvcFail=$( LC_ALL=C systemctl --state=active,failed | awk '
/error|not-found|failed/ { sub(/●|\*/,""); /error|not-found|failed/ { sub(/●|\*/,"");
printf "%-50s %-11s %-8s %-8s %s",$1,$2,$3,$4,$5; $1=$2=$3=$4=$5=""; print $0}' ) printf "%-50s %-11s %-8s %-8s %s",$1,$2,$3,$4,$5; $1=$2=$3=$4=$5=""; print $0}' )
@ -2661,7 +2714,7 @@ figet_batt(){ # 25/02/2018
[ "$fg_batt" ] || fg_batt="répertoire power_supply inaccessible" [ "$fg_batt" ] || fg_batt="répertoire power_supply inaccessible"
return 1 return 1
fi fi
fg_nb_batt=$( grep -is 'Battery' /sys/class/power_supply/*/type | grep -c . ) # pas de messages, pb gentoo, pk? fg_nb_batt=$( grep -is 'Battery' /sys/class/power_supply/*/type | grep -c . )
if [ "$fg_nb_batt" -eq 0 ]; then if [ "$fg_nb_batt" -eq 0 ]; then
return 0 return 0
fi fi
@ -3931,7 +3984,7 @@ figet_modules(){ # 25/02/2018
if [ "$1" == "bluetooth" ]; then if [ "$1" == "bluetooth" ]; then
dir="/lib/modules/$(uname -r)/kernel/drivers/bluetooth" # répertoire à scruter dir="/lib/modules/$(uname -r)/kernel/drivers/bluetooth" # répertoire à scruter
# recherche modules/formation motif ou liste # recherche modules/formation motif ou liste
separator="|" # séparateur | par défaut separator="|" # séparateur | par défaut
modules=$( f__dir -l "$dir" ) modules=$( f__dir -l "$dir" )
modules=${modules//.ko} modules=${modules//.ko}
modules=${modules// /|} modules=${modules// /|}
@ -3990,7 +4043,7 @@ figet_shell(){ # 28/02/2018 # thanks neofetch
x_shell=1 x_shell=1
fg_shell=${SHELL##*/} # suppression jusqu'au dernier /, pas de chemin fg_shell=${SHELL##*/} # suppression jusqu'au dernier /, altern: ps -p $BASHPID -o comm --no-heading
fg_shell=${fg_shell,,} fg_shell=${fg_shell,,}
case ${shell:=$fg_shell} in # shell null, donc assigné avec $fg_shell case ${shell:=$fg_shell} in # shell null, donc assigné avec $fg_shell
bash ) bash )
@ -4379,7 +4432,7 @@ fscript_remove(){ # 24/02/2018
} }
# mise à jour script, [$1 != "" si upgrade en place, $1 dans message info] # mise à jour script, [$1 != "" si upgrade en place, $1 dans message info]
fscript_update(){ # 24/02/2018 fscript_update(){ # 01/03/2018
local dirTemp="/tmp/$script-maj" upgradeEnPlace="$1" local dirTemp="/tmp/$script-maj" upgradeEnPlace="$1"
type -t fscript_update_special &>/dev/null && fscript_update_special # test, si fonction spécifique, appel type -t fscript_update_special &>/dev/null && fscript_update_special # test, si fonction spécifique, appel
@ -4392,7 +4445,7 @@ fscript_update(){ # 24/02/2018
f__info "log" "pas de mise à jour disponible pour $script $version" f__info "log" "pas de mise à jour disponible pour $script $version"
return 0 return 0
else else
f__info "mise à jour en courupgradeEnPlaces" f__info "mise à jour en cours"
fi fi
mkdir -p "$dirTemp" mkdir -p "$dirTemp"
wget -q --tries=2 --timeout=15 -o /dev/null -O "$dirTemp/$script" "$url_script" wget -q --tries=2 --timeout=15 -o /dev/null -O "$dirTemp/$script" "$url_script"
@ -4412,7 +4465,7 @@ fscript_update(){ # 24/02/2018
rm -rf "$dirTemp/" rm -rf "$dirTemp/"
} }
prg_init(){ # 28/02/2018 prg_init(){ # 01/03/2018
PATH='/usr/sbin:/usr/bin:/sbin:/bin' PATH='/usr/sbin:/usr/bin:/sbin:/bin'
TERM=xterm TERM=xterm
@ -4420,6 +4473,14 @@ prg_init(){ # 28/02/2018
IFS=$' \t\n' IFS=$' \t\n'
export PATH TERM IFS export PATH TERM IFS
# options bash figées
# défaut bash, pattern étendus: extglob
shopt -s checkwinsize complete_fullquote extglob extquote interactive_comments sourcepath
shopt -u force_fignore execfail failglob
# options bash spé
# shopt -s nocasematch ( case, [[ ) nocaseglob ( fichier )
# whereis script retourne vide si installé # whereis script retourne vide si installé
DIRNAME=$( dirname $0 ) DIRNAME=$( dirname $0 )
DIRNAME=${DIRNAME#/usr/bin} # suppression /usr/bin éventuel au début ( lien ) DIRNAME=${DIRNAME#/usr/bin} # suppression /usr/bin éventuel au début ( lien )
@ -4576,7 +4637,7 @@ function display_menu {
prg_init prg_init
# logo et définition couleurs # logo et définition couleurs
f_affichage [ "$1" != "-rc" ] && f_affichage
# paramètres script # paramètres script
user_agent="Mozilla/5.0 Firefox" user_agent="Mozilla/5.0 Firefox"
@ -4642,7 +4703,7 @@ for j in $options; do # deuxième passe options, actions
# fi_efi fi_locale fi_conf fi_vrms fi_packagers # fi_efi fi_locale fi_conf fi_vrms fi_packagers
# fi_reseau fi_nm # fi_reseau fi_nm
# fi_system_analyse fi_log_xorg fi_journal # fi_system_analyse fi_log_xorg fi_journal
fi_bluez # long fi_system
echo echo
[ "$DISPLAY" ] && f_prnt_md "$file_output" || pager "$file_output" [ "$DISPLAY" ] && f_prnt_md "$file_output" || pager "$file_output"
;; ;;
@ -4653,12 +4714,20 @@ for j in $options; do # deuxième passe options, actions
prg_2 "$j" prg_2 "$j"
prg_3 prg_3
;; ;;
-dx ) # ESSAI détail, xorgOnly -rc ) # essai rc
file_output="/tmp/getInfo.rc"
echo > "$file_output"
chmod 666 "$file_output" &>/dev/null
fi_system "rc"
cat "$file_output"
#~ f_prnt_md "$file_output"
exit ;;
-dx ) # essai détail, xorgOnly
prg_1 "$*" prg_1 "$*"
fi_gpu "xorgOnly" fi_gpu "xorgOnly"
[ "$DISPLAY" ] && f_prnt_md "$file_output" || pager "$file_output" [ "$DISPLAY" ] && f_prnt_md "$file_output" || pager "$file_output"
exit ;; exit ;;
-dp ) # ESSAI util source/apt confOnly -dp ) # essai util source/apt confOnly
prg_1 "$*" prg_1 "$*"
fi_pkg_apt "confOnly" fi_pkg_apt "confOnly"
[ "$DISPLAY" ] && f_prnt_md "$file_output" || pager "$file_output" [ "$DISPLAY" ] && f_prnt_md "$file_output" || pager "$file_output"

View File

@ -2,6 +2,12 @@
## getInfo 3.28.0 01/03/2018
* nouveau: fi_system, alerte SLiM+systemd
* révision f__color, prg_init (opions bash)
* fix fi_bluez, vitesse (erreur de commande)
## getInfo 3.27.0 28/02/2018 ## getInfo 3.27.0 28/02/2018
révision: fi_cpu, fi_pkg_apt révision: fi_cpu, fi_pkg_apt