diff --git a/scripts/getInfo b/scripts/getInfo index ea73596..7fa5d27 100755 --- a/scripts/getInfo +++ b/scripts/getInfo @@ -1,7 +1,7 @@ #!/bin/bash -version=3.27.0 -date="28/02/2018" +version=3.28.0 +date="01/03/2018" projet="simpledeb" contact="IRC freenode.net ##sdeb ou https://framagit.org/kyodev/kyopages/issues/" script="getInfo" @@ -34,19 +34,28 @@ f__architecture(){ # 14/12/2017 esac } -f__color(){ # 31/01/2018 +f__color(){ # 01/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=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 # tit1|tit2|tit3 # 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 # ATTENTION aux éventuelles collision $x dans ce cas: # "[ \"$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 -fi_bluez(){ # 22/02/2018 +fi_bluez(){ # 01/03/2018 local bluez cmd_bluez cmt_bluez mod cmd_mod cmt_mod pluriel text x_bluez=1 - if hcitool scan &>/dev/null && [[ $( f__which hciconfig ) ]]; then - fe_nb_bluez=$( hciconfig name 2>/dev/null ) - fe_cards_bluez=$( grep -Eo '^hci[0-9]+' <<< "$fe_nb_bluez" ) - fe_nb_bluez=$( grep -c '^hci[0-9].*$' <<< "$fe_nb_bluez" ) - fe_cards_bluez=${fe_cards_bluez//[[:cntrl:]]/ } # mise en liste inline + if [[ $( f__which hcitool ) ]] ; then + fe_nb_bluez=$( hcitool dev | grep -c 'hci[[:digit:]]' ) + fe_cards_bluez=$( hcitool dev | grep -Eo 'hci[0-9]+' | tr '\n' ' ' ) else - fe_nb_bluez=0 + fe_nb_bluez=-99 + fe_cards_bluez="n/a" fi - [[ "$1" == "silent" || "$fe_nb_bluez" -eq 0 ]] && return 0 + [[ "$1" == "silent" || "$fe_nb_bluez" -le 0 ]] && return 0 ### # état 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" cmt_bluez="état périphérique"$pluriel # modules @@ -1729,7 +1737,6 @@ fi_pkg_apt(){ # 28/02/2018 # essai confOnly if [ "$1" == "confOnly" ]; then 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/50unattended-upgrades" "comment//" ) cmd_unUpgrd="grep -Erv '^//|^$' /etc/apt/apt.conf.d/50unattended-upgrades" @@ -2249,7 +2256,7 @@ fi_ssid(){ # 24/12/2017 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 enum_batt nb_desktop serverX serverType local alimentation alim_total @@ -2271,7 +2278,7 @@ fi_system(){ # 28/02/2018 (( x_shell == 1 )) || figet_shell (( x_touchpad == 1 )) || fi_touchpad "silent" (( x_wm == 1 )) || figet_wm - echo -n "ø" + [ "$1" != "rc" ] && echo -n "ø" # divers système 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}' if [[ "$initDaemon" == "systemd" && $( f__which systemd ) ]]; then 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 initDaemon=${initDaemon^} # 1er car mal if upstart --version &>/dev/null; then # encore présent sur 16.04?? @@ -2347,7 +2357,7 @@ fi_system(){ # 28/02/2018 # alimentation 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" ' { alim_on=sprintf("%d", $1); if (alim_on>1) pllo="s" } END { if ( alim_total > 1 ) pllt="s"; printf alim_total " alimentation" pllt @@ -2358,6 +2368,10 @@ fi_system(){ # 28/02/2018 # batterie(s) enum_batt=$( grep -E '[A-Z][A-Z]' <<< "$fg_batt" ) ### + if [ "$1" == "rc" ]; then + fi_systemRc + return + fi [ "$ORIGIN" ] && f_prnt tit2 "système" f_prnt 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 "date d'installation: $date_install" 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__wcv -w "$fg_shells" )" -gt 1 ] && pluriel="s" || unset pluriel f_prnt l2 "shell"$pluriel" installé"$pluriel": $fg_shells" @@ -2415,7 +2429,47 @@ fi_system(){ # 28/02/2018 f_prnt 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**" - [ "$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 flush } @@ -2435,7 +2489,6 @@ fi_system_analyse(){ # 25/02/2018 cmd_bootTime="systemd-analyze time" cmt_bootTime="durée du boot, avant interface graphique" # services en erreur -# srvcFail=$( systemctl --state=active,failed | grep -cE 'error|not-found|failed' ) srvcFail=$( LC_ALL=C systemctl --state=active,failed | awk ' /error|not-found|failed/ { sub(/●|\*/,""); 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" return 1 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 return 0 fi @@ -3931,7 +3984,7 @@ figet_modules(){ # 25/02/2018 if [ "$1" == "bluetooth" ]; then dir="/lib/modules/$(uname -r)/kernel/drivers/bluetooth" # répertoire à scruter # recherche modules/formation motif ou liste - separator="|" # séparateur | par défaut + separator="|" # séparateur | par défaut modules=$( f__dir -l "$dir" ) modules=${modules//.ko} modules=${modules// /|} @@ -3990,7 +4043,7 @@ figet_shell(){ # 28/02/2018 # thanks neofetch 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,,} case ${shell:=$fg_shell} in # shell null, donc assigné avec $fg_shell bash ) @@ -4379,7 +4432,7 @@ fscript_remove(){ # 24/02/2018 } # 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" 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" return 0 else - f__info "mise à jour en courupgradeEnPlaces" + f__info "mise à jour en cours" fi mkdir -p "$dirTemp" 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/" } -prg_init(){ # 28/02/2018 +prg_init(){ # 01/03/2018 PATH='/usr/sbin:/usr/bin:/sbin:/bin' TERM=xterm @@ -4420,6 +4473,14 @@ prg_init(){ # 28/02/2018 IFS=$' \t\n' 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é DIRNAME=$( dirname $0 ) DIRNAME=${DIRNAME#/usr/bin} # suppression /usr/bin éventuel au début ( lien ) @@ -4576,7 +4637,7 @@ function display_menu { prg_init # logo et définition couleurs -f_affichage +[ "$1" != "-rc" ] && f_affichage # paramètres script 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_reseau fi_nm # fi_system_analyse fi_log_xorg fi_journal - fi_bluez # long + fi_system echo [ "$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_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 "$*" fi_gpu "xorgOnly" [ "$DISPLAY" ] && f_prnt_md "$file_output" || pager "$file_output" exit ;; - -dp ) # ESSAI util source/apt confOnly + -dp ) # essai util source/apt confOnly prg_1 "$*" fi_pkg_apt "confOnly" [ "$DISPLAY" ] && f_prnt_md "$file_output" || pager "$file_output" diff --git a/scripts/getInfo_changelog.md b/scripts/getInfo_changelog.md index 25226f0..1340402 100644 --- a/scripts/getInfo_changelog.md +++ b/scripts/getInfo_changelog.md @@ -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 révision: fi_cpu, fi_pkg_apt