kyopages/scripts/getInfo

4959 lines
194 KiB
Plaintext
Raw Normal View History

2017-07-30 17:08:05 +02:00
#!/bin/bash
2018-03-09 17:11:49 +01:00
# shellcheck disable=SC1091,SC2009,SC2016,SC2119,SC2129
2017-07-30 17:08:05 +02:00
2018-03-09 07:12:34 +01:00
# SC1091 Not following (source)
# SC2009 Consider using pgrep instead of grepping ps output
2018-03-09 17:11:49 +01:00
# SC2016 Expressions don't expand in single quotes
2018-03-09 07:12:34 +01:00
# SC2119 Use function "$@" if function's $1 should mean script's $1 (??)
# SC2129 Consider using { cmd1; cmd2; } >> file ... (erreur détection?)
2018-04-08 16:34:59 +02:00
version=4.4.0
date="08/04/2018"
2018-02-14 07:50:17 +01:00
contact="IRC freenode.net ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
2017-07-30 17:08:05 +02:00
script="getInfo"
##### license LPRAB/WTFPL
2017-08-17 10:49:12 +02:00
# auteur: simpledeb
2017-11-25 20:13:54 +01:00
# contributeurs: kyodev, saiqui, naguam, agentcobra, amilcar
2017-07-30 17:08:05 +02:00
#####
2017-12-05 14:28:41 +01:00
# détecte architecture système, assign $fu_archi: 32bits, i686 | 64bits, amd64 (x86_64)
2017-11-25 19:39:57 +01:00
# return 1 on unknown architecture
2017-08-03 02:44:53 +02:00
# remarque, debian: dpkg --print-architecture affiche i386
2017-12-14 13:55:05 +01:00
f__architecture(){ # 14/12/2017
x_architecture=1
2018-03-09 07:12:34 +01:00
2017-08-03 02:44:53 +02:00
case "$(uname -m)" in
amd64 | x86_64 )
2017-12-02 11:05:56 +01:00
fu_archi="64bits, amd64 (x86_64)";;
2017-08-03 02:44:53 +02:00
i?86 | x86 )
2017-12-02 11:05:56 +01:00
fu_archi="32bits, i686";;
2017-08-03 02:44:53 +02:00
* )
case "$(getconf LONG_BIT)" in
64 )
2017-12-02 11:05:56 +01:00
fu_archi="64bits, amd64 (x86_64)";;
2017-08-03 02:44:53 +02:00
32 )
2017-12-02 11:05:56 +01:00
fu_archi="32bits, i686";;
2017-08-03 02:44:53 +02:00
*)
return 1
esac ;;
esac
}
2018-03-09 07:12:34 +01:00
# shellcheck disable=SC2034
# SC2034 foo appears unused. Verify it or export it.
2018-03-02 06:06:51 +01:00
f__color(){ # 01/03/2018
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
2017-09-19 08:15:55 +02:00
}
2018-02-11 14:42:07 +01:00
# $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
2018-02-01 18:36:24 +01:00
# options: oui|non réponse par défaut, -txy timeout (sans espaces entre t et chiffres) 1 à 99s
# clear effacement ligne question/réponse
2018-03-09 07:12:34 +01:00
f__dialog_oui_non(){ # 05/03/2018
2017-12-13 03:15:07 +01:00
local param
2018-02-01 18:36:24 +01:00
# extraction timeout éventuel
if [[ "$1" =~ -t[0-9]{1,2} ]]; then
2018-02-23 17:07:39 +01:00
param=$( sed -En 's/.*(-t[0-9]{1,2}).*/\1/p' <<< "$1" )
2018-02-01 18:36:24 +01:00
fi
# affichage
2017-12-05 14:28:41 +01:00
echo -en "$BLUE$2$STD"
[[ "$1" =~ oui ]] && echo -n " [O/n] " || echo -n " [o/N] "
2017-10-09 20:19:07 +02:00
if [ "$param" ]; then
2018-03-09 07:12:34 +01:00
read "$param" -r
2018-02-01 18:36:24 +01:00
echo
2017-10-09 20:19:07 +02:00
else
2017-12-13 03:15:07 +01:00
read -r
2017-10-09 20:19:07 +02:00
fi
2018-02-01 18:36:24 +01:00
# réponse par défaut si saisie vide
if [[ -z "$REPLY" && "$1" =~ oui ]]; then
REPLY="oui"
elif [[ -z "$REPLY" && "$1" =~ non ]]; then
REPLY="non"
fi
# effacement éventuel ligne question/réponse
if [[ "$1" =~ clear ]]; then
tput cuu1 # une ligne plus haut
tput dl1 # efface ligne
else
echo
fi
if [[ ${REPLY,,} =~ ^ou?i?$ ]]; then
return 0
else
return 1
2017-10-09 20:19:07 +02:00
fi
2017-12-13 03:15:07 +01:00
}
# $1=-c|-l|-lc, $2 répertoire, [$3] motif exclusion sur nom fichier, affiche 0|null si répertoire inexistant
# -c: compte du nombre de fichiers dans un répertoire
2018-02-27 09:31:41 +01:00
# -l: liste inline des noms de fichiers seuls (sans chemin) (similaire ls)
# -lc: liste en colonne des noms de fichiers seuls (sans chemin) (similaire ls -1)
2017-12-13 03:15:07 +01:00
# si joker (*?) sur chemin, le motif d'exclusion ne s'applique pas à un répertoire listé, juste sur le nom du fichier
2018-03-09 07:12:34 +01:00
# exemple: f__dir -l $dir "lock|partial" ou "\.list"
f__dir(){ # 05/03/2017
2017-12-13 03:15:07 +01:00
local i=0 action="-c" stock=''
2018-03-09 07:12:34 +01:00
[[ "$1" =~ - ]] && action="$1" || action="-c" # si option en erreur: -c par défaut
2017-12-13 03:15:07 +01:00
while read -r ; do
if [[ ! "$REPLY" =~ $3 ]] || [ -z "$3" ]; then
REPLY=${REPLY#*:} # suppression du titre de répertoire listé
[ -z "$REPLY" ] && continue # ligne vide, on passe
((i++))
stock+="$REPLY "
fi
2018-03-09 07:12:34 +01:00
done <<< "$( ls "$2" 2>/dev/null )"
2017-12-13 03:15:07 +01:00
if [ "$action" == "-c" ]; then
echo "$i"
elif [ "$action" == "-l" ]; then
2018-03-09 07:12:34 +01:00
echo "${stock% }"
2017-12-13 03:15:07 +01:00
elif [ "$action" == "-lc" ]; then
stock=${stock% }
echo -e "${stock// /$'\n'}"
fi
2017-09-15 08:54:24 +02:00
}
2017-12-24 14:25:39 +01:00
# affichage $1 en rouge, $1++ optionnels en bleu, sortie script sur erreur, log $1 si $operation=upgrade
2017-12-18 22:12:44 +01:00
f__error(){ # 18/12/2017
2017-12-05 14:28:41 +01:00
local depart=1 i
2017-10-09 20:19:07 +02:00
echo -e "\n$RED $script $version, erreur critique: $1 $STD"
for (( i=2 ; i<=$# ; i++ )); do
echo -e " $BLUE${!i}$STD"
done
echo
2017-12-24 14:25:39 +01:00
[ "$operation" == "upgrade" ] && f__log "$script $version: $1"
2017-07-30 17:08:05 +02:00
exit 1
}
2017-12-26 06:47:29 +01:00
# affichage en bleu, si $1=raw pas de ligne vide à la fin, si $1=log alors uniquement $2 logué, combiné: $1="log:raw"
2018-03-09 07:12:34 +01:00
f__info(){ # 05/03/2018
2017-10-16 07:10:04 +02:00
local depart=1 i
2017-12-05 14:28:41 +01:00
2018-03-09 07:12:34 +01:00
if [[ "$1" =~ "raw" || "$1" =~ "log" ]]; then
depart=2
fi
if [[ "$1" =~ "log" ]]; then
f__log "$( sed -E 's/\\t//;s/\\n// ' <<< "$2" | xargs )"
fi
for (( i="$depart" ; i<=$# ; i++ )); do
2017-10-09 20:19:07 +02:00
echo -e " $BLUE${!i}$STD"
done
2017-12-26 06:47:29 +01:00
[[ "$1" =~ raw ]] || echo
2017-07-30 17:08:05 +02:00
}
2017-12-01 21:50:07 +01:00
# log spécifique, fichier log limité à 10000 octets, $1 message à loguer
2018-03-09 07:12:34 +01:00
f__log(){ # 05/03/2018
2017-12-24 14:25:39 +01:00
if [ -w "$script_logs" ]; then
2018-03-09 07:12:34 +01:00
if [ "$( stat -c %s "$script_logs" )" -ge "10000" ]; then
2017-12-24 14:25:39 +01:00
echo "$(date +%Y%m%d\ %H%M%S) $1" &>/dev/null > "$script_logs"
2017-08-22 01:49:27 +02:00
else
2017-12-24 14:25:39 +01:00
echo "$(date +%Y%m%d\ %H%M%S) $1" &>/dev/null >> "$script_logs"
2017-08-22 01:49:27 +02:00
fi
fi
2017-07-30 17:08:05 +02:00
}
2018-02-26 13:26:50 +01:00
# recherche commandes/paquets, $1 liste: cmd1|cmd2[>paquet] (séparées par espaces) ex: "gawk|mawk>gawk wget"
2018-01-26 17:05:36 +01:00
# si manque, return 1 & affiche commandes manquantes (si debian, ajout proposition paquet à installer)
2018-03-09 17:11:49 +01:00
f__requis(){ # 09/03/2018
2018-01-26 17:05:36 +01:00
local ENV_DEBIAN ireq table package commands command commandsMissing packagesMissing
2017-12-05 14:28:41 +01:00
2018-03-09 17:11:49 +01:00
if type -p dpkg &>/dev/null ; then
2018-03-09 07:12:34 +01:00
ENV_DEBIAN="oui" # debian
fi
if type -t f__info &>/dev/null; then
c_echo="f__info"
else
c_echo="echo -e" # f__info existe? sinon echo
fi
2018-01-26 17:05:36 +01:00
for ireq in $1; do # pour tous les composants de la liste $1
2018-03-09 07:12:34 +01:00
table=( ${ireq//>/ } ) # split sur > évite manip $IFS
2018-01-26 17:05:36 +01:00
2018-03-09 07:12:34 +01:00
commands=( ${table[0]//|/ } ) # split sur |
if [ "${table[1]}" ]; then
2018-01-26 17:05:36 +01:00
package=${table[1]}
else
2018-03-09 07:12:34 +01:00
package=${commands[0]} # pas de packages dans les options, donc idem commands[0]
2017-08-17 10:49:12 +02:00
fi
2018-01-26 17:05:36 +01:00
2018-03-09 07:12:34 +01:00
for command in "${commands[@]}"; do # pour toutes les commandes
2018-01-26 17:05:36 +01:00
if type -p "$command" &>/dev/null ; then
unset commandsMissing packagesMissing
break
else # inexistant
commandsMissing+="$command "
packagesMissing+="$package "
fi
done
2017-08-30 22:46:26 +02:00
done
2018-01-26 17:05:36 +01:00
# dédoublonnage & triage
2018-03-09 07:12:34 +01:00
commandsMissing=$( echo "$commandsMissing" | tr ' ' '\n' | sort --unique | tr '\n' ' ' )
packagesMissing=$( echo "$packagesMissing" | tr ' ' '\n' | sort --unique | tr '\n' ' ' )
2018-01-26 17:05:36 +01:00
# suppression éventuel espace final
commandsMissing=${commandsMissing% }
packagesMissing=${packagesMissing% }
# affichage final
if [ "$commandsMissing" ] && [ "$ENV_DEBIAN" ]; then
2018-03-05 03:52:18 +01:00
$c_echo "${RED}erreur critique, manquant: $STD$BOLD$commandsMissing" \
2018-01-26 17:05:36 +01:00
"vous devriez exécuter:$GREEN apt install $packagesMissing"
elif [ "$commandsMissing" ]; then
2018-03-05 03:52:18 +01:00
$c_echo "${RED}erreur critique, manquant: $STD$BOLD$commandsMissing"
2017-08-30 22:46:26 +02:00
fi
2018-01-26 17:05:36 +01:00
[ "$commandsMissing" ] && return 1 || return 0
}
# recherche paquet deb (scission f__requis), $1 liste paquets ("paquet1 paquet2"), si un paquet absent return 1
# assigne $deb_absent & $deb_present, si hors debian: return 1 mais $deb_present & $deb_absent vides
2018-03-09 17:11:49 +01:00
f__requis_deb(){ # 09/03/2018
2018-01-26 17:05:36 +01:00
local ireq
2018-03-09 07:12:34 +01:00
unset deb_present deb_absent
2018-03-09 17:11:49 +01:00
type -p dpkg &>/dev/null || return 1 # si pas dpkg, sortie return 0
2018-01-26 17:05:36 +01:00
for ireq in $1; do
LC_ALL=C dpkg --get-selections | grep -qE "^$ireq[[:space:]]+install" \
&& deb_present+="$ireq " || deb_absent+="$ireq "
done
deb_absent=${deb_absent% } # suppression éventuel espace final
deb_present=${deb_present% } # suppression éventuel espace final
[ "$deb_absent" ] && return 1
[ "$deb_present" ] && return 0
2017-08-30 22:46:26 +02:00
}
2017-07-30 17:08:05 +02:00
2018-02-24 11:59:27 +01:00
# $@=cmd à lancer en root avec su ou sudo. si $@ contient [':x:'] x=nombre de tentatives, 3 par défaut
# si sudo si possible sera utilisé.
# si su &2 redirigé sur &1
2018-01-15 09:52:05 +01:00
# si bash inexistant, return 2
2018-03-09 07:12:34 +01:00
f__sudo(){ # 06/03/2018
local nb sudo isudo options nbDefault=3
2017-10-13 21:58:51 +02:00
2018-01-26 19:56:39 +01:00
# détermination sudo possible
2017-10-09 20:19:07 +02:00
if sudo -v &>/dev/null && [ $EUID -ne 0 ] ; then
2018-03-09 07:12:34 +01:00
sudo="sudo su --preserve-environment -c "
2017-10-09 20:19:07 +02:00
else
2018-03-09 07:12:34 +01:00
sudo="su --preserve-environment -c "
2017-10-09 20:19:07 +02:00
fi
2018-01-26 19:56:39 +01:00
# extraction nb de tentatives éventuel
2018-03-09 07:12:34 +01:00
if [[ "$*" =~ :.{1,2}: ]]; then
nb="$*"
2018-01-15 09:52:05 +01:00
nb=${nb#*:}
nb=${nb%:*}
2018-03-09 07:12:34 +01:00
options=${*//:$nb:/ }
(( nb+1 )) 2>/dev/null || nb="$nbDefault" # test si numérique, sinon,
2018-01-15 09:52:05 +01:00
else
2018-01-26 19:56:39 +01:00
nb="$nbDefault"
2018-03-09 07:12:34 +01:00
options="$*"
2018-01-15 09:52:05 +01:00
fi
2018-01-26 19:56:39 +01:00
# lancement cmds
2018-02-24 11:59:27 +01:00
if [[ "$sudo" =~ ^sudo ]]; then
$sudo "$options"
else
for (( isudo=1 ; isudo<="$nb" ; isudo++ )); do
2018-03-09 07:12:34 +01:00
echo -en "\n[su] Mot de passe root : "
$sudo "$options" 2>/dev/null && break
2018-02-24 11:59:27 +01:00
[ "$isudo" == "$nb" ] && return 1
done
2018-03-09 07:12:34 +01:00
echo
2018-02-24 11:59:27 +01:00
fi
2017-10-09 20:19:07 +02:00
}
2018-03-09 07:12:34 +01:00
# test connectivité ping, $1=-4|-6, par défaut -4, return 1 si échec
f__test_cnx(){ # 08/03/2018
local proto="-4" cmd_ping iip timeout
declare -a ping_test
if [ "$1" == "-6" ]; then
proto="-6"
ping_test=(
2001:41d0:2:73d4::100 # ns10.fr.dns.opennic.glue
2a00:6d40:60:6a7f::1 # ns1.tus.it.dns.opennic.glue
2001:41d0:302:2100::949 # ns1.hau.fr.dns.opennic.glue
2001:910:800::12 # ns0.fdn.fr
2001:67c:2178:8::16 # conncheck.opensuse.org
2001:910:800::40 # ns1.fdn.fr
)
#~ [ -h "$( type -p ping6 2>/dev/null )" ] && cmd_ping="ping -6" || cmd_ping="ping6"
else
ping_test=(
51.254.141.22 # ns1.hau.fr.dns.opennic.glue
94.177.171.127 # ns1.tus.it.dns.opennic.glue
87.98.175.85 # ns10.fr.dns.opennic.glue
80.67.169.12 # ns0.fdn.fr
195.135.221.140 # conncheck.opensuse.org
80.67.169.40 # ns1.fdn.fr
)
#~ [ -h "$( type -p ping4 2>/dev/null )" ] && cmd_ping="ping -4" || cmd_ping="ping4"
fi
for timeout in 1 0; do # 2 passes, timeout 1s, si fail, timeout standard
cmd_ping="ping -c1 -w$timeout"
for iip in "${ping_test[@]}"; do
if eval "$cmd_ping" "$iip" &>/dev/null ; then
return 0 # sortie quand ok
break 2
else
echo -e "\t ip de test connectivité en échec ($iip)" 1>&2
fi
done
done
return 1 # sortie en échec
}
2018-02-27 09:31:41 +01:00
# $1=NOM de la variable à trimer (variable et non $variable), [$2=left|right|all], all si vide
# gain vitesse en test: 40 à 75% par rapport à '| xargs'
# var=$( function ) presque 2x lent que eval "var="
2018-03-09 07:12:34 +01:00
f__trim(){ # 07/03/2018
2018-02-27 09:31:41 +01:00
local trim=${!1}
2018-03-09 07:12:34 +01:00
2018-02-27 09:31:41 +01:00
[[ "$2" == right || "$2" == all || -z "$2" ]] && trim="${trim%${trim##*[^[:space:]]}}" # fin right
[[ "$2" == left || "$2" == all || -z "$2" ]] && trim="${trim#${trim%%[^[:space:]]*}}" # début left
eval "$1=\"$trim\""
2018-02-20 03:59:50 +01:00
}
2018-03-09 22:45:00 +01:00
# $1 chaîne où convertir les unités
f__unit_french(){ # 08/03/2018
2018-03-09 07:12:34 +01:00
local display
display=${1//G/Go}
display=${display//M/Mo}
display=${display//K/ko}
echo "$display"
}
2018-01-26 19:56:39 +01:00
# $1=nombre à convertir en ko, affiche ko ou Mo ou Go
2018-03-09 07:12:34 +01:00
f__unit_human(){ # 05/03/2018
2018-01-26 19:56:39 +01:00
echo -n "$( awk ' {
2017-12-05 14:28:41 +01:00
if ( $1<1024 ) {unit="ko"; printf "%d%s", $1, unit; exit}
if ( $1<1024*1024 && $1>=1024 ) {unit="Mo"; printf "%d%s", $1/1024, unit}
else {unit="Go"; printf "%.1f%s", $1/1024/1024, unit}
2018-02-23 17:07:39 +01:00
}' <<< "$1" )"
2017-12-05 14:28:41 +01:00
}
2017-12-05 15:57:02 +01:00
# user ayant initié la session graphique, assigne $fu_user
# return 1 sur échec identification user, return 2 sur absence home/
# gestion variable environnement user avec: USER_INSTALL=<user> script
2018-03-09 07:12:34 +01:00
f__user(){ # 08/03/2018
local user userid root_login
2017-12-05 15:57:02 +01:00
root_login="$(grep ':0:' /etc/passwd | cut -d':' -f1)" || root_login="root"
if [ "$USER_INSTALL" ]; then # user via variable environnement, moyen d'injecter root si pb
fu_user="$USER_INSTALL";
return 0
elif [[ "$TERM" =~ linux ]]; then #debian 9 recovery ou nomodeset TERM=linux
if [ "$USER" ]; then
user="$USER"
elif [ "$EUID" -eq 0 ]; then
fu_user="$root_login"
return 0
fi
fi
if [ "$SUDO_UID" ]; then
userid="$SUDO_UID";
elif grep -qEo '[0-9]+' <<< "$XDG_RUNTIME_DIR" ; then
2018-02-23 17:07:39 +01:00
userid=$( grep -Eo '[0-9]+' <<< "$XDG_RUNTIME_DIR" | cut -d'/' -f4 )
2018-03-09 07:12:34 +01:00
else
2018-02-23 17:07:39 +01:00
userid=$( grep -Eo '[0-9]+' <<< "$XAUTHORITY" | cut -d'/' -f4 )
2017-12-05 15:57:02 +01:00
fi
2018-03-09 07:12:34 +01:00
[ "$userid" ] && user=$( grep "$userid" /etc/passwd | cut -d ":" -f 1 )
2017-12-05 15:57:02 +01:00
if [ "$user" ] && [ "$user" != "$root_login" ]; then
fu_user="$user"
return 0
else
if [ "$SUDO_USER" ] && [ "$SUDO_USER" != "$root_login" ]; then
user="$SUDO_USER";
2018-02-26 13:26:50 +01:00
elif who | grep -qv 'root'; then
user=$( who | grep -v 'root' | head -n1 | cut -d ' ' -f1 ); # who | grep -v 'root' | awk 'FNR==1{print $1}'
2018-03-09 07:12:34 +01:00
else
user=$( grep -m1 'hourly.*get[A-Z].*\.anacrontab.*\.config/anacron/spool' /etc/crontab | cut -d' ' -f2 );
2017-12-05 15:57:02 +01:00
fi
fi
fu_user="$user"
[ "$fu_user" ] || return 1
[ -d "/home/$fu_user" ] || return 2
return 0
}
2017-10-31 12:12:03 +01:00
# $1='-l' comptage ligne dans variable $2, affiche quantité
2017-11-10 12:47:20 +01:00
# $1='-w' comptage dans variable $2 des mots
# $1='-wv' comptage dans variable $2, des mots $3, affiche quantité
2017-11-05 06:33:36 +01:00
# f__wcv -l $var ; f__wcv -w $var ; f__wcv -wv $var "mot"
2018-03-09 17:11:49 +01:00
f__wcv(){ # 09/03/2018
2018-03-01 08:18:19 +01:00
2018-03-09 17:11:49 +01:00
[[ "$1" =~ -l|-wv|-w ]] || echo "erreur f__wcv \$1 ($1) incorrect"
2018-03-01 08:18:19 +01:00
if [ "$1" == "-l" ]; then
grep -cEv '^[[:space:]]*$' <<< "$2" # (wc -l compterait 1 pour une variable vide)
elif [ "$1" == "-w" ]; then
result=$( xargs <<< "$2" | grep -o '[[:graph:]][[:blank:]][[:graph:]]' | grep -c ' ' )
[ "$result" -ne 0 ] && result=$(( result+1 ))
echo "$result"
elif [ "$1" == "-wv" ]; then
grep -o "$3" <<< "$2" | grep -c .
fi
2017-10-31 06:52:36 +01:00
}
2017-12-24 20:00:08 +01:00
# test wget, $1=url à tester, $2=''|print|loc|test
# par défaut, sortie du script (même si url testée ok) avec affichage erreur ou ok
2017-12-05 14:28:41 +01:00
# si $2=print affiche url testée & entêtes http & location, return 0
# si $2=loc affiche seulement location, return 0
# si $2=test return 0 si ok, return 1 si KO
2018-02-23 17:07:39 +01:00
f__wget_test(){ # 22/02/2018
2017-12-24 20:00:08 +01:00
local file_test_wget="/tmp/testWget-$script" retourWget retourHttp location
2017-12-05 14:28:41 +01:00
2017-12-24 20:00:08 +01:00
wget -Sq --timeout=5 --tries=2 --user-agent="$user_agent" --spider --save-headers "$1" &>"$file_test_wget"
2017-09-29 20:27:53 +02:00
retourWget="$?"
2017-12-05 14:28:41 +01:00
[ "$retourWget" == 1 ] && retourWget="1: code erreur générique"
[ "$retourWget" == 2 ] && retourWget="2: parse erreur (ligne de commande?)"
[ "$retourWget" == 3 ] && retourWget="3: erreur Entrée/sortie fichier"
[ "$retourWget" == 4 ] && retourWget="4: défaut réseau"
[ "$retourWget" == 5 ] && retourWget="5: défaut vérification SSL"
[ "$retourWget" == 6 ] && retourWget="6: défaut authentification"
[ "$retourWget" == 7 ] && retourWget="7: erreur de protocole"
[ "$retourWget" == 8 ] && retourWget="8: réponse serveur en erreur"
2017-12-11 23:00:03 +01:00
retourHttp=$( grep -i 'HTTP/' "$file_test_wget" | tr -d '\n' | xargs )
location=$( grep -i 'location' $file_test_wget | xargs )
2017-11-06 13:25:09 +01:00
if [ "$2" == "test" ]; then
2017-12-24 14:25:39 +01:00
rm -f "$file_test_wget"
2017-12-05 14:28:41 +01:00
# spécial maintenance frama.link, pas de redirection sur page status framalink
2018-02-23 17:07:39 +01:00
grep -q '303' <<< "$retourHttp" && return 1 # 303 See Other
2017-11-06 13:25:09 +01:00
[ "$retourWget" == "0" ] && return 0 || return 1
fi
2017-09-09 20:26:43 +02:00
if [ "$2" == "print" ]; then
2017-12-05 14:28:41 +01:00
if [ "$retourWget" != "0" ]; then
2018-01-24 17:29:41 +01:00
echo " erreur wget: erreur $RED$retourWget"
echo -e "$BLUE $1$STD\t$RED $retourHttp$STD"
2017-09-09 20:26:43 +02:00
else
2018-01-24 17:29:41 +01:00
echo -e "$BLUE $1$STD\t$GREEN $retourHttp$STD"
2017-09-09 20:26:43 +02:00
fi
fi
2017-09-25 23:38:39 +02:00
if [ "$2" == "print" ] || [ "$2" == "loc" ]; then
2018-01-24 17:29:41 +01:00
[ "$location" ] && echo -n "$YELLOW $location" || echo -n "$YELLOW no location"
2017-10-09 20:19:07 +02:00
echo "$STD"
2017-12-24 14:25:39 +01:00
rm -f "$file_test_wget"
2017-09-25 23:38:39 +02:00
return 0
2017-08-28 10:09:47 +02:00
fi
2017-12-05 14:28:41 +01:00
if [ "$retourWget" != "0" ]; then
2017-12-24 20:00:08 +01:00
rm -f "$file_test_wget"
2017-12-24 14:25:39 +01:00
f__error "wget, erreur $retourWget" "$1" "$YELLOW$retourHttp" "$location"
2017-12-11 23:00:03 +01:00
echo -e "$RED erreur wget, $retourWget \n $1 \n $YELLOW$retourHttp \n $location$STD" # pour les diags
return 1
2017-08-28 10:09:47 +02:00
fi
2018-02-23 17:07:39 +01:00
if grep -q '200' <<< "$retourHttp"; then
2017-12-11 23:00:03 +01:00
echo -e "$GREEN\ntout est ok, réessayer$STD\n"
2017-09-25 23:38:39 +02:00
fi
2017-12-24 20:00:08 +01:00
rm -f "$file_test_wget"
2017-08-28 10:09:47 +02:00
exit 0
2017-08-07 21:58:22 +02:00
}
2018-04-08 16:34:59 +02:00
f_affichage(){ # 12/03/2018
2018-01-24 17:29:41 +01:00
local affichage_text=" _ ___ __
__ _ ___| |_|_ _|_ __ / _| ___
/ _' |/ _ \ __|| || '_ \| |_ / _ \
| (_| | __/ |_ | || | | | _| (_) |
\__, |\___|\__|___|_| |_|_| \___/
|___/"
2017-12-24 14:25:39 +01:00
2018-03-09 17:11:49 +01:00
(( x_logo == 1 )) && return
x_logo=1
2018-04-08 16:34:59 +02:00
clear 2>/dev/null || tput clear 2>/dev/null
2018-01-24 17:29:41 +01:00
echo -e "$BLUE$affichage_text$YELLOW version $version - $date$STD\n"
2017-12-02 11:05:56 +01:00
}
2017-12-14 20:07:23 +01:00
# $1=type de titre var|cmd|sans|+:text|+:vide, $2 variable à afficher [$3 titre] [$4 commentaire]
2017-12-01 21:50:07 +01:00
# $1: cmd->`titre`, var->**titre**, sans: pas de titre
2017-11-15 13:02:18 +01:00
# :text ajouté, affiche le text en liste (avec puce)
2017-12-01 21:50:07 +01:00
# :vide bypass le test de contenu $2, affiche 'vide', si besoin, en liste
2017-12-03 13:48:03 +01:00
# passage en paramètre VARIABLE et pas $variable
2017-12-01 21:50:07 +01:00
# un test si variable $2 est vide est fait sauf ':vide'
2018-02-22 01:26:29 +01:00
# un test si variable $2 contient 'nofile' (non trouvé par f_grep_file), remplacé par 'fichier non trouvé'
2017-12-13 03:15:07 +01:00
# f_dspl "variable" "type" "titre" "commentaire"
2018-02-22 01:26:29 +01:00
f_dspl(){ # 21/02/2018
2017-12-03 13:48:03 +01:00
local display='' toDisplay
2017-12-01 21:50:07 +01:00
2017-12-29 12:36:55 +01:00
[ "$text" ] && echo -en "$text" >> "$file_output" # flush, avant fonction, de $text parent
2017-10-21 11:07:11 +02:00
unset text
2017-12-01 21:50:07 +01:00
2018-02-20 03:59:50 +01:00
[[ "$2" || "$1" =~ :vide ]] || return 0 # test si contenu dans $2 ou option :vide, sinon retour
2017-12-14 13:55:05 +01:00
toDisplay="$2"
2017-11-20 15:27:48 +01:00
[ "$toDisplay" ] || toDisplay="vide" # cas si :vide
2017-12-14 13:55:05 +01:00
# traitement ligne de titre
2017-12-13 03:15:07 +01:00
[[ "$1" =~ sans|var|cmd ]] || display=" **⚡ erreur f_dspl \$1 ($2 $3) ⚡** \n" # test $1 valide
2017-12-01 21:50:07 +01:00
[[ "$1" =~ "var" ]] && display="**$3**" # type var, titre en gras
[[ "$1" =~ "cmd" ]] && display="\`$3\`" # type cmd, titre entre backtick
2017-11-20 15:27:48 +01:00
[ "$4" ] && display+="$spc5( $4 )" # +$4 en gras avec 5 espaces insécables avant
2017-12-01 21:50:07 +01:00
[ "$1" != "sans" ] && display+=" \n"
[[ "$1" == "sans" && "$3$4" ]] && display+=" \n"
2017-11-20 15:27:48 +01:00
# traitement contenu
2017-12-01 21:50:07 +01:00
if [ "$toDisplay" == "nofile" ]; then # nofile renvoyé par f_grep
2018-02-22 01:26:29 +01:00
display+="\n* fichier non trouvé \n\n"
2018-02-20 03:59:50 +01:00
elif [[ "$1" =~ :text ]]; then
2017-11-20 15:27:48 +01:00
display+="\n* $toDisplay \n"
2017-11-10 21:06:23 +01:00
else
display+='``` \n'
2017-11-17 07:27:10 +01:00
display+="$toDisplay \n"
2017-12-14 13:55:05 +01:00
display+='``` \n\n'
2017-11-10 21:06:23 +01:00
fi
2017-12-29 12:36:55 +01:00
echo -en "$display" >> "$file_output"
2017-10-21 11:07:11 +02:00
}
2017-12-14 20:07:23 +01:00
# $1=variable à afficher en alerte/info, [$2 alert|info] type de message, alert par défaut
2017-11-10 12:47:20 +01:00
# un test si variable $1 est vide ou non est fait
2018-03-09 07:12:34 +01:00
f_dspl_alrt(){ # 07/03/2018
2017-11-15 13:02:18 +01:00
local display type
2018-03-09 07:12:34 +01:00
[ "$1" ] || return 0 # test si contenu dans $1
2017-11-15 13:02:18 +01:00
# flush, avant fonction, de $text parent
2017-12-29 12:36:55 +01:00
[ "$text" ] && echo -en "$text\n" >> "$file_output"
2017-11-09 11:43:42 +01:00
unset text
2017-11-21 22:44:56 +01:00
2018-03-09 07:12:34 +01:00
type="alert" # alert par défaut
2017-11-15 13:02:18 +01:00
[[ "$2" =~ info ]] && type="info"
2018-01-28 08:16:30 +01:00
[ "$type" == "alert" ] && display="> ↯ $1 \n\n"
[ "$type" == "info" ] && display=" ☛ $1 \n\n"
2017-12-29 12:36:55 +01:00
echo -en "$display" >> "$file_output" # flush fonction
2017-10-26 07:05:22 +02:00
}
2018-03-09 07:12:34 +01:00
# $1=LISTE fichier(s) à grepper, [$2]: N &| novide &| notitre &| noinexist &| ligneVide &| date &| commentXY &| sources
2018-01-28 08:16:30 +01:00
# si aucun fichier dans la liste, retour indication: 'nofile|vide|inexistant'
2018-02-22 01:26:29 +01:00
# exemple cumul option: "10 novide notitre lignevide" (espace obligatoire, pas d'autre séparateur)
2018-03-09 07:12:34 +01:00
# /!\ protéger les chemins avec ", ex: f_grep_file "${toScrut[*]}".
2018-01-28 08:16:30 +01:00
# option largeur, des chiffres AU DÉBUT!
# option 'novide', pas d'indication vide
# option 'notitre', pas d'énumération de fichier greppé (destiné à un seul fichier)
# option 'noinexist', pas de titre si fichier inexistant
2017-12-02 18:24:34 +01:00
# option 'lignevide', pas de suppression des lignes vides
# option 'date', date de modification du fichier
2018-01-28 08:16:30 +01:00
# option 'commentXY', A LA FIN, commentaire supplémentaire à filtrer, ex: comment//
2018-03-09 07:12:34 +01:00
# option 'sources', les .sources avec largeur fixe 1ère colonne (format deb822)
# option 'sources', affiche les fichiers !(*.sources) en colonne selon leur largeur maxi
2018-01-28 08:16:30 +01:00
# commande de base: grep -Ersv '^#|^$' file|dossier "options"
2018-03-09 07:12:34 +01:00
f_grep_file(){ # 08/03/2018
local motifBase="^[[:blank:]]*#" motif file content largeur un deux trois quatre cinq six sept huit reste
local col1=0 col2=0 col3=0 col4=0 col5=0 col6=0 col7=0 col8=0 display=''
2018-01-28 08:16:30 +01:00
motif="$motifBase"
2018-03-09 07:12:34 +01:00
if [[ ! "$2" =~ lignevide ]]; then
motif+="|^[[:blank:]]*$"
fi
if [[ "$2" =~ comment ]]; then
motif+="|^[[:blank:]]*${2##*comment}" # conservation symboles de commentaires à la fin
fi
2017-11-10 12:47:20 +01:00
for file in $1; do
2017-11-27 06:26:24 +01:00
# contenu
2017-12-04 09:33:29 +01:00
content=$( grep -Ersv "$motif" "$file" 2>&1)
2018-01-28 08:16:30 +01:00
if [[ "$2" =~ ^[0-9] ]]; then # si $2 contient des chiffres: (largeur) en tête
2017-12-04 09:33:29 +01:00
largeur=${2%% *}
2018-01-28 08:16:30 +01:00
content=$( awk -v larg="$largeur" '{ printf "%-"larg"s",$1; $1=""; print $0 }' <<< "$content" )
2017-11-10 12:47:20 +01:00
fi
2018-03-09 07:12:34 +01:00
if [[ "$2" =~ sources && "$file" =~ \.sources$ ]]; then # nouveau format sources deb822
content=$( grep -Ersv "$motifBase" "$file" 2>&1) # conservation lignes vides
content=${content#$'\n'} # suppression éventuelle ligne vide au début
content=$( awk '{ printf "%-12s",$1; $1=""; print $0 }' <<< "$content" ) # largeur fixe première colonne
elif [[ "$2" =~ sources ]]; then # fichier sources.list ou autres genre fstab
2017-12-07 18:06:12 +01:00
content=$(
2018-03-09 07:12:34 +01:00
while read -r un deux trois quatre cinq six sept huit reste; do
2017-12-07 18:06:12 +01:00
[ ${#un} -gt "$col1" ] && col1=$(( ${#un}+1 ))
[ ${#deux} -gt "$col2" ] && col2=$(( ${#deux}+1 ))
[ ${#trois} -gt "$col3" ] && col3=$(( ${#trois}+1 ))
[ ${#quatre} -gt "$col4" ] && col4=$(( ${#quatre}+1 ))
2018-03-09 07:12:34 +01:00
[ ${#cinq} -gt "$col5" ] && col5=$(( ${#cinq}+1 ))
[ ${#six} -gt "$col6" ] && col6=$(( ${#six}+1 ))
[ ${#sept} -gt "$col7" ] && col7=$(( ${#sept}+1 ))
[ ${#huit} -gt "$col8" ] && col8=$(( ${#huit}+1 ))
2017-12-07 18:06:12 +01:00
done <<< "$content"
2018-03-09 07:12:34 +01:00
while read -r un deux trois quatre cinq six sept huit reste; do
printf "%-${col1}s %-${col2}s %-${col3}s %-${col4}s %-${col5}s %-${col6}s %-${col7}s %-${col8}s %s \n" "$un" "$deux" "$trois" "$quatre" "$cinq" "$six" "$sept" "$huit" "$reste"
2017-12-07 18:06:12 +01:00
done <<< "$content"
)
fi
2018-03-09 07:12:34 +01:00
if [ -d "$file" ]; then # si répertoire, ajout / final, joli
file+='/'
fi
2017-11-27 06:26:24 +01:00
content=${content//$file} # joli, suppression de $file dans les noms de fichiers entete grep
# mise en forme
2017-12-04 09:33:29 +01:00
if [[ ! "$2" =~ notitre ]]; then # titre
2017-11-27 06:26:24 +01:00
if [ -e "$file" ]; then
2017-12-04 09:33:29 +01:00
if [[ "$2" =~ "date" ]]; then
2017-12-09 00:19:29 +01:00
display+=" => $file, date de modification: $( date -r $file '+%d/%m/%Y %H:%M %z' ) \n"
2017-11-27 15:00:49 +01:00
else
2017-12-09 00:19:29 +01:00
display+=" => $file \n"
2017-12-04 09:33:29 +01:00
fi
elif [[ ! "$2" =~ "noinexist" ]]; then
if touch -c $file 2>/dev/null ; then
2017-12-09 00:19:29 +01:00
display+=" => $file: inexistant"$'\n\n'
2017-12-04 09:33:29 +01:00
else
2017-12-09 00:19:29 +01:00
display+=" => $file: Permission non accordée"$'\n\n'
2017-11-27 15:00:49 +01:00
fi
2017-11-27 06:26:24 +01:00
fi
fi
if [ "$content" ]; then
display+="$content"$'\n\n'
elif [[ ! "$2" =~ novide && -e "$file" ]]; then
display+=" ‣ vide"$'\n\n'
fi
2017-11-10 12:47:20 +01:00
done
2018-03-09 07:12:34 +01:00
#~ display=${display%%[[:space:]]} # suppression dernier \n
display=${display%$'\n'} # suppression dernier \n
if [ -z "$display" ]; then
display="nofile" # si display vide, inscription 'nofile'
fi
2017-11-14 09:18:06 +01:00
echo -en "$display"
2017-11-10 12:47:20 +01:00
}
2018-03-03 23:48:13 +01:00
f_help(){ # 03/03/2018
2018-01-24 17:29:41 +01:00
local ligne help=(
"-----------------------------------------------------------------------"
2018-03-05 03:52:18 +01:00
"${GREEN}./getInfo$STD : exécution script"
"${GREEN}getInfo$STD : exécution script installé dans le système"
2018-02-07 13:27:59 +01:00
" "
2018-01-24 17:29:41 +01:00
"$BOLD""options:$STD"
"$BLUE -c$STD : (catégorie) menu sélection catégorie d'analyse"
"$BLUE -cs$STD : catégorie système $BLUE-cs$STD : catégorie configuration"
"$BLUE -cr$STD : catégorie réseau $BLUE-ca$STD : catégorie analyse"
"$BLUE -j$STD : (journaux) analyse démarrage système, log Xorg, kernel et système, catégorie -ca"
"$BLUE -l$STD : (list) afficher le rapport markdown existant"
"$BLUE -p$STD : (paste) exporte le rapport markdown existant, durée standard du paste 7 jours"
"$BLUE -us$STD : upgrade spécial du script en place (sans être installé)"
2018-03-03 23:48:13 +01:00
"$BLUE --debug$STD : messages d'erreur (stderr) logués et exportés avec le rapport"
2018-01-24 17:29:41 +01:00
"$BLUE --ip$STD : affiche ip publique (ipv4/ipv6), pas de rapport markdown"
"$BLUE --mac$STD : affiche adresses Mac, pas de rapport markdown"
2018-03-03 23:48:13 +01:00
"$BLUE --rc$STD : gfetch, affiche un résumé, destiné à l'identification et appelé depuis .batchrc"
2018-01-24 17:29:41 +01:00
"$BLUE --serial$STD : affiche n° série disques, batterie et châssis, pas de rapport markdown"
"$BLUE --ssid$STD : affiche configurations ssid, pas de rapport markdown,$RED root & NetworkManager$STD requis"
2018-03-05 03:52:18 +01:00
"$BLUE -t$STD${GREEN}n$STD : durée de conservation du paste de$GREEN n$STD jour(s)"
2018-01-24 17:29:41 +01:00
"-----------------------------------------------------------------------"
"$BLUE./$script -i$STD : installation du script dans le système $RED(root)$STD"
"$BLUE$script -h$STD, --help : affichage aide"
2018-03-03 23:48:13 +01:00
"$BLUE$script --irc$STD : installation gfetch $RED(root)$STD"
2018-01-24 17:29:41 +01:00
"$BLUE$script -r$STD, --remove : désinstallation du script $RED(root)$STD"
2018-03-03 23:48:13 +01:00
"$BLUE$script --rrc$STD : désinstallation gfetch $RED(root)$STD"
2018-01-24 17:29:41 +01:00
"$BLUE$script -u$STD, --upgrade : mise à jour script"
"$BLUE$script -v$STD, --version : version du script"
)
tput cuu1 # une ligne plus haut
for ligne in "${help[@]}"; do
echo -e " $ligne"
2017-11-22 20:33:37 +01:00
done
2017-12-24 14:25:39 +01:00
echo -e "$STD\n plus d'infos: $GREEN$url_notice\n$STD"
2017-08-30 01:04:45 +02:00
}
2017-12-16 23:31:32 +01:00
# $1=texte à épurer
2018-02-09 13:14:43 +01:00
f_lifting(){ # 08/02/2018
2017-12-16 23:31:32 +01:00
local text="$1"
text=${text/ System Controller Hub}
text=${text/ Advanced Micro Devices, Inc.}
text=${text/ Electronics Co., Ltd.}
text=${text/ Co., Ltd.}
text=${text/ Semiconductor Co., Ltd.}
text=${text/ Semiconductor Corp.}
text=${text/ Series Family /Series}
text=${text/ Series Chipset Family /Series}
2018-02-09 06:07:03 +01:00
text=${text/ High Definition / HD }
2017-12-16 23:31:32 +01:00
text=${text/ Semiconductor}
text=${text/ Computer}
text=${text/ COMPUTER}
text=${text/ Industries}
text=${text// Limited}
text=${text//, Inc.}
text=${text//, Inc}
text=${text// Inc.}
text=${text// INC.}
text=${text// Corporation}
text=${text// Corp.}
text=${text// Co.}
text=${text//, Ltd}
text=${text//, Ltd.}
text=${text// Ltd.}
text=${text//\(R\)}
text=${text//\(TM\)}
text=${text//\(r\)}
text=${text//\(tm\)}
text=${text// / }
echo "$text"
}
2018-01-28 08:16:30 +01:00
# $1=preferences|sources, affiche fichiers ignorés par apt
f_policy(){ # 27/01/2018
local policy
policy=$( LC_ALL=C apt-cache --quiet=0 policy foo 2>&1 | grep 'Ignoring file' )
policy=$( awk -v motif="$1" '
$0 ~ motif { print $7$4 }
' <<< "$policy" )
policy=${policy//\'}
echo "$policy"
}
2017-12-15 01:18:35 +01:00
# f_prnt "1||2|3|l1|l2|l3|tit1|tit2|tit3|hl|quote|flush|code" "texte" '[CONDITION test]'
2017-12-14 13:55:05 +01:00
# $1: 1|2|3 indentation, liste à puce, une puce par ligne
2017-12-06 15:00:33 +01:00
# l1|l2|l3 ligne, indentation, avec espaces
2017-12-15 01:18:35 +01:00
# tit1|tit2|tit3
2017-12-02 18:24:34 +01:00
# quote|hl|flush
2018-03-02 06:06:51 +01:00
# $2 texte à afficher, pas de contrôle si texte null ou présent
2017-12-03 14:34:44 +01:00
# $3 test éventuel, Si CONDITION ok -> affichage
# ATTENTION aux éventuelles collision $x dans ce cas:
# "[ \"$1\" != \"notitre\" ]" ou "[ $1 != notitre ]" (attention au manque de ")
2017-12-13 03:15:07 +01:00
# flush (f_prnt flush) inutile si f_d(x) final
2017-12-01 21:50:07 +01:00
# $1 type, $2 texte, [$3] test /!\ assigne la variable parent $text
2018-03-09 07:12:34 +01:00
f_prnt(){ # 05/03/2018
2017-12-01 21:50:07 +01:00
local preline='' line='' endline=" \n"
2018-03-09 07:12:34 +01:00
[[ "$1" =~ tit ]] && preline="\n\n"
[[ "$1" == tit1 ]] && preline+="# "
[[ "$1" == tit2 ]] && preline+="## "
[[ "$1" == tit3 ]] && preline+="### "
[[ "$1" =~ tit ]] && endline+="\n"
[[ "$1" == 1 ]] && line="$( sed -E 's/(.*)/* \1 /' <<< "$2" )"
[[ "$1" == 2 ]] && line="$( sed -E 's/(.*)/ * \1 /' <<< "$2" )"
[[ "$1" == 3 ]] && line="$( sed -E 's/(.*)/ * \1 /' <<< "$2" )"
[[ "$1" == l1 ]] && line="$( sed -E 's/(.*)/\1/ ' <<< "$2" )"
[[ "$1" == l2 ]] && line="$( sed -E 's/(.*)/ \1/ ' <<< "$2" )"
[[ "$1" == l3 ]] && line="$( sed -E 's/(.*)/ \1/ ' <<< "$2" )"
[[ "$1" == quote ]] && preline="> "
[[ "$line" ]] || line="$2" # utilisation $2 sans traitement à faire
2017-12-01 21:50:07 +01:00
if [[ "$3" ]]; then
2018-03-09 07:12:34 +01:00
eval "$3" || return 0 # évaluation de la CONDITION, si erreur: sortie
2017-12-01 21:50:07 +01:00
fi
if [[ "$1" == "hl" ]]; then # <hl>
2017-12-14 13:55:05 +01:00
text+="\n---\n"
elif [[ "$1" == "code" ]]; then # ```
2017-12-11 16:21:06 +01:00
text+='```\n'
2017-12-01 21:50:07 +01:00
elif [[ "$1" ]]; then
text+="$preline$line$endline" # ligne formatée
else
text+="\n" # newline
fi
if [[ "$1" == "flush" ]]; then
2017-12-29 12:36:55 +01:00
echo -en "$text" >> "$file_output"
2017-12-01 21:50:07 +01:00
unset text
fi
}
2017-12-14 20:07:23 +01:00
# $1=file à parser, [$2=marge] margin left 2 espaces
2018-01-26 19:56:39 +01:00
# tout en bash regex par défaut non-greedy (non gourmand) comme sed ou awk
2017-12-13 03:15:07 +01:00
# contrainte markdown:
# l'italique avec _ ou * n'est pas géré, trop d'interférences potentielles
# liste niveau2: 3 ou 4 caractères, niveau3: 6 ou 8 caractères, puce * ou -
2018-03-09 07:12:34 +01:00
f_prnt_md(){ # 08/03/2018
2017-12-13 03:15:07 +01:00
local display display2 ligne margin
2018-03-09 07:12:34 +01:00
2017-12-13 03:15:07 +01:00
if [ ! -f "$1" ]; then
f__info "pas de rapport à afficher, vous devez lancer une analyse auparavant:" \
"$GREEN$script -l$BLUE ou afficher l'aide $GREEN$script -h"
return 0
fi
2018-03-09 07:12:34 +01:00
if [ "$( stat -c %s "$1" )" -gt 100000 ]; then # si taille en octets > 100ko pager
2017-12-13 03:15:07 +01:00
pager "$1" || less "$1" || more "$1"
return
fi
2018-03-09 07:12:34 +01:00
if [ "$2" == "marge" ]; then
margin=" "
fi
display=$( < "$1" )
2017-12-13 03:15:07 +01:00
# code
display=${display//\`\`\`/------------} # transforme ``` en ---, plus visibles
2018-03-09 07:12:34 +01:00
# traitement par lignes, à là sed, obligatoire pour les titres #
# plus simple pour les multi-patterns, sinon matches multilignes délicats à gérer en cas d'impairage
2017-12-13 03:15:07 +01:00
while read -r ligne; do
2018-03-03 07:40:41 +01:00
[[ "$ligne" == "------------" && "$operation" == "rc" ]] && continue
2018-03-09 07:12:34 +01:00
ligne=${ligne//\\/\\\\} # re echappement des antislash, utile pour efiboot
2017-12-13 03:15:07 +01:00
# # TITRE 1 red
2018-03-09 07:12:34 +01:00
[[ "$ligne" =~ ^(#[^#].*)$ ]] && ligne="\x1B[31m${BASH_REMATCH[1]}\x1B(B\x1B[m"
2017-12-13 03:15:07 +01:00
# ## TITRE 2 blue
2018-03-09 07:12:34 +01:00
[[ "$ligne" =~ ^(#{2}[^#].*)$ ]] && ligne="\x1B[34m${BASH_REMATCH[1]}\x1B(B\x1B[m"
2017-12-13 03:15:07 +01:00
# ### TITRE 3 green
2018-03-09 07:12:34 +01:00
[[ "$ligne" =~ ^(#{3}[^#].*)$ ]] && ligne="\x1B[32m${BASH_REMATCH[1]}\x1B(B\x1B[m"
2017-12-13 03:15:07 +01:00
# #### TITRE 4 yellow
2018-03-09 07:12:34 +01:00
[[ "$ligne" =~ ^(#{4}[^#].*)$ ]] && ligne="\x1B[33m${BASH_REMATCH[1]}\x1B(B\x1B[m"
2017-12-13 03:15:07 +01:00
# interne message alert, red
2018-03-09 07:12:34 +01:00
[[ "$ligne" =~ ( ↯ .*)$ ]] && ligne="\x1B[31m${BASH_REMATCH[1]}\x1B(B\x1B[m"
2017-12-13 03:15:07 +01:00
# interne message indo, green
2018-03-09 07:12:34 +01:00
[[ "$ligne" =~ ( ☛ .*)$ ]] && ligne="\x1B[32m${BASH_REMATCH[1]}\x1B(B\x1B[m"
2017-12-13 03:15:07 +01:00
# **gras**
while [[ "$ligne" =~ (.*)\*{2}(.*)\*{2}(.*) ]]; do
2018-03-09 07:12:34 +01:00
ligne="${BASH_REMATCH[1]}\x1B[1m${BASH_REMATCH[2]}\x1B(B\x1B[m${BASH_REMATCH[3]}"
2017-12-13 03:15:07 +01:00
done
# ` backtick en italique
while [[ "$ligne" =~ (.*)\`([^\`].*)\`(.*) ]]; do
2018-03-09 07:12:34 +01:00
ligne="${BASH_REMATCH[1]}\x1B[3m${BASH_REMATCH[2]}\x1B(B\x1B[m${BASH_REMATCH[3]}"
2017-12-13 03:15:07 +01:00
done
# puces niveau 1
ligne=${ligne/#\*[^*]/• }
ligne=${ligne/#-[^-]/• }
# puces niveau 2
2018-03-09 07:12:34 +01:00
[[ "$ligne" =~ ^([[:space:]]{3,4})\*(.*)$ ]] && ligne="${BASH_REMATCH[1]}► ${BASH_REMATCH[2]}"
[[ "$ligne" =~ ^([[:space:]]{3,4})-(.*)$ ]] && ligne="${BASH_REMATCH[1]}► ${BASH_REMATCH[2]}"
2017-12-13 03:15:07 +01:00
# puces niveau 3
2018-03-09 07:12:34 +01:00
[[ "$ligne" =~ ^([[:space:]]{6,8})\*(.*)$ ]] && ligne="${BASH_REMATCH[1]}◾ ${BASH_REMATCH[2]}"
[[ "$ligne" =~ ^([[:space:]]{6,8})-(.*)$ ]] && ligne="${BASH_REMATCH[1]}◾ ${BASH_REMATCH[2]}"
2018-03-03 07:40:41 +01:00
display2+="$margin""$ligne"$'\n'
2017-12-13 03:15:07 +01:00
done <<< "$display"
2018-03-03 07:40:41 +01:00
echo -e "${display2%$'\n'}"
2017-12-13 03:15:07 +01:00
}
2017-12-13 20:44:22 +01:00
# $1=modules [$2=repertoire spécifique de recherche], affiche emplacements et modules trouvés
2018-03-09 07:12:34 +01:00
f_search_ko(){ # 06/03/2018
local dir motif emplacement imod mod_ko
2017-12-13 20:44:22 +01:00
2018-03-09 07:12:34 +01:00
dir="/lib/modules/$( uname -r )"
if [ "$1" ]; then
motif="$1"
else
return 1
fi
if [ "$2" ]; then
dir="$2"
fi
2017-12-13 20:44:22 +01:00
motif="($motif|${motif//_/-})\.ko"
emplacement=$( du -a "$dir" | grep -Ew "$motif" )
if [ "$emplacement" ]; then
IFS=$'\n'
2018-02-09 06:07:03 +01:00
for imod in $emplacement; do
imod=${imod#*/}
mod_ko+=" => /$imod"$'\n'
done
2017-12-13 20:44:22 +01:00
IFS="$IFS_INI"
mod_ko=${mod_ko%[[:cntrl:]]} # suppression \n final
fi
echo -e "$mod_ko"
}
2017-11-30 20:27:02 +01:00
# [$1=silent], assigne fe_nb_audio, fe_cards_audio
2018-03-09 07:12:34 +01:00
fi_audio(){ # 06/03/2018
2017-12-01 21:50:07 +01:00
local cardsAudio cmd_cards version_alsa card_alsa cmd_card_alsa cmt_card_alsa pluriel text
2018-03-09 07:12:34 +01:00
local arecord aplay mod_alsa cmd_mod_alsa cmt_mod_alsa modAudio cmd_modAudio cmt_modAudio
2017-11-29 00:59:12 +01:00
local alert_alsa
2017-12-14 13:55:05 +01:00
x_audio=1
2018-02-09 06:07:03 +01:00
2017-11-30 20:27:02 +01:00
# devices
2018-02-09 06:07:03 +01:00
figet_lspci "audio" "name"
fe_cards_audio=$( f_lifting "${lspci[name]}" )
2017-12-16 23:31:32 +01:00
fe_cards_audio=${fe_cards_audio% controller}
fe_cards_audio=${fe_cards_audio% Controller}
fe_cards_audio=${fe_cards_audio#*: }
2018-02-09 06:07:03 +01:00
fe_nb_audio=${lspci[nb_card]}
2017-11-30 20:27:02 +01:00
[ "$fe_nb_audio" -eq 0 ] && return 0
2018-02-09 06:07:03 +01:00
2018-03-09 07:12:34 +01:00
[ "$1" == "silent" ] && return 0 # pas d'affichage
2017-12-01 21:50:07 +01:00
###
2017-12-13 20:44:22 +01:00
2017-11-29 00:59:12 +01:00
# lspci
2018-02-09 06:07:03 +01:00
figet_lspci "audio" "raw"
cardsAudio=${lspci[card]}
2018-03-09 07:12:34 +01:00
cmd_cards="lspci -nnv | grep -Ei -A10 'Audio device|Audio controller'"
2017-11-29 00:59:12 +01:00
if [ ! -d /proc/asound ] ; then
alert_alsa="/proc/asound : répertoire inexistant"
alert_alsa="ALSA n'est pas installé correctement"
2017-11-30 20:27:02 +01:00
else
# ALSA
2018-02-26 13:26:50 +01:00
version_alsa=$( awk '{
2017-11-30 20:27:02 +01:00
sub(/Advanced Linux Sound Architecture Driver /,"")
sub(/Version /,"")
sub(/.$/,"")
print $0
}' /proc/asound/version )
2018-02-26 13:26:50 +01:00
card_alsa=$( awk ' { print " "$0 }' /proc/asound/cards )
2018-03-09 07:12:34 +01:00
if [ "$( grep -c '\[.*\]' <<< "$card_alsa" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
2017-12-01 21:50:07 +01:00
cmd_card_alsa="cat /proc/asound/cards"
2018-03-09 07:12:34 +01:00
cmt_card_alsa="carte$pluriel enregistée$pluriel"
2018-02-09 18:45:09 +01:00
# périphériques
2018-02-13 20:26:29 +01:00
arecord=$( LC_ALL=C arecord -l 2>/dev/null | grep 'card' )
aplay=$( LC_ALL=C aplay -l 2>/dev/null | grep 'card' )
2018-02-09 18:45:09 +01:00
cmd_arecord="arecord -l | grep 'carte'"
cmd_aplay="aplay -l | grep 'carte'"
cmt_arecord="périphériques de capture"
cmt_aplay="périphériques de lecture"
2017-11-30 20:27:02 +01:00
# modules alsa
2018-02-26 13:26:50 +01:00
mod_alsa=$( awk '{ print $2 }' /proc/asound/modules )
2018-02-23 17:07:39 +01:00
mod_alsa=$( sort <<< "$mod_alsa" )
2018-03-09 07:12:34 +01:00
if [ "$( f__wcv -l "$mod_alsa" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
2017-12-09 00:19:29 +01:00
cmd_mod_alsa="cat /proc/asound/modules"
2018-03-09 07:12:34 +01:00
cmt_mod_alsa="module$pluriel alsa"
2018-02-09 06:07:03 +01:00
# modules kernel utilisé
figet_lspci "audio" "module"
modAudio="${lspci[module]}"
cmd_modAudio="lsmod | grep -Ew '${lspci[srch_mod]}'"
2018-03-09 07:12:34 +01:00
if [ "$( f__wcv -wv "$modAudio" "^[[:alnum:]]" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
cmt_modAudio="$( f__wcv -wv "$modAudio" "^[[:alnum:]]" ) module$pluriel utilisé"$pluriel
2017-11-29 00:59:12 +01:00
fi
###
2017-12-15 01:18:35 +01:00
f_prnt tit2 "audio"
2018-02-23 17:07:39 +01:00
f_prnt 1 "$( sed -E 's/(.*)/**\1** /' <<< "$fe_cards_audio" )" # en gras
2017-12-13 03:15:07 +01:00
f_prnt
2017-11-29 00:59:12 +01:00
# lspci -nnv
2017-12-15 01:18:35 +01:00
f_dspl cmd "$cardsAudio" "$cmd_cards"
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$alert_alsa" "alert"
2017-12-15 01:18:35 +01:00
f_dspl cmd "$version_alsa" "/proc/asound/version" "driver alsa (Advanced Linux Sound Architecture)"
f_dspl cmd "$card_alsa" "$cmd_card_alsa" "$cmt_card_alsa"
2018-02-09 18:45:09 +01:00
f_dspl cmd "$arecord" "$cmd_arecord" "$cmt_arecord"
f_dspl cmd "$aplay" "$cmd_aplay" "$cmt_aplay"
2018-02-09 06:07:03 +01:00
f_dspl cmd "$mod_alsa" "$cmd_mod_alsa" "$cmt_mod_alsa"
2017-12-15 01:18:35 +01:00
f_dspl cmd "$modAudio" "$cmd_modAudio" "$cmt_modAudio"
2017-11-29 00:59:12 +01:00
}
2018-03-09 07:12:34 +01:00
fi_batt(){ # 06/03/2018
2017-10-22 11:14:21 +02:00
local pluriel
2017-12-01 21:50:07 +01:00
2018-03-09 07:12:34 +01:00
(( x_batt == 1 )) || figet_batt
2017-12-09 17:15:18 +01:00
[ "$fg_batt" ] || return 0 # pas de batterie
2017-12-01 21:50:07 +01:00
###
2018-03-09 07:12:34 +01:00
if [ "$fg_nb_batt" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
2017-12-15 01:18:35 +01:00
f_prnt tit2 "batterie"$pluriel
f_dspl sans "$fg_batt"
2017-09-28 20:47:34 +02:00
}
2017-12-14 13:55:05 +01:00
# [$1=silent], assigne $fe_nb_bluez, $fe_cards_bluez
2018-03-09 07:12:34 +01:00
fi_bluez(){ # 06/03/2018
2017-12-09 00:19:29 +01:00
local bluez cmd_bluez cmt_bluez mod cmd_mod cmt_mod pluriel text
2017-12-14 13:55:05 +01:00
x_bluez=1
2018-02-09 06:07:03 +01:00
2018-03-09 07:12:34 +01:00
if type -p hcitool &>/dev/null ; then
2018-03-02 06:06:51 +01:00
fe_nb_bluez=$( hcitool dev | grep -c 'hci[[:digit:]]' )
fe_cards_bluez=$( hcitool dev | grep -Eo 'hci[0-9]+' | tr '\n' ' ' )
2017-11-30 20:41:28 +01:00
else
2018-03-02 06:06:51 +01:00
fe_nb_bluez=-99
fe_cards_bluez="n/a"
2017-11-30 20:41:28 +01:00
fi
2018-03-02 06:06:51 +01:00
[[ "$1" == "silent" || "$fe_nb_bluez" -le 0 ]] && return 0
2017-12-13 20:44:22 +01:00
2017-11-30 20:27:02 +01:00
# état
bluez=$( hciconfig -a )
2018-03-09 07:12:34 +01:00
if [ "$fe_nb_bluez" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
2017-11-30 20:27:02 +01:00
cmd_bluez="hciconfig -a"
2017-12-01 21:50:07 +01:00
cmt_bluez="état périphérique"$pluriel
2017-11-30 20:27:02 +01:00
# modules
figet_modules "bluetooth"
mod="$fg_modules" # modules chargés
2017-12-09 00:19:29 +01:00
cmd_mod="lsmod | grep -Ew '$fg_srch_mod'"
2018-03-09 07:12:34 +01:00
if [ "$( f__wcv -l "$mod" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
cmt_mod="$( f__wcv -l "$mod" ) module$pluriel utilisé"$pluriel
2017-12-09 00:19:29 +01:00
fg_mod_motif=${fg_mod_motif//|/ } # fg_mod_motif motif de recherche, avec |
2017-11-30 20:27:02 +01:00
###
2017-12-15 01:18:35 +01:00
f_prnt tit2 "Bluetooth"
f_dspl cmd "$bluez" "$cmd_bluez" "$cmt_bluez"
f_dspl cmd "$mod" "$cmd_mod" "$cmt_mod"
2018-02-09 13:14:43 +01:00
[ "$mod" ] || f_dspl sans "$fg_mod_motif" " " "pas de modules en mémoire parmi:"
2017-11-30 20:27:02 +01:00
}
2018-02-22 01:26:29 +01:00
fi_conf(){ # 21/02/2018
local confs appArmor toScrut=(
2017-12-13 20:44:22 +01:00
'/etc/default/grub'
2018-02-09 18:45:09 +01:00
'/etc/default/grub.d/*.cfg'
# '/etc/grub.d/' # pour info
2017-12-05 20:12:07 +01:00
'/etc/sysctl.conf'
2017-11-22 20:33:37 +01:00
'/etc/sysctl.d/*.conf'
2017-12-03 13:48:03 +01:00
'/etc/hostname' # debian
2017-12-13 20:44:22 +01:00
'/etc/sysconfig/network' # fedora?
2017-12-05 20:12:07 +01:00
'/etc/HOSTNAME' # suse
2018-03-09 07:12:34 +01:00
# /etc/os-release # nouveau standard systemd/freedesktop (voir figet_distrib)
2017-12-05 20:12:07 +01:00
'/etc/vconsole.conf'
2018-03-09 07:12:34 +01:00
# /etc/locale.conf # (voir fi_locale)
2017-11-22 20:33:37 +01:00
'/etc/tmpfiles.d/*.conf'
'/etc/binfmt.d/*.conf'
2018-03-09 07:12:34 +01:00
# /etc/machine-id # voir (fi_serial)
2017-12-03 13:48:03 +01:00
'/etc/modules-load.d/*.conf' #modules to load at boot time
2017-12-05 20:12:07 +01:00
'/etc/machine-info'
2017-12-13 20:44:22 +01:00
'/etc/modprobe.d/*.conf' # blacklist modules
2017-12-03 13:48:03 +01:00
'/etc/systemd/system/*/override.conf' # éditions services
2017-12-13 20:44:22 +01:00
'/etc/discover-modprobe.conf'
2017-11-22 20:33:37 +01:00
)
2017-12-01 21:50:07 +01:00
2017-11-27 06:26:24 +01:00
confs=$( f_grep_file "${toScrut[*]}" "noinexist" )
2018-02-22 01:26:29 +01:00
appArmor=$( aa-status 2>/dev/null )
2017-11-27 06:26:24 +01:00
###
2018-02-22 01:26:29 +01:00
f_prnt tit2 "configuration, divers"
2017-12-15 01:18:35 +01:00
f_dspl cmd "$confs" "grep -Ersv '^#|^$' <fichiers désirés>"
2018-02-22 01:26:29 +01:00
f_dspl cmd "$appArmor" "aa-status" "statut AppArmor"
2017-11-22 20:33:37 +01:00
}
2018-03-09 07:12:34 +01:00
fi_cpu(){ # 08/03/2018
2017-12-05 20:12:07 +01:00
local cpu_flags text iflag qte_flags text_flags="" pluriel
2017-12-01 21:50:07 +01:00
local alert_microcode
2017-12-14 13:55:05 +01:00
(( x_cpu == 1 )) || figet_cpu
2018-03-01 08:18:19 +01:00
(( x_cpu_flags == 1 )) || figet_cpu_flags # 'base' des tags
2018-02-23 17:07:39 +01:00
2018-03-01 08:18:19 +01:00
cpu_flags=$( awk -F ': ' '/^flags/ { print $2; exit }' /proc/cpuinfo | tr ' ' '\n' | sort | tr '\n' ' ' ) # vitesse, pas mieux
2017-11-05 06:33:36 +01:00
for iflag in $cpu_flags; do
2018-02-26 13:26:50 +01:00
text_flags+=$( awk -v motif="$iflag" -F '⟷' '
2018-02-23 17:07:39 +01:00
BEGIN { pattern = "^"toupper(motif) } # recherche sur majuscule
$0 ~ pattern { $1 = motif; exit } # $1 (flag en minuscule)
2018-01-28 19:54:59 +01:00
END { if( $1 != motif ) { $1 = motif; $2 = "?" } # si rien trouvé: ?
printf ("%-20s %s",$1,$2 )
}
2018-02-23 17:07:39 +01:00
' <<< "$CPU_FLAGS" )$'\n'
2017-11-05 06:33:36 +01:00
done
2018-02-27 09:31:41 +01:00
text_flags=${text_flags%[[:cntrl:]]} # suppression \n final
2018-03-09 07:12:34 +01:00
qte_flags=$( f__wcv -w "$cpu_flags" flags )
2018-03-01 08:18:19 +01:00
if ! figet_ucode ; then # retour fonction en erreur => pas d'installation mais possible
2017-12-01 21:50:07 +01:00
alert_microcode="$fg_ucode"
[ "$ENV_DEBIAN" ] && alert_microcode+="\n les installer: **apt install $ucode**"
fi
2018-03-09 07:12:34 +01:00
if [ $(( ${fg_cpu:0:1} )) -gt 1 ]; then pluriel="s"; else unset pluriel; fi
2017-12-14 20:07:23 +01:00
unset CPU_FLAGS x_cpu_flags
2017-12-01 21:50:07 +01:00
###
2017-12-15 01:18:35 +01:00
f_prnt tit2 "processeur"$pluriel
f_dspl cmd "$fg_cpu" "lscpu" # affichage proc
2018-02-20 03:59:50 +01:00
f_dspl var "$fg_uarch" "µ architecture processeur"
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$alert_microcode" "info"
2017-12-15 01:18:35 +01:00
f_prnt 1 "$fg_ucode" '[[ -z "$alert_microcode" && "$fg_ucode" ]]'
2017-12-13 03:15:07 +01:00
f_prnt
2017-12-15 01:18:35 +01:00
f_dspl var "$cpu_flags" "$qte_flags flags cpu" # flags cpu bruts
f_dspl sans "$text_flags" # flags cpu texte
2017-10-04 10:29:08 +02:00
}
2018-03-09 07:12:34 +01:00
# shellcheck disable=SC2086
# SC2086 Double quote to prevent globbing and word splitting
# (certaines variables ne sont pas quotées pour permettre les traitements avec liste, ex: df)
2018-04-08 16:34:59 +02:00
fi_disk(){ # 13/03/2018
local cmd_dd_temp="" dd_temp="" liste_df disk_df disk_df_i cmd_dfi cmd_dfh disk_lsblk fstab crypttab
2017-11-27 15:00:49 +01:00
local resume idResume idSwap idisk text pluriel
2017-11-10 21:06:23 +01:00
local alert_dd_temp alert_file_resume alert_uuidResume
2018-03-09 07:12:34 +01:00
2017-12-14 13:55:05 +01:00
(( x_disk == 1 )) || figet_disk
2017-12-01 21:50:07 +01:00
# hddtemp
2018-03-09 07:12:34 +01:00
if type -p hddtemp &>/dev/null ; then
2017-11-10 12:47:20 +01:00
for idisk in $fg_disk_fixe; do
[ -r "/dev/$idisk" ] || continue
2018-03-09 07:12:34 +01:00
temp=$(( $( LC_ALL=C hddtemp -n "/dev/$idisk" 2>/dev/null ) ))
2017-11-14 19:21:43 +01:00
if [ "$temp" -ge 50 ]; then
2017-11-18 18:34:57 +01:00
alert_dd_temp+="$idisk: température > 50°C "$'\n'
2017-11-10 21:06:23 +01:00
fi
2017-11-14 19:21:43 +01:00
dd_temp+="$idisk: $temp °C"$'\n'
2017-11-25 20:13:54 +01:00
cmd_dd_temp+=" /dev/$idisk"
2017-11-10 12:47:20 +01:00
done
2018-03-09 07:12:34 +01:00
dd_temp=${dd_temp%$'\n'} # suppression dernier $'\n'
2017-11-25 20:13:54 +01:00
cmd_dd_temp="hddtemp$cmd_dd_temp"
2017-11-10 12:47:20 +01:00
[ "$alert_dd_temp" ] && alert_dd_temp=${alert_dd_temp::-1} # suppression dernier $'\n'
fi
2017-11-27 15:00:49 +01:00
# df, espaces des partitions montées seules
2018-03-09 07:12:34 +01:00
liste_df=$( printf "/dev/%s " $fg_disk_part_fixe_m ) # $fg_disk_part_swap
disk_df=$( df -h --total --output=source,target,fstype,size,used,avail,pcent $liste_df )
2017-11-27 15:00:49 +01:00
cmd_dfh="df -h --total --output=source,target,fstype,size,used,avail,pcent $liste_df"
2018-03-09 07:12:34 +01:00
disk_df=$( f__unit_french "$disk_df" )
2017-11-10 12:47:20 +01:00
# df -i, inoeuds
2017-11-27 15:00:49 +01:00
disk_df_i=$( df -i $liste_df )
cmd_dfi="df -i $liste_df"
2017-11-10 12:47:20 +01:00
# lsblk répertoire disques & partitions
2017-11-25 19:39:57 +01:00
disk_lsblk=$( lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID )
2018-03-09 07:12:34 +01:00
disk_lsblk=$( f__unit_french "$disk_lsblk" )
2018-04-08 16:34:59 +02:00
# fstab & crypttab éventuel
2018-03-09 07:12:34 +01:00
fstab=$( f_grep_file "/etc/fstab" "sources notitre" )
2018-04-08 16:34:59 +02:00
crypttab=$( f_grep_file "/etc/crypttab" "sources notitre" )
2017-11-10 12:47:20 +01:00
# resume
2017-11-27 06:26:24 +01:00
resume=$( f_grep_file "/etc/initramfs-tools/conf.d/resume" "notitre" )
2017-11-18 18:34:57 +01:00
if [ "$resume" == "nofile" ]; then
2018-03-09 07:12:34 +01:00
alert_file_resume="Pas de fichier _resume_ dans /etc/initramfs-tools/conf.d/" # alert resume absent
2017-10-12 08:45:16 +02:00
fi
2017-11-25 19:39:57 +01:00
idResume=$( grep -Evs '^[[:blank:]]*#|^$' /etc/initramfs-tools/conf.d/resume | sed -En 's/.*UUID=([0-9a-Z-]*).*$/\1/p' )
idSwap=$( grep -Ev '^[[:blank:]]*#|^$' /etc/fstab | sed -En 's/UUID=([0-9a-Z-]*).*swap.*$/\1/p' )
2017-09-16 14:25:36 +02:00
if [ "$idSwap" ] && [ "$idResume" ] && [ "$idSwap" != "$idResume" ]; then
2017-11-18 18:34:57 +01:00
alert_uuidResume+="vérifier la config resume, l'UUID ne correspond pas à celui du swap. \n"
alert_uuidResume+="id swap : $idSwap \nid resume: $idResume \n"
2018-02-22 01:26:29 +01:00
alert_uuidResume+="vous pouvez utiliser _RESUME=auto_ ou _RESUME=/dev/sdx_ (voire supprimer ce fichier)"
2017-09-16 14:25:36 +02:00
fi
2017-12-01 21:50:07 +01:00
###
2018-03-09 07:12:34 +01:00
if [ "$fg_nb_disk" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
2017-12-15 01:18:35 +01:00
f_prnt tit2 "disque"$pluriel
2017-10-19 09:45:17 +02:00
# espace des partitions fixes montées
2018-03-09 07:12:34 +01:00
f_prnt 1 "$( awk -F ': ' '{print $1": **"$2"**"}' <<< "$fg_disk_part_fix_tot" )"
f_prnt 1 "$fg_disk_part_syst"
2017-12-13 03:15:07 +01:00
f_prnt
2017-12-15 01:18:35 +01:00
f_prnt code
2017-10-19 09:45:17 +02:00
# disques fixes et amovibles
2018-03-09 07:12:34 +01:00
if [ "$( wc -w <<< "$fg_disk_fixe" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
f_prnt l "$( printf '%-17s: %s' "disque$pluriel fixe$pluriel" "$fg_disk_fixe" )"
if [ "$( wc -w <<< "$fg_disk_amov" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
f_prnt l "$( printf '%-17s: %s' "disque$pluriel amovible$pluriel" "$fg_disk_amov" )"
2017-12-13 03:15:07 +01:00
f_prnt
2017-10-20 03:10:56 +02:00
# partitions fixes montées / swap / non montées
2018-03-09 07:12:34 +01:00
if [ "$( wc -w <<< "$fg_disk_part_fixe_m" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
f_prnt l "$( printf '%-24s: %s' "partition$pluriel fixe$pluriel montée$pluriel" "$fg_disk_part_fixe_m" )"
if [ "$( wc -w <<< "$fg_disk_part_swap" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
f_prnt l "$( printf '%-24s: %s' "partition$pluriel swap$pluriel" "$fg_disk_part_swap" )"
if [ "$( wc -w <<< "$fg_disk_part_fixe_nm" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
f_prnt l "$( printf '%-28s: %s' "partition$pluriel fixe$pluriel non montée$pluriel" "$fg_disk_part_fixe_nm" )"
2017-12-13 03:15:07 +01:00
f_prnt
2017-10-19 09:45:17 +02:00
# partitions amovibles montées / non montées
2018-03-09 07:12:34 +01:00
if [ "$( wc -w <<< "$fg_disk_part_amov_m" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
f_prnt l "$( printf '%-33s: %s' "partition$pluriel amovible$pluriel montée$pluriel" "$fg_disk_part_amov_m" )"
if [ "$( wc -w <<< "$fg_disk_part_amov_nm" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
f_prnt l "$( printf '%-33s: %s' "partition$pluriel amovible$pluriel non montée$pluriel" "$fg_disk_part_amov_nm" )"
2017-12-13 03:15:07 +01:00
f_prnt
2017-10-31 06:52:36 +01:00
# détails des disques par type
2018-03-09 07:12:34 +01:00
f_prnt l "$fg_disk_table"
2017-12-15 01:18:35 +01:00
f_prnt code
2017-12-13 03:15:07 +01:00
f_prnt
2018-03-09 07:12:34 +01:00
if [ "$fg_nb_disk" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
f_prnt 1 "**types de disque$pluriel** "
2018-04-08 16:34:59 +02:00
f_prnt 2 "ata : $fg_disk_ata (y compris externe ata sur usb)" '[ "$fg_disk_ata" ]'
f_prnt 2 "usb : $fg_disk_usb (type clefs usb)" '[ "$fg_disk_usb" ]'
2018-03-09 07:12:34 +01:00
f_prnt 2 "mmc : $fg_disk_mmc" '[ "$fg_disk_mmc" ]'
f_prnt 2 "nvme: $fg_disk_nvme" '[ "$fg_disk_nvme" ]'
2017-12-13 03:15:07 +01:00
f_prnt
2017-10-17 22:02:16 +02:00
# éventuellement hddtemp
2017-12-15 01:18:35 +01:00
f_dspl cmd "$dd_temp" "$cmd_dd_temp" "température disque"$pluriel
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$alert_dd_temp" "info"
2017-11-10 12:47:20 +01:00
# df, espaces des partitions montées seules
2017-12-15 01:18:35 +01:00
f_dspl cmd "$disk_df" "$cmd_dfh" "utilisation disque"$pluriel
2017-10-31 06:52:36 +01:00
# df -i, inoeuds
2017-12-15 01:18:35 +01:00
f_dspl cmd "$disk_df_i" "$cmd_dfi" "utilisation inoeuds"
2017-11-10 12:47:20 +01:00
# lsblk répertoire disques & partitions
2018-03-09 07:12:34 +01:00
f_dspl cmd "$disk_lsblk" "lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID" "disque$pluriel & partitions"
2018-04-08 16:34:59 +02:00
# fstab & crypttab
2017-12-15 01:18:35 +01:00
f_dspl cmd "$fstab" "grep -Ev '^#|^$' /etc/fstab" "fstab"
2018-04-08 16:34:59 +02:00
f_dspl cmd "$crypttab" "grep -Ev '^#|^$' /etc/crypttab" "crypttab"
2017-10-21 11:07:11 +02:00
# resume
2017-12-15 01:18:35 +01:00
f_dspl cmd "$resume" "grep -Evs '^#|^$' /etc/initramfs-tools/conf.d/resume" "resume"
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$alert_file_resume" "info"
f_dspl_alrt "$alert_uuidResume" "alert"
2017-08-02 05:30:37 +02:00
}
2018-03-09 07:12:34 +01:00
# shellcheck disable=SC2181
# SC2181 Check exit code directly
fi_dmesg(){ # 08/03/2018
2017-11-27 08:06:58 +01:00
local dmesg_err dmesg_warn dmesg_crit file info_ucode alert_firmBug text nb_lignes=25
local alert_firmBug
2017-12-01 21:50:07 +01:00
2018-01-26 19:56:39 +01:00
file="/tmp/$script-dmesg"
2017-10-09 20:19:07 +02:00
[ "$EUID" -eq 0 ] || echo
2017-10-19 08:57:57 +02:00
f__sudo "dmesg -Hk --nopager -l emerg > $file-emerg ; \
dmesg -Hk --nopager -l alert > $file-alert ; \
dmesg -Hk --nopager -l crit > $file-crit ; \
2017-11-27 08:06:58 +01:00
dmesg -Hk --nopager -l err > $file-err ; \
2017-10-19 08:57:57 +02:00
dmesg -Hk --nopager -l warn > $file-warn ; \
2017-11-27 08:06:58 +01:00
dmesg -Hk --nopager -l info | grep -i 'microcode: .*updated early' > $file-ucode ; \
dmesg -Hk --nopager | grep -i 'Firmware Bug' > $file-firmBug ; \
2017-12-02 18:24:34 +01:00
chown $fu_user: $file-*"
2017-10-09 20:19:07 +02:00
if [ "$?" != "0" ]; then
2017-10-19 08:57:57 +02:00
f__info "\n les commandes$GREEN dmesg$RED ont échoué $BLUE(droits root requis, échec authentification?)" \
2017-10-11 02:06:15 +02:00
"vous pouvez relancer le script complet$RED en root$BLUE pour voir les erreurs du noyau via dmesg" \
2017-11-24 18:00:20 +01:00
"ou juste la partie journaux avec $GREEN$DIRNAME""getInfo -j"
2017-10-31 06:52:36 +01:00
text+="* les commandes \`dmesg\` ont échoué, relancer avec les droits root \n\n"
2017-12-29 12:36:55 +01:00
echo -e "$text" >> "$file_output"
2017-10-09 20:19:07 +02:00
return 0
2017-08-26 09:05:54 +02:00
fi
2017-11-25 19:39:57 +01:00
dmesg_emerg=$( sed -n 1,"$nb_lignes"p $file-emerg )
dmesg_alert=$( sed -n 1,"$nb_lignes"p $file-alert )
dmesg_crit=$( sed -n 1,"$nb_lignes"p $file-crit )
dmesg_err=$( sed -n 1,"$nb_lignes"p $file-err )
dmesg_warn=$( sed -n 1,"$nb_lignes"p $file-warn )
2017-10-20 03:10:56 +02:00
[ "$dmesg_emerg" ] || dmesg_emerg=" <vide>"
[ "$dmesg_alert" ] || dmesg_alert=" <vide>"
[ "$dmesg_crit" ] || dmesg_crit=" <vide>"
[ "$dmesg_err" ] || dmesg_err=" <vide>"
[ "$dmesg_warn" ] || dmesg_warn=" <vide>"
2017-11-27 08:06:58 +01:00
# messages microcode
2018-03-09 07:12:34 +01:00
info_ucode=$( < $file-ucode )
2017-11-27 08:06:58 +01:00
[ "$info_ucode" ] && info_ucode="microcode processeur mis à jour au boot"
2018-03-09 07:12:34 +01:00
alert_firmBug=$( < $file-firmBug )
2017-11-27 08:06:58 +01:00
# suppression fichier de transfert
2017-10-11 02:06:15 +02:00
rm "$file-"*
2017-12-01 21:50:07 +01:00
###
2017-12-15 01:18:35 +01:00
f_prnt tit2 "dmesg kernel (emergency, alerte, erreur, warning ou critique)"
f_dspl cmd "$dmesg_emerg" "dmesg -l emerg" "emergency, $nb_lignes premières lignes"
f_dspl cmd "$dmesg_alert" "dmesg -l alert" "alerte, $nb_lignes premières lignes"
f_dspl cmd "$dmesg_crit" "dmesg -l crit" "critique, $nb_lignes premières lignes"
f_dspl cmd "$dmesg_err" "dmesg -l err" "erreur, $nb_lignes premières lignes"
f_dspl cmd "$dmesg_warn" "dmesg -l warn" "warning, $nb_lignes premières lignes"
f_prnt l "**les $nb_lignes premières lignes commencent à la date la plus ancienne encore dans les logs kernel**"
2017-12-13 03:15:07 +01:00
f_prnt flush
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$info_ucode" "info"
f_dspl_alrt "$alert_firmBug" "alert"
2017-12-01 21:50:07 +01:00
}
2018-03-09 07:12:34 +01:00
fi_efi(){ # 06/03/2018
2017-11-19 10:40:13 +01:00
local efiboot text
2017-12-01 21:50:07 +01:00
2018-03-09 07:12:34 +01:00
type -p efibootmgr &>/dev/null || return 0 # pas d'efibootmgr
2018-02-22 01:26:29 +01:00
efiboot=$( efibootmgr -v 2>/dev/null ) || return 0 # pas d'efi
efiboot=${efiboot// / } # amélioration légère
efiboot=${efiboot//\\/\\\\} # échappement des \
2017-12-01 21:50:07 +01:00
###
2017-12-15 01:18:35 +01:00
f_prnt tit2 "EFI boot"
f_dspl cmd "$efiboot" "efibootmgr -v" "config EFI boot"
2017-11-19 10:40:13 +01:00
}
2018-02-09 18:45:09 +01:00
# [$1=silent|xorgOnly], assigne $fe_gpu (liste des gpu), $fe_nb_gpu, fe_Xorg (peut être null)
2018-03-09 07:12:34 +01:00
# shellcheck disable=SC2086
# SC2086 Double quote to prevent globbing and word splitting
fi_gpu(){ # 06/03/2018
2018-02-22 01:26:29 +01:00
local toScrut confs ifile fileConfs cmd_confs cmt_confs info_config
2018-03-09 07:12:34 +01:00
local cards cmd_cards openGl pluriel text
2017-11-30 20:27:02 +01:00
local stck_glxinfo glx_dvc cmd_glx_dvc stck_glxinfoOpt stck_glxinfoDri glx_dvc_temp
2018-02-07 13:27:59 +01:00
local cmd_openGl stck_xrandr_query resolutions cmd_resolutions cmt_resolutions providers cmd_providers
2017-11-30 20:27:02 +01:00
local current_preferred cmd_current_preferred cmt_current_preferred
2017-12-09 00:19:29 +01:00
local modGpu cmd_modGpu cmt_modGpu
2017-11-22 06:40:09 +01:00
local alert_hybrid alert_3D alert_Wayland
2017-12-14 13:55:05 +01:00
x_gpu=1
2018-02-09 06:07:03 +01:00
2017-12-02 11:05:56 +01:00
# liste/description gpu et qte
2018-02-09 06:07:03 +01:00
figet_lspci "video" "name"
fe_gpu=${lspci[name]/VGA compatible controller: }
2017-12-16 23:31:32 +01:00
fe_gpu=${fe_gpu/VGA compatible controller: }
fe_gpu=${fe_gpu/Display controller: }
fe_gpu=${fe_gpu/3D controller: }
2018-02-09 06:07:03 +01:00
fe_nb_gpu=${lspci[nb_card]}
[ "$fe_nb_gpu" -eq 0 ] && return 0 # pas de gpu, rien à voir
2017-12-02 11:05:56 +01:00
# version Xorg Server
2018-03-09 07:12:34 +01:00
fe_Xorg=$( xdpyinfo -display "$DISPLAY" 2>/dev/null | grep -i 'x.*version' ) # X.Org version: 1.19.6
fe_Xorg=${fe_Xorg// version:} # X.Org 1.19.6
2017-12-02 11:05:56 +01:00
2017-12-02 18:24:34 +01:00
[ "$1" == "silent" ] && return 0
2018-02-09 06:07:03 +01:00
### ## xorgOnly (essai)
2017-12-02 18:24:34 +01:00
toScrut=(
2018-03-09 07:12:34 +01:00
"/etc/X11/xorg.conf"
"/etc/X11/xorg.conf.d/*.conf"
2017-12-02 18:24:34 +01:00
)
2017-12-03 13:48:03 +01:00
confs=$( f_grep_file "${toScrut[*]}" )
2018-03-09 07:12:34 +01:00
for ifile in "${toScrut[@]}"; do
[ -e $ifile ] && fileConfs+="$ifile " # ne pas quoter $ifile dans la condition pour permettre glob
2017-12-02 18:24:34 +01:00
done
2018-03-09 07:12:34 +01:00
cmd_confs="grep -Ersv '^#|^$' ${toScrut[*]}"
#~ [ "$fileConfs" ] || cmd_confs="Aucun fichier à afficher"
2017-12-02 18:24:34 +01:00
cmt_confs="configuration Xorg"
info_config="les configurations par défaut de Xorg se trouve dans **/usr/share/X11/xorg.conf.d/**, "
2017-12-08 00:33:12 +01:00
info_config+="non sorties ici."
2017-12-03 13:48:03 +01:00
2017-12-02 18:24:34 +01:00
if [ "$1" == "xorgOnly" ]; then
2017-12-13 03:15:07 +01:00
f_dspl cmd "$confs" "$cmd_confs" "$cmt_confs"
2017-12-03 13:48:03 +01:00
confs=$( f_grep_file "/usr/share/X11/xorg.conf.d/*" )
2018-02-09 06:07:03 +01:00
f_dspl cmd "$confs" "grep -Ersv '^#|^$' /usr/share/X11/xorg.conf.d/*" "config par défaut Xorg"
2018-03-09 07:12:34 +01:00
fi_journal_xorg "notitre"
2017-12-02 18:24:34 +01:00
return 0
fi
2017-12-01 21:50:07 +01:00
###
2018-02-09 06:07:03 +01:00
xrandr --auto 2>/dev/null
2017-11-01 07:45:18 +01:00
# lspci
2017-12-14 13:55:05 +01:00
# lspci -nnk | grep -EiA 3 'vga|display|3d'
2018-03-09 07:12:34 +01:00
# lspci -nnv | grep -iE -A10 'vga|display|3d'
2017-12-14 13:55:05 +01:00
# lspci -nnv -s $( lspci | grep -Ei 'vga|display|3d' | cut -d" " -f1 )
2018-02-23 17:07:39 +01:00
# lspci -nnv -s $( awk '/VGA |Display |3D / {print $1}' <<< "$( lspci )" )
2018-02-09 06:07:03 +01:00
figet_lspci "video" "raw"
cards=${lspci[card]}
cmd_cards="${lspci[prefix_gpu]}lspci -nnv -s \$( lspci | awk '/VGA |Display |3D / {print \$1}' )"
2017-11-10 21:06:23 +01:00
if grep -iq 'Unknown header type 7f' <<< "$cards" ; then
2017-11-18 18:34:57 +01:00
alert_hybrid="Une carte graphique semble désactivée actuellement, lspci n'est pas complet. \n"
2017-11-10 12:47:20 +01:00
fi
2018-02-09 06:07:03 +01:00
# openGl / glxinfo
2017-11-22 06:40:09 +01:00
if [[ "$wayland" && "$EUID" -eq 0 ]]; then # évite erreur $DISPLAY en root wayland
2017-11-25 19:39:57 +01:00
openGl="n/a:wayland root"
resolutions="n/a:wayland root"
providers="n/a:wayland root"
current_preferred="n/a:wayland root"
2017-11-22 06:40:09 +01:00
else
2018-03-09 07:12:34 +01:00
if type -p glxinfo &>/dev/null ; then
2017-11-22 06:40:09 +01:00
stck_glxinfo=$( glxinfo )
# test 3D actif
if grep -iq 'direct rendering: No' <<< "$stck_glxinfo" ; then
alert_3D="l'accélération 3D n'est pas active"
fi
# devices
glx_dvc=$( grep -i 'direct rendering:' <<< "$stck_glxinfo" )$'\n'
2017-11-24 18:00:20 +01:00
glx_dvc+=$( grep 'Device: ' <<< "$stck_glxinfo" | xargs )
2017-11-22 06:40:09 +01:00
cmd_glx_dvc="glxinfo | grep -E 'rendering|Device: '"
2017-12-02 11:05:56 +01:00
if [ "$fe_nb_gpu" -gt 1 ]; then # plusieurs cartes, optirun et prime
2018-03-09 07:12:34 +01:00
if type -p optirun &>/dev/null ; then
2017-11-22 06:40:09 +01:00
stck_glxinfoOpt=$( optirun glxinfo )
2018-02-23 17:07:39 +01:00
glx_dvc_temp=$( grep 'Device: ' <<< "$stck_glxinfoOpt" | xargs )
2017-11-22 06:40:09 +01:00
cmd_glx_dvc="optirun $cmd_glx_dvc"
2017-11-20 15:27:48 +01:00
else
2017-11-22 06:40:09 +01:00
stck_glxinfoDri=$( DRI_PRIME=1 glxinfo )
2018-02-23 17:07:39 +01:00
glx_dvc_temp=$( grep 'Device: ' <<< "$stck_glxinfoDri" | xargs )
2017-11-22 06:40:09 +01:00
cmd_glx_dvc="DRI_PRIME=1 $cmd_glx_dvc"
2017-11-20 15:27:48 +01:00
fi
2017-11-22 06:40:09 +01:00
[ "$glx_dvc_temp" != "$glx_dvc" ] && glx_dvc+="\n$glx_dvc_temp" # ajout si diff
2017-11-20 15:27:48 +01:00
fi
2017-11-22 06:40:09 +01:00
# openGL
2017-12-01 21:50:07 +01:00
fi_gpu_openGl # openGl pour une carte ou gpu de base
2017-12-02 11:05:56 +01:00
if [ "$fe_nb_gpu" -gt 1 ]; then # plusieurs cartes, optirun et prime
2018-03-09 07:12:34 +01:00
if type -p optirun &>/dev/null ; then
2017-12-01 21:50:07 +01:00
fi_gpu_openGl "opt" # ajout à $openGl existant, pas de redondance
2018-02-07 13:27:59 +01:00
cmd_openGl="optirun glxinfo | grep -E "
2017-11-22 06:40:09 +01:00
else # DRI
2017-12-01 21:50:07 +01:00
fi_gpu_openGl "dri" # redondance
2018-02-07 13:27:59 +01:00
cmd_openGl="DRI_PRIME=1 glxinfo | grep -E "
2017-11-22 06:40:09 +01:00
fi
else
cmd_openGl="glxinfo | grep -E "
2017-11-10 12:47:20 +01:00
fi
2018-02-07 13:27:59 +01:00
cmd_openGl+="'OpenGL vendor|OpenGL renderer|OpenGL version|shading language|OpenGL extensions'"
2017-11-22 06:40:09 +01:00
openGl=${openGl// string:/:} # suppression chaîne ' string'
openGl=${openGl% } # suppression espace final éventuel
2017-11-10 12:47:20 +01:00
fi
2017-11-21 22:44:56 +01:00
# xrandr: résolutionS & providers & preferred/current
2018-03-09 07:12:34 +01:00
if type -p xrandr &>/dev/null ; then
2018-02-09 06:07:03 +01:00
stck_xrandr_query=$( xrandr --query 2>/dev/null )
2018-02-23 17:07:39 +01:00
resolutions=$( grep -i 'screen' <<< "$stck_xrandr_query" )$'\n' # screen partie "carte graphique"
resolutions+=$( grep -A10 -iw 'connected' <<< "$stck_xrandr_query" ) # partie "output"
2018-02-07 13:27:59 +01:00
cmd_resolutions="xrandr --query | grep -A10 -B1 -i 'screen'"
2017-11-24 18:00:20 +01:00
cmt_resolutions="10 premières résolutions possibles"
2018-02-09 06:07:03 +01:00
providers=$( xrandr --listproviders 2>/dev/null ) # DRI: ok, sort 2 fournisseurs
2017-11-24 18:00:20 +01:00
cmd_providers="xrandr --listproviders"
2018-02-26 13:26:50 +01:00
current_preferred=$( xrandr --verbose 2>/dev/null | grep -EA2 'current|preferred' )
2017-11-24 18:00:20 +01:00
cmd_current_preferred="xrandr --verbose | grep -EA2 'current|preferred'"
cmt_current_preferred="résolution courante et préférée"
fi
2017-11-21 22:44:56 +01:00
fi
2018-02-09 06:07:03 +01:00
# modules utilisé
figet_lspci "video" "module"
modGpu="${lspci[module]}"
cmd_modGpu="lsmod | grep -Ew '${lspci[srch_mod]}'"
2018-03-09 07:12:34 +01:00
if [ "$( f__wcv -wv "$modGpu" "^[[:alnum:]]" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
cmt_modGpu="**Gpu:** $( f__wcv -wv "$modGpu" "^[[:alnum:]]" ) module$pluriel utilisé"$pluriel
2017-10-26 01:21:24 +02:00
# fonctions externes
2017-12-14 13:55:05 +01:00
(( x_screen )) || figet_screen
2017-12-02 18:24:34 +01:00
###
2017-12-15 01:18:35 +01:00
f_prnt tit2 "vidéo"
2018-02-23 17:07:39 +01:00
f_prnt 1 "$( sed -E 's/(.*)/**\1** /' <<< "$fe_gpu" )" # mise en gras
2017-12-13 03:15:07 +01:00
f_prnt
2017-10-26 01:55:35 +02:00
# nb écran & résolution(s) active(s)
2017-12-15 01:18:35 +01:00
f_prnt 1 "nombre d'écrans: **$fg_nb_screen**"
2018-03-09 07:12:34 +01:00
if [ "$( f__wcv "-wv" "$fg_resolution" "pixels" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
f_prnt 1 "résolution$pluriel active$pluriel: **$fg_resolution**"
2017-12-13 03:15:07 +01:00
f_prnt
2017-11-06 09:24:58 +01:00
# lspci -nnv
2017-12-15 01:18:35 +01:00
f_dspl cmd "$cards" "$cmd_cards"
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$alert_hybrid" "alert"
2017-11-22 06:40:09 +01:00
# wayland
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$alert_Wayland" "info"
2017-10-25 05:21:16 +02:00
# openGl
2017-12-15 01:18:35 +01:00
f_dspl cmd "$glx_dvc" "$cmd_glx_dvc" "devices OpenGl"
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$alert_3D" "info"
2017-12-15 01:18:35 +01:00
f_dspl cmd "$openGl" "$cmd_openGl" "OpenGl"
2017-11-10 12:47:20 +01:00
# liste providers, preferred & current
2017-12-15 01:18:35 +01:00
f_dspl cmd "$current_preferred" "$cmd_current_preferred" "$cmt_current_preferred"
f_dspl cmd "$providers" "$cmd_providers"
2017-10-26 01:55:35 +02:00
# résolutions possibles, pas d'affichage si mode (ssh) ou xrandr pas accessible
2017-12-15 01:18:35 +01:00
f_dspl cmd "$resolutions" "$cmd_resolutions" "$cmt_resolutions"
2017-10-25 05:21:16 +02:00
# modules vidéo
2017-12-15 01:18:35 +01:00
f_dspl cmd "$modGpu" "$cmd_modGpu" "$cmt_modGpu"
2017-12-02 18:24:34 +01:00
# Xorg config
2017-12-15 01:18:35 +01:00
f_dspl cmd "$confs" "$cmd_confs" "$cmt_confs"
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$info_config" "info"
2017-08-03 02:44:53 +02:00
}
2017-12-01 21:50:07 +01:00
# $1="[opt|dri]", assigne $openGl, sous fonction de fi_gpu
2018-03-09 07:12:34 +01:00
fi_gpu_openGl(){ # 06/03/2018
2017-12-01 21:50:07 +01:00
local iogl dri_glxinfo=""
[[ "$1" == "opt" ]] && openGl+="\n---- \n"
toScrut=(
'OpenGL vendor'
'OpenGL renderer'
'OpenGL version'
'shading language'
'OpenGL extensions'
)
for iogl in "${toScrut[@]}" ; do
2017-11-29 18:20:36 +01:00
if [ "$1" == "dri" ]; then
2018-02-23 17:07:39 +01:00
dri_glxinfo+=$( grep "$iogl" <<< "$stck_glxinfoDri" )$'\n'
2017-12-01 21:50:07 +01:00
elif [ "$1" == "opt" ]; then
2018-02-23 17:07:39 +01:00
openGl+=$( grep "$iogl" <<< "$stck_glxinfoOpt" )$'\n'
2017-12-01 21:50:07 +01:00
else
openGl+=$( grep "$iogl" <<< "$stck_glxinfo" )$'\n'
2017-11-29 18:20:36 +01:00
fi
2017-12-01 21:50:07 +01:00
done
if [ "$1" == "dri" ]; then
dri_glxinfo=${dri_glxinfo::-1}
2018-03-09 07:12:34 +01:00
openGl=$( uniq <<< "$dri_glxinfo" 2>/dev/null ) || openGl="$dri_glxinfo"
2017-12-01 21:50:07 +01:00
fi
openGl=${openGl::-1}
}
2017-11-29 18:20:36 +01:00
2017-12-14 13:55:05 +01:00
fi_hw(){ # 14/12/2017
(( x_hw == 1 )) || figet_hw
2017-12-01 21:50:07 +01:00
###
2017-12-15 01:18:35 +01:00
f_prnt tit2 "hardware monitor"
f_dspl sans "$fg_hw" "sans"
f_prnt 1 "pas d'informations détectées" '[ -z "$fg_hw" ]'
2017-12-13 03:15:07 +01:00
f_prnt flush
2017-10-12 21:49:57 +02:00
}
2018-03-09 07:12:34 +01:00
fi_ip_pub(){ # 08/03/2018
local itest
2017-12-14 13:55:05 +01:00
2018-03-09 07:12:34 +01:00
for itest in -4 -6; do
2017-12-14 13:55:05 +01:00
if figet_ip_pub "$itest" ; then
echo "$BOLD$fg_ip_pub$STD"
else
echo "pas de connectivité ipv${itest#-}"
fi
done
}
2018-03-09 07:12:34 +01:00
# shellcheck disable=SC2181
# SC2181 Check exit code directly
fi_journal(){ # 06/03/2018
2018-02-23 17:07:39 +01:00
local file options_jctl jctl_boot jctl_alert_k jctl_crit_k jctl_err_k jctl_warn_k jctl_warn_nok jctl_last jctl_size
2017-11-27 06:26:24 +01:00
local info_ucode text nb_lignes=25
2017-11-18 18:34:57 +01:00
local alert_jctl_persist alert_firmBug
2017-12-01 21:50:07 +01:00
2018-03-09 07:12:34 +01:00
if ! type -p journalctl &>/dev/null ; then
2017-11-25 19:39:57 +01:00
fi_dmesg # pas systemd, appel dmesg
return 0
fi
2017-12-01 21:50:07 +01:00
2018-01-26 19:56:39 +01:00
file="/tmp/$script-journalctl"
2018-02-23 17:07:39 +01:00
if journalctl --help | grep -q -- '--no-hostname' ; then # fix obsolescence buntu 16.04
options_jctl="--no-hostname"
fi
2018-02-26 13:26:50 +01:00
if [ "$EUID" -ne 0 ] ; then
echo -e '\n'
f__info "raw" "les droits root sont demandés et requis pour afficher les journaux systèmes"
f__info "raw" "[su] nécessite la saisie du mot de passe root"
f__info "raw" "[sudo] nécessite le mot de passe utilisateur si celui peut obtenir les privilèges administrateur"
f__info "à défaut de saisie valide, les journaux n'apparaîtront pas dans le rapport final"
fi
2018-02-23 17:07:39 +01:00
f__sudo "LC_ALL=C journalctl $options_jctl --boot -1 &>$file-persistant ; \
LC_ALL=C journalctl --no-pager $options_jctl -b0 -k -p 1 > $file-alert ; \
LC_ALL=C journalctl --no-pager $options_jctl -b0 -k -p 2..2 > $file-crit ; \
LC_ALL=C journalctl --no-pager $options_jctl -b0 -p 3..3 > $file-err ; \
LC_ALL=C journalctl --no-pager $options_jctl -b0 -p 4..4 > $file-warn ; \
LC_ALL=C journalctl --no-pager $options_jctl -b0 -p 4 -n$nb_lignes > $file-last ; \
2017-10-29 07:39:51 +01:00
LC_ALL=C journalctl --disk-usage > $file-size ; \
2018-02-23 17:07:39 +01:00
LC_ALL=C journalctl --no-pager $options_jctl -o short-monotonic --boot 0 -k -p6 | grep -i 'microcode: .*updated early' > $file-ucode ; \
2017-12-18 22:12:44 +01:00
type -p dmesg &>/dev/null && dmesg -Hk --nopager | grep -i 'Firmware Bug' > $file-firmBug ; \
2017-12-02 18:24:34 +01:00
chown $fu_user: $file-*"
2017-11-27 08:06:58 +01:00
if [ "$?" != "0" ]; then
2017-10-19 08:57:57 +02:00
f__info "\n les commandes$GREEN journalctl$RED ont échoué $BLUE(droits root requis, échec authentification?)" \
"vous pouvez relancer le script complet$RED en root$BLUE pour voir les erreurs des journaux" \
2017-11-24 18:00:20 +01:00
"ou juste la partie journaux avec $GREEN$DIRNAME""getInfo -j"
2017-10-31 06:52:36 +01:00
text+="* les commandes \`journalctl\` ont échoué, relancer avec les droits root \n\n"
2017-12-29 12:36:55 +01:00
echo -e "$text" >> "$file_output"
2017-10-19 08:57:57 +02:00
return 0
fi
2017-11-14 16:59:44 +01:00
# début des logs, extraction à partir de file-last (toujours lignes) pour début des logs
2018-02-26 13:26:50 +01:00
jctl_boot=$( awk -F '--|,' 'FNR==1 {print $2}' $file-last )
2017-11-17 07:27:10 +01:00
jctl_boot=$( date -d "${jctl_boot##*begin at }" ) # passage en date locale
2017-11-14 16:59:44 +01:00
# test persistance
2017-11-10 21:06:23 +01:00
if grep -iq 'no persistent journal' "$file-persistant"; then
2017-11-09 11:43:42 +01:00
alert_jctl_persist="les journaux ne sont pas persistants, revoir les logs du précédent boot "
2017-11-27 08:06:58 +01:00
alert_jctl_persist+="n'est donc pas possible pour investigation avec: \n"
2018-02-23 17:07:39 +01:00
alert_jctl_persist+="$spc5 **journalctl $options_jctl --boot -1**"
2017-11-24 18:00:20 +01:00
fi
2017-11-14 16:59:44 +01:00
# journaux kernel
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 )
jctl_err_k=$( sed '/kernel:/!d' $file-err | sed -n 1,"$nb_lignes"p ) # uniquement lignes avec kernel, élimine no entries et logs begin
jctl_warn_k=$( sed '/kernel:/!d' $file-warn | sed -n 1,"$nb_lignes"p )
# taille des journaux
2017-11-25 19:39:57 +01:00
jctl_size=$( grep -Eo '[0-9]*\.[0-9]*[[:alpha:]]{1,2}' $file-size | sed 's/M/ Mo/' )
2017-11-14 16:59:44 +01:00
# signalement fichier vides ou suppression origine kernel (gain de place)
[ "$jctl_alert_k" ] && jctl_alert_k=${jctl_alert_k//kernel:/:} || jctl_alert_k=" ‣ vide"
[ "$jctl_crit_k" ] && jctl_crit_k=${jctl_crit_k//kernel:/:} || jctl_crit_k=" ‣ vide"
[ "$jctl_err_k" ] && jctl_err_k=${jctl_err_k//kernel:/:} || jctl_err_k=" ‣ vide"
[ "$jctl_warn_k" ] && jctl_warn_k=${jctl_warn_k//kernel:/:} || jctl_warn_k=" ‣ vide"
# journaux hors kernel
2017-11-17 07:27:10 +01:00
jctl_alert_nok=$( sed '/-- Logs begin/d;/kernel:/d; s/-- No entries --/ ‣ vide/' $file-alert | \
sed -n 1,"$nb_lignes"p )
jctl_crit_nok=$( sed '/-- Logs begin/d;/kernel:/d; s/-- No entries --/ ‣ vide/' $file-crit | \
sed -n 1,"$nb_lignes"p )
jctl_err_nok=$( sed '/-- Logs begin/d;/kernel:/d; s/-- No entries --/ ‣ vide/' $file-err | \
sed -n 1,"$nb_lignes"p )
jctl_warn_nok=$( sed '/-- Logs begin/d;/kernel:/d; s/-- No entries --/ ‣ vide/;s/<warn>//
' $file-warn | sed -n 1,"$nb_lignes"p )
2017-11-14 16:59:44 +01:00
# dernières lignes, toute provenance
2017-11-17 07:27:10 +01:00
jctl_last=$( sed '/-- Logs begin/d; s/-- No entries --/ ‣ vide/;s/<warn>//' $file-last )
2017-11-27 06:26:24 +01:00
# messages microcode
2017-11-27 08:06:58 +01:00
info_ucode=$( cat $file-ucode )
[ "$info_ucode" ] && info_ucode="microcode processeur mis à jour au boot"
2018-02-23 17:07:39 +01:00
alert_firmBug=$( grep -i 'Firmware Bug' <<< "$jctl_err_k" )$'\n'
2017-11-27 08:06:58 +01:00
alert_firmBug=${alert_firmBug%%[[:space:]]}
alert_firmBug+=$( cat $file-firmBug 2>/dev/null )
alert_firmBug=${alert_firmBug%%[[:space:]]}
2017-11-14 16:59:44 +01:00
# suppression fichier de transfert
2017-10-19 08:57:57 +02:00
rm "$file-"*
2017-11-09 07:00:30 +01:00
###
2017-12-15 01:18:35 +01:00
f_prnt tit2 "journalctl kernel (emergency, alert, erreur, warning ou critique)"
f_prnt 1 "**journaux persistants**" '[ -z "$alert_jctl_persist" ]'
f_prnt 1 "Début des log: **$jctl_boot**"
2017-12-13 03:15:07 +01:00
f_prnt
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$alert_jctl_persist" "info"
2017-11-14 16:59:44 +01:00
# journaux kernel
2018-02-23 17:07:39 +01:00
f_dspl cmd "$jctl_alert_k" "journalctl $options_jctl -b0 -k -p1" \
2017-12-01 21:50:07 +01:00
"**kernel emergency 0 & alerte 1**, $nb_lignes premières lignes"
2018-02-23 17:07:39 +01:00
f_dspl cmd "$jctl_crit_k" "journalctl $options_jctl -b 0 -k -p 2..2" \
2017-12-01 21:50:07 +01:00
"**kernel critique**, $nb_lignes premières lignes"
2018-02-23 17:07:39 +01:00
f_dspl cmd "$jctl_err_k" "journalctl $options_jctl -b0 -k -p 3..3" \
2017-12-01 21:50:07 +01:00
"**kernel erreur**, $nb_lignes premières lignes)"
2018-02-23 17:07:39 +01:00
f_dspl cmd "$jctl_warn_k" "journalctl $options_jctl -b0 -k -p 4..4" \
2017-12-01 21:50:07 +01:00
"**kernel warning**, $nb_lignes premières lignes"
2017-11-14 16:59:44 +01:00
# journaux hors kernel
2017-12-15 01:18:35 +01:00
f_prnt tit2 "journalctl hors kernel (emergency, alert, erreur, warning ou critique)"
f_prnt 1 "Début des log: **$jctl_boot**"
2017-12-13 03:15:07 +01:00
f_prnt
2018-02-23 17:07:39 +01:00
f_dspl cmd "$jctl_alert_nok" "journalctl $options_jctl -b0 -p 1 | grep -v kernel" \
2017-12-01 21:50:07 +01:00
"**hors kernel, emergency 0 & alerte 1**, $nb_lignes premières lignes"
2018-02-23 17:07:39 +01:00
f_dspl cmd "$jctl_crit_nok" "journalctl $options_jctl -b0 -p 2..2 | grep -v kernel" \
2017-12-01 21:50:07 +01:00
"**hors kernel, critique**, $nb_lignes premières lignes"
2018-02-23 17:07:39 +01:00
f_dspl cmd "$jctl_err_nok" "journalctl $options_jctl -b0 -p 3..3 | grep -v kernel" \
2017-12-01 21:50:07 +01:00
"**hors kernel, erreur**, $nb_lignes premières lignes"
2018-02-23 17:07:39 +01:00
f_dspl cmd "$jctl_warn_nok" "journalctl $options_jctl -b0 -p 4..4 | grep -v kernel" \
2017-12-01 21:50:07 +01:00
"**hors kernel, warning**, $nb_lignes premières lignes"
2017-11-14 16:59:44 +01:00
#informations
2017-12-15 01:18:35 +01:00
f_prnt 1 "les $nb_lignes premières lignes commencent à la date du dernier boot"
2017-12-13 03:15:07 +01:00
f_prnt
2017-12-15 01:18:35 +01:00
f_dspl cmd "$jctl_size" "journalctl --disk-usage " "taille des journaux"
2017-11-14 16:59:44 +01:00
# dernières lignes
2018-02-23 17:07:39 +01:00
f_dspl cmd "$jctl_last" "journalctl $options_jctl -b0 -p 4 -n25" \
2017-12-01 21:50:07 +01:00
"**toutes provenance, emergency-warning**, $nb_lignes lignes les plus **récentes**"
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$alert_firmBug" "alert"
f_dspl_alrt "$info_ucode" "info"
2017-10-19 08:57:57 +02:00
}
2018-03-09 07:12:34 +01:00
# [$1=notitre]
fi_journal_xorg(){ # 08/03/2018
local toScrut xfile xfileTest="" logXorg cmd_logXorg="" cmt_logXorg extract dateFile text nb_lignes=50
local info_logs alert_cyrilic
[[ "$ENV_SSH" || "$ENV_DISPLAY" ]] && return 0
(( x_dm == 1 )) || figet_dm
toScrut=(
/var/log/Xorg.0.log
/home/$fu_user/.local/share/xorg/Xorg.0.log
)
[[ "${fg_dm,,}" =~ gdm ]] && toScrut=( ${toScrut[@]} "/var/lib/gdm3/.local/share/xorg/Xorg.0.log" )
for xfile in "${toScrut[@]}"; do
[ -e "$xfile" ] && xfileTest+="y"
done
[ ${#xfileTest} -eq 0 ] && return 0 # aucun fichier à tester (wayland?), retour
# coeur fonction
for xfile in "${toScrut[@]}"; do
if [ -e "$xfile" ]; then
dateFile=$( date -r "$xfile" '+%d/%m/%Y %H:%M %z' )
extract=$( grep -Es '\(WW\)|\(EE\)|\(\?\?\)' "$xfile" | sed '/(WW) warning, (EE) error,/d' )
extract=$( sed -n 1,"$nb_lignes"p <<< "$extract" )
if [ "$extract" ]; then
logXorg+=" $xfile, date de modification: $dateFile \n\n"
logXorg+=" (WW) **warning**, (EE) **erreur**, (??) inconnu, $nb_lignes premières lignes \n"
logXorg+=$( grep -E '\(EE\)' <<< "$extract" )$'\n'
logXorg+=$( grep -E '\(WW\)' <<< "$extract" )$'\n'
logXorg+=$( grep -E '\(\?\?\)' <<< "$extract" )" "$'\n\n'
cmd_logXorg+="$xfile "
else
logXorg+=" $xfile : <vide> "$'\n\n'
fi
else
logXorg+=" $xfile : <inexistant> "$'\n\n'
fi
done
logXorg=${logXorg::-2}
[ "$cmd_logXorg" ] && cmd_logXorg=${cmd_logXorg% } || cmd_logXorg="<emplacement>"
cmd_logXorg="grep -Es '\(WW\)|\(EE\)|\(\?\?\)' $cmd_logXorg"
cmt_logXorg="Xorg.log"
info_logs="voir les options appliquées par défaut: **cat $cmd_logXorg | grep '(\\\*\\\*)**' "
alert_cyrilic=$( grep '/usr/share/fonts/X11/cyrillic" does not exist' <<< "$logXorg" )
if [ "$alert_cyrilic" ]; then
alert_cyrilic=${alert_cyrilic#*) }
alert_cyrilic=${alert_cyrilic%\.}
alert_cyrilic+=": \npour éviter ce message, en root : \`mkdir -p /usr/share/fonts/X11/cyrillic\`"
fi
###
f_prnt tit2 "journaux Xorg" "[ \"$1\" != \"notitre\" ]"
f_dspl cmd "$logXorg" "$cmd_logXorg" "$cmt_logXorg"
f_dspl_alrt "$info_logs" "info"
f_dspl_alrt "$alert_cyrilic" "alert"
}
fi_locale(){ # 06/03/2018
2017-12-06 15:00:33 +01:00
local localeConf localeCtl locale timezone timedatectl xKeyboardMap keyboard text
2017-11-11 19:41:13 +01:00
local alert_rtc alert_ntp
2017-12-01 21:50:07 +01:00
2017-10-25 12:24:21 +02:00
# locale
2018-03-09 07:12:34 +01:00
localeConf=$( f_grep_file "/etc/default/locale* /etc/locale.conf" )
localeCtl=$( localectl --no-pager status 2>/dev/null )
2017-12-06 15:00:33 +01:00
locale=$( locale )
2017-10-25 12:24:21 +02:00
# timezone
2018-03-09 07:12:34 +01:00
timezone=$( f_grep_file "/etc/timezone*" )
if type -p timedatectl &>/dev/null ; then
2017-11-25 19:39:57 +01:00
timedatectl=$( LC_ALL=C timedatectl status --no-pager )
2017-11-10 21:06:23 +01:00
if grep -iq 'Network time on: no' <<< "$timedatectl"; then
2017-11-18 18:34:57 +01:00
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"
2017-11-10 21:06:23 +01:00
alert_ntp+="et/ou installer le démon Ntp: apt install ntp"
fi
if grep -iq 'RTC in local TZ: yes' <<< "$timedatectl"; then
2017-11-18 18:34:57 +01:00
alert_rtc="RTC in local TZ: yes \n"
2017-11-10 21:06:23 +01:00
alert_rtc+="Lhorloge système doit être en UTC pour que les applications de date et "
2017-11-18 18:34:57 +01:00
alert_rtc+="heure fonctionnent correctement avec le fuseau horaire configuré sur le système. \n"
2017-11-10 21:06:23 +01:00
alert_rtc+="Les modifications dheure dété/hiver peuvent être incohérentes quand lhorloge "
alert_rtc+="matérielle est en heure locale."
fi
2017-09-16 14:25:36 +02:00
fi
2017-10-25 12:24:21 +02:00
# keyboard layout
2017-11-25 19:39:57 +01:00
keyboard=$( f_grep_file "/etc/default/keyboard*" )
2018-03-01 08:18:19 +01:00
if [[ "$wayland" && "$EUID" -eq 0 ]]; then # na root wayland
2017-11-25 06:27:15 +01:00
xKeyboardMap="n/a en root sous wayland"
2018-03-01 08:18:19 +01:00
elif [[ "$ENV_SSH" && -z "$DISPLAY" ]]; then # na ssh
xKeyboardMap="n/a avec ssh"
elif [[ "$ENV_SSH" && "$EUID" -eq 0 && ${DISPLAY%:*} ]]; then # na ssh X root
xKeyboardMap="n/a avec ssh X sous root"
elif [[ -z "$DISPLAY" ]]; then # na noX
xKeyboardMap="n/a sans serveur X"
2017-11-25 06:27:15 +01:00
else
2018-03-09 07:12:34 +01:00
xKeyboardMap=$( setxkbmap -query 2>/dev/null )
2017-11-25 06:27:15 +01:00
fi
2017-12-01 21:50:07 +01:00
###
2017-12-15 01:18:35 +01:00
f_prnt tit2 "localisation"
2017-10-25 12:24:21 +02:00
# locale
2017-12-15 01:18:35 +01:00
f_dspl cmd "$localeConf" "grep -Esv '#|^$' /etc/default/locale* /etc/locale.conf"
f_dspl cmd "$localeCtl" "localectl status"
f_dspl cmd "$locale" "locale"
2017-10-25 12:24:21 +02:00
# timezone
2017-12-15 01:18:35 +01:00
f_dspl cmd "$timezone" "grep -EHsv '#|^$' /etc/timezone*"
f_dspl cmd "$timedatectl" "timedatectl status"
f_dspl_alrt "$alert_ntp" "info"
f_dspl_alrt "$alert_rtc" "alert"
2017-10-25 12:24:21 +02:00
# keyboard layout
2017-12-15 01:18:35 +01:00
f_dspl cmd "$keyboard" "grep -EHv '#|^$' /etc/default/keyboard*"
f_dspl cmd "$xKeyboardMap" "setxkbmap -query"
2017-10-23 03:52:48 +02:00
}
2018-02-22 01:26:29 +01:00
fi_mem(){ # 21/02/2018
local memoire swappiness swapType text
2017-12-01 21:50:07 +01:00
2017-10-22 07:07:07 +02:00
figet_mem "mem" #options possibles mem swap total notitle nocoltitle
2017-11-20 15:27:48 +01:00
memoire="$fg_mem \n"
2017-10-22 07:07:07 +02:00
figet_mem "swap" "notitle"
2017-11-17 07:27:10 +01:00
memoire+="$fg_mem"
2017-11-25 19:39:57 +01:00
swappiness=$( cat /proc/sys/vm/swappiness 2>/dev/null )
2018-02-22 01:26:29 +01:00
swapType=$( awk 'FNR != 1 { print $2,":", $1 }' /proc/swaps )
2017-12-01 21:50:07 +01:00
###
2017-12-15 01:18:35 +01:00
f_prnt tit2 "mémoire"
f_dspl cmd "$memoire" "free -h"
2018-03-09 07:12:34 +01:00
f_dspl cmd "$swapType" "awk 'FNR != 1 { print \$2,\":\", \$1 }' /proc/swaps" "type de swap"
2017-12-15 01:18:35 +01:00
f_dspl cmd "$swappiness" "cat /proc/sys/vm/swappiness" "Seuil bas de RAM libre où le swap est utilisé"
2017-10-04 23:26:27 +02:00
}
2017-11-30 20:27:02 +01:00
# [$1=silent], assigne fe_nb_reseau, fe_cards_reseau
2018-03-09 07:12:34 +01:00
fi_net(){ # 07/03/2018 ( matériel )
2017-12-09 00:19:29 +01:00
local cards cmd_cards modEth cmd_modEth cmt_modEth modWln cmd_modWln cmt_modWln pluriel text
2017-11-30 20:27:02 +01:00
local alert_wlx
2017-12-14 13:55:05 +01:00
x_net=1
2018-02-09 06:07:03 +01:00
2017-11-30 20:27:02 +01:00
# devices
2018-02-09 06:07:03 +01:00
figet_lspci "net" "name" # noms des cartes réseau détectées, mix ethernet/wifi
fe_cards_reseau=${lspci[name]/Network controller: /Wireless: }
2017-12-14 20:07:23 +01:00
fe_cards_reseau=${fe_cards_reseau/Wireless Network/Wireless}
2018-03-03 07:40:41 +01:00
fe_cards_reseau=${fe_cards_reseau/Ethernet controller: /Ethernet: }
2018-02-09 06:07:03 +01:00
fe_nb_reseau=${lspci[nb_card]} # nombre de cartes réseau détectées, mix ethernet/wifi
2017-12-01 21:50:07 +01:00
[ "$1" == "silent" ] && return
[ "$fe_nb_reseau" -eq 0 ] && return 0 # pas de cartes réseau, rien à voir (en attendant usb ou autre)
###
2017-11-30 20:27:02 +01:00
# lspci
2017-12-13 20:44:22 +01:00
# lspci -nnk | grep -EiA 3 'network|ethernet'
# lspci -nnv -s $( lspci | grep -Ei 'network' | cut -d" " -f1 )
# lspci -nnv -s $( lspci | grep -Ei 'ethernet' | cut -d" " -f1 )
2018-02-09 06:07:03 +01:00
figet_lspci "net" "raw"
cards=${lspci[card]}
2018-03-09 07:12:34 +01:00
cmd_cards="lspci -nnv | grep -Ei -A10 'network|ethernet'"
2017-12-09 00:19:29 +01:00
#modules ethernet
2018-02-09 06:07:03 +01:00
figet_lspci "ethernet" "module" # obtention module utilisé
modEth="${lspci[module]}"
cmd_modEth="lsmod | grep -Ew '${lspci[srch_mod]}'"
2018-03-09 07:12:34 +01:00
if [ "$( f__wcv -wv "$modEth" "^[[:alnum:]]" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
cmt_modEth="**Ethernet:** $( f__wcv -wv "$modEth" "^[[:alnum:]]" ) module$pluriel utilisé"$pluriel
2017-12-09 00:19:29 +01:00
# modules wifi
2018-02-09 06:07:03 +01:00
figet_lspci "wireless" "module" # obtention module utilisé
modWln="${lspci[module]}"
cmd_modWln="lsmod | grep -Ew '${lspci[srch_mod]}'"
2018-03-09 07:12:34 +01:00
if [ "$( f__wcv -wv "$modWln" "^[[:alnum:]]" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
cmt_modWln="**Wifi:** $( f__wcv -wv "$modWln" "^[[:alnum:]]" ) module$pluriel utilisé"$pluriel
2018-03-03 07:40:41 +01:00
figet_ip
2017-11-30 20:27:02 +01:00
if grep -iq 'wlx' <<< "$fg_ifn"; then
2018-02-23 17:07:39 +01:00
alert_wlx="Une interface wifi est en erreur: $( grep 'wlx' <<< "${fg_ifn// /$'\n'}" ) \n"
2017-11-30 20:27:02 +01:00
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
###
2017-12-15 01:18:35 +01:00
f_prnt tit2 "réseau"
2018-02-23 17:07:39 +01:00
f_prnt 1 "$( sed -E 's/(.*)/**\1** /' <<< "$fe_cards_reseau" )" # mise en gras
2017-12-13 03:15:07 +01:00
f_prnt
2017-11-30 20:27:02 +01:00
# lspci -nnv
2017-12-15 01:18:35 +01:00
f_dspl cmd "$cards" "$cmd_cards"
2017-11-30 20:27:02 +01:00
# modules réseau
2017-12-15 01:18:35 +01:00
f_dspl cmd "$modEth" "$cmd_modEth" "$cmt_modEth"
f_dspl cmd "$modWln" "$cmd_modWln" "$cmt_modWln"
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$alert_wlx" "alert"
2017-11-30 20:27:02 +01:00
}
2018-03-09 07:12:34 +01:00
fi_nm(){ # 06/03/2018
local nm_etat cmd_nm_etat cmt_nm_etat nm_conf cmd_nm_conf cmt_nm_conf nm_wifis cmd_nm_wifis cmt_nm_wifis text
2017-12-01 21:50:07 +01:00
2018-03-09 07:12:34 +01:00
type -p nmcli &>/dev/null || return 0
2017-11-27 06:26:24 +01:00
nm_etat=$( f_grep_file "/var/lib/NetworkManager/NetworkManager.state" "notitre" )
2017-11-20 15:27:48 +01:00
cmd_nm_etat="grep -Ev '#|^$' /var/lib/NetworkManager/NetworkManager.state"
cmt_nm_etat="état de NetworkManager"
2017-11-24 18:00:20 +01:00
nm_conf=$( f_grep_file "/etc/NetworkManager/NetworkManager.conf /etc/NetworkManager/conf.d/*.conf" )
cmd_nm_conf="grep -Ev '#|^$' /etc/NetworkManager/NetworkManager.conf /etc/NetworkManager/conf.d/*.conf"
2017-11-20 15:27:48 +01:00
cmt_nm_conf="configuration de NetworkManager"
nm_wifis=$( LC_ALL=C nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list | head -n15 )
cmd_nm_wifis="nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list"
cmt_nm_wifis="wifis à proximité"
2018-03-09 07:12:34 +01:00
[ "$(f__wcv "-l" "$nm_wifis")" -eq 1 ] && unset nm_wifis # si jamais sortie entête quand pas de wifi, possible?
2017-12-01 21:50:07 +01:00
###
2017-12-15 01:18:35 +01:00
f_prnt tit2 "NetworkManager"
f_dspl cmd "$nm_etat" "$cmd_nm_etat" "$cmt_nm_etat"
f_dspl cmd "$nm_conf" "$cmd_nm_conf" "$cmt_nm_conf"
f_dspl cmd "$nm_wifis" "$cmd_nm_wifis" "$cmt_nm_wifis"
2017-08-26 09:05:54 +02:00
}
2017-08-06 02:43:48 +02:00
2018-02-09 06:07:03 +01:00
fi_packagers(){ # 23/11/2017
2017-11-18 18:34:57 +01:00
local alert_pkg_todo="ce gestionnaire de paquets n'est pas maîtrisé par manque d'expertise \n"
alert_pkg_todo+="vous êtes donc bienvenus à contribuer dans ce domaine: \n"
2017-11-17 17:25:36 +01:00
alert_pkg_todo+="https://framagit.org/kyodev/kyopages/blob/master/scripts/CONTRIB.md#getinfo"
2017-12-01 21:50:07 +01:00
2017-11-17 17:25:36 +01:00
if type -p dpkg &>/dev/null ; then # debian, buntu apt/dpkg
unset alert_pkg_todo # modèle, alert_pkg_todo pas implanté dans fi_pkg_apt
2017-11-24 18:00:20 +01:00
fi_pkg_apt "apt:apt/dpkg"
2017-11-17 17:25:36 +01:00
elif type -p dnf &>/dev/null || type -p yum &>/dev/null ; then # Fedora, RedHat (rpm)
2017-11-24 18:00:20 +01:00
fi_pkg_x "dnf:dnf/rpm"
2017-11-17 17:25:36 +01:00
elif type -p pacman &>/dev/null ; then # ArchLinux, Chakra Linux, Manjaro, KaOS, Parbola, Antergos, Apricity
fi_pkg_x "pacman:Pacman"
elif type -p pacman-g2 &>/dev/null ; then # Frugalware
fi_pkg_x "pacman-g2:Pacman-g2"
elif type -p emerge &>/dev/null ; then # Gentoo
2017-11-24 18:00:20 +01:00
fi_pkg_x "portage:portage/emerge"
2017-11-17 07:27:10 +01:00
elif type -p installpkg &>/dev/null || type -p slackpkg &>/dev/null ; then # Slackware, slackpkg gestion automatique paquets
2017-11-17 17:25:36 +01:00
fi_pkg_x "slackware:Slackware"
elif type -p zypper &>/dev/null ; then # Suse, openSuse
2017-11-24 18:00:20 +01:00
fi_pkg_x "zypper:zypper/rpm"
2017-11-17 17:25:36 +01:00
elif type -p alps &>/dev/null ; then # AryaLinux
fi_pkg_x "x:alps"
2017-11-17 07:27:10 +01:00
elif type -p eopkg &>/dev/null ; then # Solus Linux
2017-11-17 17:25:36 +01:00
fi_pkg_x "x:eopkg"
2017-11-17 07:27:10 +01:00
elif type -p guix &>/dev/null ; then # GNU Guix
2017-11-17 17:25:36 +01:00
fi_pkg_x "x:Guix"
2017-11-17 07:27:10 +01:00
elif type -p lvu &>/dev/null ; then # Lunar Linux
2017-11-17 17:25:36 +01:00
fi_pkg_x "x:lvu"
2017-11-17 07:27:10 +01:00
elif type -p nix-env &>/dev/null ; then # Nix: NixOs
2017-11-17 17:25:36 +01:00
fi_pkg_x "x:Nix"
2017-11-17 07:27:10 +01:00
elif type -p opkg &>/dev/null ; then # opkg fork ipkg, ipkg (abandonné) sauf sur Syno?
2017-11-17 17:25:36 +01:00
fi_pkg_x "x:opkg"
2017-11-17 07:27:10 +01:00
elif type -p sorcery &>/dev/null ; then # SourceMage
2017-11-17 17:25:36 +01:00
fi_pkg_x "x:Sorcery"
2017-11-17 07:27:10 +01:00
elif type -p tazpkg &>/dev/null ; then # SliTaz
2017-11-17 17:25:36 +01:00
fi_pkg_x "x:tazpkg"
2017-11-17 07:27:10 +01:00
elif type -p tce-status &>/dev/null ; then # TinyCoreLinux
2017-11-17 17:25:36 +01:00
fi_pkg_x "x:TinyCoreExtensions"
2017-11-17 07:27:10 +01:00
elif type -p xbps-query &>/dev/null ; then # VoidLinux
2017-11-17 17:25:36 +01:00
fi_pkg_x "x:VoidLinux"
2017-11-17 07:27:10 +01:00
else
2017-11-17 17:25:36 +01:00
fi_pkg_x "x:Inconnue"
2017-11-12 19:29:33 +01:00
fi
2017-11-12 08:33:05 +01:00
}
2017-11-12 19:29:33 +01:00
2018-03-09 07:12:34 +01:00
# shellcheck disable=SC2034
# SC2034 foo appears unused. Verify it or export it.
2018-04-08 16:34:59 +02:00
fi_pkg_apt(){ # 15/03/2018
2017-11-18 18:34:57 +01:00
local dateMaj nb_packages ifile info_update text pluriel
2018-01-28 08:16:30 +01:00
local sources cmt_sources cmd_sources result
local apt_v apt_version apt_prefs cmt_apt_prefs cmd_apt_prefs alert_non_pref
2017-11-20 15:27:48 +01:00
local stck_upgd qte_upgradable
local upgrade cmt_upgrade cmd_upgrade
2017-12-01 21:50:07 +01:00
local notUpgraded cmt_notUpgraded
2017-11-20 15:27:48 +01:00
local toRemove qte_toRemove cmt_toRemove cmd_toRemove
2018-03-09 07:12:34 +01:00
local autoclean qte_autoclean cmt_autoclean cmd_autoclean
local clean qte_clean cmt_clean cmd_clean size_cleanH
2017-11-20 15:27:48 +01:00
local non_ii qte_non_ii cmt_non_ii cmd_non_ii etat ligne stck_etat
local deborphan qte_deborphan cmt_deborphan cmd_deborphan
local holded qte_holded cmt_holded cmd_holded
2018-02-27 09:31:41 +01:00
local pinned tempo qte_pinned cmd_pinned cmt_pinned
2018-03-09 07:12:34 +01:00
local kernel cmd_kernel cmt_kernel
2017-11-19 21:16:02 +01:00
local alert_https alert_httpsPossible alert_non_list alert_httpredir alert_upgrade alert_full_upgrade
2017-11-20 17:03:18 +01:00
local alert_apt alert_remove alert_autoclean alert_clean alert_non_ii alert_deborphan
2017-12-01 21:50:07 +01:00
2017-12-03 13:48:03 +01:00
# sources
2018-01-28 08:16:30 +01:00
sources=$( f_grep_file "/etc/apt/sources.list /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/*.sources" "sources date" )
2017-11-20 15:27:48 +01:00
cmt_sources="dépôts"
2018-01-28 19:54:59 +01:00
cmd_sources="grep -Ersv '^#|^$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/*.sources"
2018-01-28 08:16:30 +01:00
# sources ignorées
result=$( f_policy "sources" )
if [ "$result" ] ; then
alert_non_list="ignoré: \n$result"
fi
unset result
# preferences
apt_prefs=$( f_grep_file "/etc/apt/preferences /etc/apt/preferences.d/*" "lignevide date" )
2018-01-28 19:54:59 +01:00
cmd_apt_prefs="grep -Erv '^#|^$' /etc/apt/preferences /etc/apt/preferences.d/"
2017-12-04 09:33:29 +01:00
cmt_apt_prefs="préférences apt"
2018-01-28 08:16:30 +01:00
# preferences ignorées
result=$( f_policy "preferences" )
if [ "$result" ] ; then
alert_non_pref="ignoré: \n$result"
fi
# essai confOnly
2017-12-03 13:48:03 +01:00
if [ "$1" == "confOnly" ]; then
2017-12-04 09:33:29 +01:00
local apt_unUpgrd cmd_unUpgrd cmd_apt_history essai
# 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"
2017-12-13 03:15:07 +01:00
if [ "$apt_unUpgrd" ]; then
info_unUpgrd="les logs spécifiques unattended-upgrades: "
info_unUpgrd+="**ls -l /var/log/unattended-upgrades/*.log**"
fi
f_dspl cmd "$sources" "$cmd_sources" "$cmt_sources"
f_dspl cmd "$apt_prefs" "$cmd_apt_prefs" "$cmt_apt_prefs"
f_dspl cmd "$apt_unUpgrd" "$cmd_unUpgrd" ".conf unattended-upgrades"
2017-12-04 09:33:29 +01:00
f_dspl_alrt "$info_unUpgrd" "info"
2017-12-13 03:15:07 +01:00
#f_dspl cmd "$( tail -n20 /var/log/syslog )" "$( tail -n20 /var/log/syslog )" "20 derniers logs"
#f_dspl cmd "$( tail -n25 /var/log/apt/history.log )" "tail -n25 /var/log/apt/history.log" "25 derniers historiques apt"
#f_dspl sans "$( f_grep_file "/var/log/unattended-upgrades/*.log" )"
2017-12-03 14:34:44 +01:00
IFS=$'\n'
2017-12-13 03:15:07 +01:00
# essai=( grep -B1 -A2 'unattended-upgrade' /var/log/apt/history.log )
2017-12-04 09:33:29 +01:00
# for i in "${!essai[@]}"; do
# for i in /var/log/unattended-upgrades/* ; do
# done
2017-12-13 03:15:07 +01:00
# f_dspl cmd $(echo "${essai[*]}") "$cmt_apt_history"
2017-12-03 14:34:44 +01:00
#echo ${#essai[*]}
#echo ${essai[3]}
IFS="$IFS_INI"
2017-12-04 09:33:29 +01:00
return 0
2017-12-03 13:48:03 +01:00
fi
2018-01-28 08:16:30 +01:00
2017-12-03 13:48:03 +01:00
# avertissement
2018-01-28 08:16:30 +01:00
info_update="apt update n'a pas été lancé, vérifier que la date de mise à jour ne soit pas trop ancienne."
2017-12-03 13:48:03 +01:00
# divers
2018-03-01 08:18:19 +01:00
dateMaj=$( date -r /var/lib/apt/lists '+%d/%m/%Y %H:%M %z' 2>/dev/null ) || dateMaj="n/a"
2018-02-26 13:26:50 +01:00
nb_packages=$( dpkg -l | grep -c '^ii' ) # alternatif: ls -1 /var/lib/dpkg/info/*.list | grep -c '\.list'
2017-11-19 16:16:41 +01:00
# https
2018-01-26 17:05:36 +01:00
apt_version=$( apt --version ) # apt 1.4.8 (i386)
apt_version=${apt_version#apt } # 1.4.8 (i386)
apt_version=${apt_version% (*} # 1.4.8
apt_v=${apt_version%.*} # 1.4
2018-02-26 13:26:50 +01:00
alert_https=$( awk '{if ( $1 > 1.5 ) {print "https inutile"}}' <<< "$apt_v" )
2018-01-26 17:05:36 +01:00
if f__requis_deb "apt-transport-https" && [ "$alert_https" ]; then
2017-11-19 17:29:13 +01:00
alert_https="le paquet <apt-transport-https> est inutile maintenant avec la version $apt_v d'apt (depuis 1.6)"
2017-11-19 16:16:41 +01:00
else
unset alert_https
2017-11-19 21:16:02 +01:00
fi
2018-02-26 13:26:50 +01:00
alert_httpsPossible=$( awk '{if ( $1 > 1.5 ) {print "https possible"}}' <<< "$apt_v" )
2017-11-19 21:16:02 +01:00
if [ "$alert_httpsPossible" ]; then
alert_httpsPossible="votre version d'apt ($apt_v) permet d'utiliser simplement les sources avec "
alert_httpsPossible+="le protocole https et les dépôts deb.debian.org"
2017-11-19 16:16:41 +01:00
fi
# httpredir
2018-02-23 17:07:39 +01:00
if grep -iq 'httpredir' <<< "$sources" ; then
2017-11-18 18:34:57 +01:00
alert_httpredir="ces urls sont obsolètes, préférer http://deb.debian.org/ ou un miroir local: \n\n"
2018-02-23 17:07:39 +01:00
alert_httpredir+=$( grep 'httpredir' <<< "$sources" )
2017-11-07 16:15:48 +01:00
fi
2017-12-05 14:28:41 +01:00
echo -n "◇"
2017-11-19 16:16:41 +01:00
# extraction qte ugrade, full-upgrade
2017-11-20 17:03:18 +01:00
stck_upgd=$( LC_ALL=C apt-get upgrade --simulate 2>/dev/null )
2017-11-18 18:34:57 +01:00
# $1 upgraded, $6 to remove, $10 not upgraded # => qte_upgradable [0]=upgraded, [1]=notUpgraded
2018-02-26 13:26:50 +01:00
qte_upgradable=( $( awk '/ newly installed/{print $1" "$10}' <<< "$stck_upgd" ) ) # tableau
2017-11-20 17:03:18 +01:00
[ "${qte_upgradable[0]}" ] || qte_upgradable=("-1" "-1") # si erreur
2017-11-18 18:34:57 +01:00
# upgrade
2018-03-09 07:12:34 +01:00
if [ $(( qte_upgradable[0] )) -gt 1 ]; then pluriel="s"; else unset pluriel; fi
cmt_upgrade="${qte_upgradable[0]} paquet$pluriel à mettre à jour"
2017-11-20 15:27:48 +01:00
[ "${qte_upgradable[0]}" -eq 0 ] && cmt_upgrade=${cmt_upgrade/0 /aucun }
2018-04-08 16:34:59 +02:00
# /!\ apt list --upgradable ne tient pas compte des paquets figés dans preferences (et holded?) et
# donc résultat > à apt-get upgrade --simulate | grep -c '^Inst '
cmd_upgrade="apt-get upgrade --simulate"
2017-11-18 18:34:57 +01:00
if [ "${qte_upgradable[0]}" -gt 0 ]; then
2018-02-26 13:26:50 +01:00
upgrade=$( grep '^Inst' <<< "$stck_upgd" | sort | awk '{
2018-01-28 22:35:30 +01:00
paquet=$2; paquet=substr(paquet,1,30)
2018-01-28 08:16:30 +01:00
sub(/\[/,"",$3); sub(/\]/,"",$3); $3=substr($3,1,20); ver_ini=$3
sub(/\(/,"",$4); $4=substr($4,1,20); ver_final=$4
$1=$2=$3=$4=""
source=$0; sub(/\/.*/,"",source); gsub(/\[.*\]/,"",source); gsub(/\)/,"",source)
gsub(/^ */,"",source);gsub(/,/,", ",source)
2018-01-28 22:35:30 +01:00
printf "%-30s %-20s ⇉ %-20s %s \n",paquet,ver_ini,ver_final,source
2018-01-28 08:16:30 +01:00
}')
2017-11-19 21:16:02 +01:00
alert_upgrade="ces paquets peuvent être mis à jour avec: **apt upgrade**"
2017-11-20 17:03:18 +01:00
elif [ "${qte_upgradable[0]}" -lt 0 ]; then
upgrade="• erreur apt, les paquets à mettre à jour ne peuvent être déterminés"
2018-01-28 19:54:59 +01:00
alert_apt="Erreur apt, vérifier avec **apt update ; apt upgrade** et analyser les messages"
2017-11-17 07:27:10 +01:00
fi
# full-upgrade
2017-11-17 17:25:36 +01:00
if [ "${qte_upgradable[1]}" -gt 0 ]; then
2017-11-20 15:27:48 +01:00
notUpgraded=${stck_upgd%The following packages will be upgraded*} # suppression fin
2018-02-27 09:31:41 +01:00
notUpgraded=${notUpgraded#*The following packages have been kept back:} # suppression début
2017-11-18 22:36:30 +01:00
notUpgraded=$( sed '/newly/d' <<< "$notUpgraded" | sort | tr '\n' ' ' )
2018-02-27 09:31:41 +01:00
notUpgraded=${notUpgraded// / } # suppression espace double
2018-03-09 07:12:34 +01:00
if [ $(( qte_upgradable[1] )) -gt 1 ]; then pluriel="s"; else unset pluriel; fi
cmt_notUpgraded="${qte_upgradable[1]} paquet$pluriel nécessitant une mise à jour profonde (dist-upgrade)"
2018-01-28 08:16:30 +01:00
alert_full_upgrade="ces paquets peuvent être mis à jour avec avec: **apt dist-upgrade**"
2017-11-17 07:27:10 +01:00
fi
2017-12-05 14:28:41 +01:00
echo -n "◇"
2017-11-07 16:15:48 +01:00
# autoremove
2017-11-17 07:27:10 +01:00
toRemove=$( LC_ALL=C apt-get autoremove --simulate | grep -E 'Remv | newly installed' )
2018-02-23 17:07:39 +01:00
toRemove=$( sort <<< "$toRemove" )
2018-02-26 13:26:50 +01:00
qte_toRemove=$( awk '/ newly installed/{ printf $6 }' <<< "$toRemove" )
2017-11-17 07:27:10 +01:00
toRemove=$( sed '/newly/d' <<< "$toRemove" ) # suppression ligne état
2018-03-09 07:12:34 +01:00
if [ $(( qte_toRemove )) -gt 1 ]; then pluriel="s"; else unset pluriel; fi
cmt_toRemove="$qte_toRemove paquet$pluriel inutile"$pluriel
2017-11-20 15:27:48 +01:00
[ "$qte_toRemove" -eq 0 ] && cmt_toRemove=${cmt_toRemove/0 /aucun }
2018-01-28 08:16:30 +01:00
cmd_toRemove="apt autoremove"
2017-11-17 17:25:36 +01:00
if [ "$qte_toRemove" -gt 0 ]; then
2018-02-23 17:07:39 +01:00
toRemove=$( sed -E '/^Remv/!d; s/\[.*\]//g; s/Remv //' <<< "$toRemove" | tr '\n' ' ' )
2017-11-17 07:27:10 +01:00
toRemove=${toRemove// / }
2018-01-28 08:16:30 +01:00
alert_remove="les paquets peuvent être supprimés avec: **apt autoremove --purge** \n"
2017-11-18 18:34:57 +01:00
alert_remove+="vérifier que la liste ne contient pas des applications devenues importantes \n"
alert_remove+="au besoin, les marquer comme installées manuellement avec apt-mark manual <paquet> \n"
2017-11-10 21:06:23 +01:00
alert_remove+="ou les installer manuellement avec apt install <paquet>"
2017-11-07 16:15:48 +01:00
fi
2017-11-20 15:27:48 +01:00
# autoclean
2017-12-05 14:28:41 +01:00
echo -n "◇"
2018-03-01 08:18:19 +01:00
autoclean=$( LC_ALL=C apt-get autoclean --simulate 2>/dev/null | awk '/^Del/{print $2}' | sort | tr '\n' ' ' )
qte_autoclean=$( f__wcv -w "$autoclean" )
2018-03-09 07:12:34 +01:00
if [ "$qte_autoclean" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
cmt_autoclean="$qte_autoclean archive$pluriel périmée"$pluriel
2017-11-20 15:27:48 +01:00
[ "$qte_autoclean" -eq 0 ] && cmt_autoclean=${cmt_autoclean/0 /aucune }
2018-01-28 08:16:30 +01:00
cmd_autoclean="apt autoclean"
2017-11-18 18:34:57 +01:00
if [ "$qte_autoclean" -gt 0 ]; then
alert_autoclean="ces archives de paquets, sans utilité directe dans le système, "
2017-11-19 21:16:02 +01:00
alert_autoclean+="peuvent être supprimées avec: **apt autoclean**"
2017-11-18 18:34:57 +01:00
fi
# clean
2018-01-28 08:16:30 +01:00
clean=$( LC_ALL=C du -chS /var/cache/apt/archives/ 2>/dev/null )
2018-04-08 16:34:59 +02:00
clean=$( f__unit_french "$clean" )
2017-11-18 18:43:37 +01:00
size_cleanH=$( du -chS /var/cache/apt/archives/ 2>/dev/null | grep -i 'total' ) # affichage en human
2017-11-18 18:34:57 +01:00
size_cleanH=${size_cleanH%[[:blank:]]total}
2018-04-08 16:34:59 +02:00
size_cleanH=$( f__unit_french "$size_cleanH" )
2017-12-13 03:15:07 +01:00
qte_clean=$( f__dir -c /var/cache/apt/archives "lock|partial" )
2018-03-09 07:12:34 +01:00
if [ "$qte_clean" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
2017-11-20 15:27:48 +01:00
cmt_clean="taille du cache des paquets"
2017-11-18 18:34:57 +01:00
cmd_clean="du -chS /var/cache/apt/archives/"
2017-12-13 03:15:07 +01:00
if [ "$qte_clean" -gt 0 ]; then # alerte si > à 100 ko (cache pas vide)
2018-03-09 07:12:34 +01:00
alert_clean="$qte_clean archive$pluriel dans le cache de téléchargement des paquets \n"
2017-11-19 21:16:02 +01:00
alert_clean+="$size_cleanH pourraient être libérés en effaçant ce cache: **apt clean**"
2017-11-18 23:12:12 +01:00
else # cache vide (72ko à 120ko)
2017-11-18 18:34:57 +01:00
clean="• cache vide"
fi
2017-11-07 16:15:48 +01:00
# paquet non ^ii
2018-02-26 13:26:50 +01:00
non_ii=$( LC_ALL=C dpkg -l | awk 'FNR>5 && ! /^i/ {
2017-12-09 22:27:46 +01:00
printf "%-3s %-25s %-12s",$1,$2,$3; $1=$2=$3=$4=""; printf "%s \n",$0 }' )
2017-11-17 17:25:36 +01:00
qte_non_ii=$( f__wcv -l "$non_ii" )
2018-03-09 07:12:34 +01:00
if [ "$qte_non_ii" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
cmt_non_ii="$qte_non_ii paquet$pluriel dans un état non standard (^ii)"
2017-11-20 15:27:48 +01:00
[ "$qte_non_ii" -eq 0 ] && cmt_non_ii=${cmt_non_ii/0 /aucun }
2018-02-26 13:26:50 +01:00
cmd_non_ii="dpkg -l | grep -v '^ii'" # dpkg -l | awk '! /^ii/ {print $0}'
2017-11-17 17:25:36 +01:00
if [ "$qte_non_ii" -gt 0 ]; then
2017-11-17 07:27:10 +01:00
# extraction différents états constatés
2017-12-13 03:15:07 +01:00
while read -r etat ligne ; do
2017-11-20 15:27:48 +01:00
stck_etat+="$etat"$'\n'
2017-11-17 07:27:10 +01:00
done <<< "$non_ii"
2017-11-20 15:27:48 +01:00
stck_etat=$( sort -u <<< "$stck_etat" ) # tri et dédoublonnage
2017-11-17 07:27:10 +01:00
non_ii+="\n\n ‣ État souhaité / État du paquet / Drapeaux d'erreur\n"
2017-11-20 15:27:48 +01:00
for ligne in $stck_etat; do
2017-11-17 07:27:10 +01:00
[[ ${ligne,,} =~ ^h ]] && non_ii+=" h: hold (à garder) "
[[ ${ligne,,} =~ ^i ]] && non_ii+=" i: install (à installer) "
[[ ${ligne,,} =~ ^p ]] && non_ii+=" p: purge (à purger) "
[[ ${ligne,,} =~ ^r ]] && non_ii+=" r: remove (à supprimer) "
[[ ${ligne,,} =~ ^u ]] && non_ii+=" u: unknown (inconnu) "
2017-11-18 18:34:57 +01:00
[[ ${ligne,,} =~ ^.c ]] && non_ii+=" c: config-files (fichiers de configuration) "
[[ ${ligne,,} =~ ^.f ]] && non_ii+=" f: halF-configured-configured (semi-configuré) "
[[ ${ligne,,} =~ ^.h ]] && non_ii+=" h: Half-installed (semi-installé) "
[[ ${ligne,,} =~ ^.i ]] && non_ii+=" i: installed (installé) "
[[ ${ligne,,} =~ ^.n ]] && non_ii+=" n: not-installed (non installé) "
[[ ${ligne,,} =~ ^.t ]] && non_ii+=" t: triggers-pending (actions différées en cours) "
[[ ${ligne,,} =~ ^.u ]] && non_ii+=" u: unpacked (décompressé seulement) "
[[ ${ligne,,} =~ ^.w ]] && non_ii+=" w: triggers-awaiting (attente actions différées) "
[[ ${ligne,,} =~ ^..r ]] && non_ii+=" r: (réinstallation requise) " || non_ii+=" / . "
2017-11-17 07:27:10 +01:00
non_ii+=$'\n'
done
non_ii=${non_ii::-1} # suppression $'\n'
2017-11-20 15:27:48 +01:00
if grep -q '^rc' <<< "$stck_etat"; then
2017-11-18 18:34:57 +01:00
alert_non_ii="les paquets dans un état 'rc' (fichiers de configuration orphelins) "
alert_non_ii+="peuvent être purgés avec: \n"
2017-11-19 21:16:02 +01:00
alert_non_ii+="**dpkg --purge \$(dpkg -l | awk '/^rc/{print \$2}')**"
2017-11-18 18:34:57 +01:00
fi
2017-11-17 07:27:10 +01:00
fi
2017-11-18 18:34:57 +01:00
# deborphan éventuel
2018-03-09 07:12:34 +01:00
if type -p deborphan &>/dev/null ; then
2017-11-17 07:27:10 +01:00
deborphan=$( deborphan -P )
2017-11-18 18:34:57 +01:00
cmd_deborphan="deborphan -P"
2017-11-17 17:25:36 +01:00
qte_deborphan=$( f__wcv "-l" "$deborphan" )
2018-03-09 07:12:34 +01:00
if [ "$qte_deborphan" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
cmt_deborphan="$qte_deborphan bibliothèque$pluriel orpheline"$pluriel
2017-11-20 15:27:48 +01:00
[ "$qte_deborphan" -eq 0 ] && cmt_deborphan=${cmt_deborphan/0 /aucune }
2017-11-17 17:25:36 +01:00
if [ "$qte_deborphan" -gt 0 ]; then
2018-03-09 07:12:34 +01:00
alert_deborphan="bibliothèque$pluriel orpheline$pluriel, suppression possible: \n"
2017-11-19 21:16:02 +01:00
alert_deborphan+="**apt purge \$(deborphan)** \n"
2017-11-18 18:34:57 +01:00
alert_deborphan+="recherche légère, mais vérifier avant de valider la suppression \n"
2017-11-17 18:38:39 +01:00
alert_deborphan+="Relancer la commande jusqu'à vidage complet, les bibliothèques pouvant "
2017-11-18 18:34:57 +01:00
alert_deborphan+="s'installer en cascade"
2017-11-10 21:06:23 +01:00
fi
2017-10-12 21:49:57 +02:00
fi
2018-02-20 03:59:50 +01:00
# paquets figés (hold)
2018-03-01 08:18:19 +01:00
holded=$( apt-mark showhold | sort | tr '\n' ' ')
qte_holded=$( f__wcv "-w" "$holded" )
2018-03-09 07:12:34 +01:00
if [ "$qte_holded" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
cmt_holded="$qte_holded paquet$pluriel figé"$pluriel
2017-11-20 15:27:48 +01:00
[ "$qte_holded" -eq 0 ] && cmt_holded=${cmt_holded/0 /aucun }
2017-11-18 18:34:57 +01:00
cmd_holded="apt-mark showhold"
2018-02-20 03:59:50 +01:00
# paquets épinglés (pinning)
2018-02-27 09:31:41 +01:00
pinned=$( apt-cache policy | grep '\->' )
while read -r ; do
2018-03-03 07:40:41 +01:00
f__trim "REPLY"
2018-02-27 09:31:41 +01:00
tempo+="$REPLY"$'\n'
done <<< "$pinned"
pinned="${tempo::-1}"
2018-02-20 03:59:50 +01:00
qte_pinned=$( f__wcv "-l" "$pinned" )
2018-03-09 07:12:34 +01:00
if [ "$qte_pinned" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
2018-02-20 03:59:50 +01:00
cmd_pinned="apt-cache policy | grep '\->'"
cmt_pinned="résultat effectif épinglage paquet"$pluriel
2017-12-07 18:06:12 +01:00
# kernel
2018-03-09 07:12:34 +01:00
#~ meta abandonné, le temps de comprendre ubuntu?
2017-12-09 22:27:46 +01:00
# metaPkg=$( dpkg -l | grep -i -E 'linux-(image|headers)-([0-9]{3}|amd)' )
2018-03-09 07:12:34 +01:00
#~ metaPkg=$( dpkg -l | awk '
#~ /linux-(image|headers)-([0-9]{3}|amd)/ {
#~ printf "%-3s %-30s %s ",$1, $2, $3
#~ $1=$2=$3=$4=""; print $0
#~ }' )
#~ cmd_metaPkg="dpkg -l | grep -i -E 'linux-(image|headers)-([0-9]{3}|amd)'"
#~ cmt_metaPkg="métapaquet noyau"
2018-02-26 13:26:50 +01:00
kernel=$( dpkg -l | awk '
2018-03-09 07:12:34 +01:00
/linux-(headers|image)-'"$(uname -r)"'/ {
2018-02-26 13:26:50 +01:00
printf "%-3s %-30s %s ",$1, $2, $3
$1=$2=$3=$4=""; print $0
}' )
2018-03-09 07:12:34 +01:00
cmd_kernel="dpkg -l | grep -i -E \"linux-(headers|image)-\$(uname -r)\""
2017-12-07 18:06:12 +01:00
cmt_kernel="noyau"
2017-11-17 07:27:10 +01:00
###
2017-12-15 01:18:35 +01:00
f_prnt tit2 "gestion de paquets ${1#*:}"
f_prnt 1 "nombre de paquets installés: **$nb_packages**"
f_prnt 1 "dernière mise à jour apt: **$dateMaj**"
f_prnt 1 "version apt: **$apt_version**"
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$info_update" "info"
2018-01-28 08:16:30 +01:00
f_prnt
2017-12-15 01:18:35 +01:00
f_dspl cmd "$sources" "$cmd_sources" "$cmt_sources"
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$alert_https" "info"
f_dspl_alrt "$alert_httpsPossible" "info"
f_dspl_alrt "$alert_non_list" "info"
f_dspl_alrt "$alert_httpredir" "info"
2017-12-15 01:18:35 +01:00
f_dspl cmd "$apt_prefs" "$cmd_apt_prefs" "$cmt_apt_prefs"
2018-01-28 08:16:30 +01:00
f_dspl_alrt "$alert_non_pref" "info"
2017-12-15 01:18:35 +01:00
f_dspl cmd:vide "$upgrade" "$cmd_upgrade" "$cmt_upgrade"
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$alert_upgrade" "info"
f_dspl_alrt "$alert_apt" "alerte"
2018-02-07 13:27:59 +01:00
f_dspl var "$notUpgraded" " " "$cmt_notUpgraded"
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$alert_full_upgrade" "info"
2017-12-15 01:18:35 +01:00
f_dspl cmd:vide "$toRemove" "$cmd_toRemove" "$cmt_toRemove"
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$alert_remove" "info"
2017-12-15 01:18:35 +01:00
f_dspl cmd:vide "$autoclean" "$cmd_autoclean" "$cmt_autoclean"
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$alert_autoclean" "info"
2017-12-15 01:18:35 +01:00
f_dspl cmd "$clean" "$cmd_clean" "$cmt_clean"
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$alert_clean" "info"
2017-12-15 01:18:35 +01:00
f_dspl cmd:vide "$non_ii" "$cmd_non_ii" "$cmt_non_ii"
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$alert_non_ii" "info"
2018-03-09 07:12:34 +01:00
f_dspl cmd "$deborphan" "$cmd_deborphan" "$cmt_deborphan"
f_dspl_alrt "$alert_deborphan" "info"
2017-12-15 01:18:35 +01:00
f_dspl cmd:vide "$holded" "$cmd_holded" "$cmt_holded"
2018-02-20 03:59:50 +01:00
f_dspl cmd:vide "$pinned" "$cmd_pinned" "$cmt_pinned"
2018-03-09 07:12:34 +01:00
#~ f_dspl cmd "$metaPkg" "$cmd_metaPkg" "$cmt_metaPkg"
f_dspl cmd "$kernel" "$cmd_kernel" "$cmt_kernel"
2017-08-06 02:43:48 +02:00
}
2018-03-09 07:12:34 +01:00
fi_pkg_x(){ # 05/03/2018
2017-11-17 17:25:36 +01:00
local nb_packages cmd_nbPackages sources cmd_sources holded cmd_holded
2017-12-01 21:50:07 +01:00
2017-11-17 17:25:36 +01:00
if [[ ${1%:*} == "dnf" ]]; then # Fedora, RedHat (rpm)
nb_packages=$( LC_ALL=C dnf list installed 2>/dev/null ) # nb_packages=$( f__wcv -l "$( rpm -qa 2>/dev/null )")
nb_packages=${nb_packages#*Installed Packages} # suppression début variable jusqu'à Installed...
cmd_nbPackages="dnf list installed"
sources=$( f_grep_file "/etc/yum.repos.d/*.repo" )
cmd_sources="grep -Ersv '^#|^$' /etc/yum.repos.d/*.repo"
elif [[ ${1%:*} == "pacman" ]]; then # ArchLinux
nb_packages=$( pacman -Q &>/dev/null ) # pas d'exemple de sortie trouvé
cmd_nbPackages="pacman -Q"
sources=$( f_grep_file "/etc/pacman.conf /etc/pacman.d/*" )
cmd_sources="grep -Ersv '^#|^$' /etc/pacman.conf /etc/pacman.d/*"
elif [[ ${1%:*} == "pacman-g2" ]]; then # Frugalware
nb_packages=$( pacman-g2 -Q &>/dev/null ) # pas d'exemple de sortie trouvé
cmd_nbPackages="pacman-g2 -Q"
sources=$( f_grep_file "/etc/pacman.conf /etc/pacman.d/*" ) # coup de bluff
cmd_sources="grep -Ersv '^#|^$' /etc/pacman.conf /etc/pacman.d/*"
elif [[ ${1%:*} == "portage" ]]; then # Gentoo # Sabayon: + Entropy ?
nb_packages=$( emerge -ep world &>/dev/null ) # pas d'exemple de sortie trouvé
cmd_nbPackages="emerge -ep world"
sources=$( f_grep_file "/etc/portage/repos.conf /etc/portage/repos.conf/*" )
cmd_sources="grep -Ersv '^#|^$' /etc/portage/repos.conf /etc/portage/repos.conf/*"
elif [[ ${1%:*} == "slackware" ]]; then # Slackware
2017-12-13 03:15:07 +01:00
nb_packages=$( f__dir -c /var/log/packages )
2018-02-26 13:26:50 +01:00
cmd_nbPackages="ls -1 /var/log/packages/ | wc -l"
2017-11-17 17:25:36 +01:00
sources=$( f_grep_file "/etc/slackpkg/mirrors" )
cmd_sources="grep -Ersv '^#|^$' /etc/slackpkg/mirrors"
elif [[ ${1%:*} == "zypper" ]]; then # Suse, openSuse
nb_packages=$( zypper search --installed-only 2>/dev/null | grep '^i' ) # # nb_packages=$( f__wcv -l "$( rpm -qa 2>/dev/null )")
cmd_nbPackages="zypper search --installed-only"
sources=$( f_grep_file "/etc/zypp/repos.d/*.repo" )
cmd_sources="grep -Ersv '^#|^$' /etc/zypp/repos.d/*.repo"
holded=$( zypper locks 2>/dev/null )
cmd_holded="zypper locks"
elif [[ ${1#*:} == "alps" ]]; then # AryaLinux
2017-11-14 09:18:06 +01:00
nb_packages=$( alps showinstalled &>/dev/null )
2017-11-17 17:25:36 +01:00
cmd_nbPackages="alps showinstalled"
elif [[ ${1#*:} == "eopkg" ]]; then # Solus Linux
2017-12-13 03:15:07 +01:00
nb_packages=$( f__dir -c /var/lib/eopkg/package )
2018-02-26 13:26:50 +01:00
cmd_nbPackages="ls -1 /var/lib/eopkg/package/ | wc -l"
2017-11-17 17:25:36 +01:00
elif [[ ${1#*:} == "Guix" ]]; then # Gnu Guix
2018-03-09 07:12:34 +01:00
nb_packages=$( f__dir -c /gnu/store/*/ )
2018-02-26 13:26:50 +01:00
cmd_nbPackages="ls -1 /gnu/store/*/ | wc -l"
2017-11-17 17:25:36 +01:00
elif [[ ${1#*:} == "lvu" ]]; then # LunarLinux
nb_packages=$( lvu installed 2>/dev/null )
cmd_nbPackages="lvu installed"
elif [[ ${1#*:} == "Nix" ]]; then # NixOs
2018-03-09 07:12:34 +01:00
nb_packages=$( f__dir -c /nix/store/*/ )
2018-02-26 13:26:50 +01:00
cmd_nbPackages="ls -1 /nix/store/*/ | wc -l"
2017-11-17 17:25:36 +01:00
elif [[ ${1#*:} == "opkg" ]]; then # opkg fork ipkg, ipkg (abandonné) sauf sur Syno?
nb_packages=$( opkg list-installed 2>/dev/null )
cmd_nbPackages="opkg list-installed"
elif [[ ${1#*:} == "Sorcery" ]]; then # SourceMage (sorcerer)
nb_packages=$( gaze installed 2>/dev/null )
cmd_nbPackages="gaze installed"
elif [[ ${1#*:} == "tazpkg" ]]; then # SliTaz
nb_packages=$( tazpkg list 2>/dev/null )
cmd_nbPackages="tazpkg list"
elif [[ ${1#*:} == "TinyCoreExtensions" ]]; then # TinyCoreLinux
nb_packages=$( tce-status -i 2>/dev/null )
cmd_nbPackages="tce-status -i"
2017-11-14 09:18:06 +01:00
sources=$( f_grep_file "/opt/tcemirror" )
cmd_sources="/opt/tcemirror"
2017-11-17 17:25:36 +01:00
elif [[ ${1#*:} == "VoidLinux" ]]; then # VoidLinux
nb_packages=$( xbps-query -l 2>/dev/null )
cmd_nbPackages="xbps-query"
2017-11-14 09:18:06 +01:00
sources=$( f_grep_file "/etc/xbps.d/* /usr/share/xbps.d/*" )
2017-11-17 17:25:36 +01:00
cmd_sources="grep -Ersv '^#|^$' /etc/xbps.d/* /usr/share/xbps.d/*"
2017-11-12 19:29:33 +01:00
fi
2017-11-25 19:39:57 +01:00
nb_packages=$( f__wcv -l "$nb_packages" )
2017-11-17 17:25:36 +01:00
[[ -z "$nb_packages" || "$nb_packages" -le 5 ]] && nb_packages="n/a"
[[ ${1#*:} == "Inconnue" ]] && unset nb_packages # totalement inconnu
2017-12-01 21:50:07 +01:00
###
2017-12-15 01:18:35 +01:00
f_prnt tit2 "gestion de paquets ${1#*:}"
f_dspl cmd:text "$nb_packages" "$cmd_nbPackages" "nombre de paquets installés"
f_dspl cmd "$sources" "$cmd_sources" "sources"
f_dspl cmd "$holded" "$cmd_holded" "paquets figés"
f_dspl var "$alert_pkg_todo" "aide souhaitée"
2017-11-12 19:29:33 +01:00
}
2018-03-09 07:12:34 +01:00
fi_reseau(){ # 06/03/2018 ( configuration )
2018-02-09 18:45:09 +01:00
local ip4 gw4 ip4_p ip6 gw6 ip_a route netplan interfaces resolv iwconfig canal_wifi text pluriel
local imgr netmgrinst netmgrrun ipa adr_temp slaac slaac_mac
local alert_ifconfig alert_slaac
declare -A netmgr=(
["NetworkManager"]="/usr/sbin/NetworkManager"
["Wicd"]="/usr/sbin/wicd"
["ConnMan"]="/usr/sbin/connmand"
)
2018-03-09 07:12:34 +01:00
2018-02-09 18:45:09 +01:00
# ipv4
figet_ip "-4"
ip4="$fg_ip"
gw4="$fg_gws"
ip4_p="$fg_ifn_prior"
# ipv6
figet_ip "-6"
ip6="$fg_ip"
gw6="$fg_gws"
2017-11-17 07:27:10 +01:00
# ip a & route
2017-12-11 16:21:06 +01:00
ip_a=$( ip a | sed '/link\/ether/d; /link\/loopback.*/d' ) # filtre adr MAC link (lo)
2018-02-09 18:45:09 +01:00
ip_a=$( sed '/valid_lft forever preferred_lft forever/d;
2018-02-23 17:07:39 +01:00
/temporary deprecated dynamic/d; /preferred_lft 0sec/d' <<< "$ip_a" )
2018-02-26 13:26:50 +01:00
route=$( ip -4 route show | sort )$'\n\n'
2017-12-11 16:21:06 +01:00
route+=$( ip -6 route show )
2018-02-09 18:45:09 +01:00
# netplan (ubuntu)
netplan=$( f_grep_file "etc/netplan/*.yaml" )
2017-11-17 07:27:10 +01:00
# interfaces & resolv
2017-11-25 19:39:57 +01:00
interfaces=$( f_grep_file "/etc/network/interfaces*" )
2018-02-23 17:07:39 +01:00
interfaces=$( sed -E 's/wpa-psk [[:graph:]]+/wpa-psk <WPA key removed>/; s/:/: /' <<< "$interfaces" )
2017-11-27 06:26:24 +01:00
resolv=$( f_grep_file "/etc/resolv.conf" "notitre" )
2017-12-07 18:06:12 +01:00
# iwconfig (/sbin)
2018-03-09 07:12:34 +01:00
iwconfig=$( LC_ALL=C iwconfig 2>/dev/null ) #paquet wireless-tools requis
# iwlist (/sbin) canal wifi utilisé paquet wireless-tools requis
canal_wifi=$( LC_ALL=C iwlist chan 2>/dev/null | grep 'Current Frequency' | grep -Eio 'channel [0-9]+' )
2017-12-11 16:21:06 +01:00
# manager réseaux
2018-03-09 07:12:34 +01:00
for imgr in "${!netmgr[@]}"; do
2017-12-11 16:21:06 +01:00
if [ -e "${netmgr[$imgr]}" ]; then
netmgrinst+="$imgr "
fi
2018-02-26 13:26:50 +01:00
if ps -e | grep -iq "$imgr" ; then
2018-02-20 03:59:50 +01:00
netmgrrun+="$imgr "
2017-11-17 07:27:10 +01:00
fi
done
2017-12-11 16:21:06 +01:00
netmgrinst=${netmgrinst% } # suppression dernier espace
2018-02-20 03:59:50 +01:00
netmgrrun=${netmgrrun% } # suppression dernier espace
[ "$netmgrinst" == "$netmgrrun" ] && unset netmgrinst
2017-12-11 16:21:06 +01:00
# alertes
2018-03-09 07:12:34 +01:00
if type -p ifconfig &>/dev/null ; then
2017-11-17 07:27:10 +01:00
alert_ifconfig="ifconfig [net-tools](https://github.com/giftnuss/net-tools) est un projet abandonné "
alert_ifconfig+="depuis des années. iproute2 (linuxfoundation) le remplace."
fi
2018-02-09 18:45:09 +01:00
# slaac ipv6
2017-12-11 16:21:06 +01:00
for ipa in $ip6 ; do
if grep -q 'ff:fe:' <<< "$ipa"; then
adr_temp=$( grep -o '^.*ff:fe:.* (.*$' <<< "$ipa" )
adr_temp=${adr_temp%/*}
slaac+="$adr_temp"$'\n'
adr_temp=${adr_temp#*: }
slaac_mac+=${adr_temp/ff:fe:}
fi
done
if [ "$slaac" ]; then
2018-03-09 07:12:34 +01:00
if [ "$( f__wcv -l "$slaac" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
2017-12-11 16:21:06 +01:00
slaac_mac=${slaac_mac% ø } # suppression dernier ' ø '
slaac=${slaac%[[:cntrl:]]} # suppression dernier $'\n'
2018-03-09 07:12:34 +01:00
alert_slaac="adresse$pluriel ipv6 autoconfigurée$pluriel (mode SLAAC): \n"
2017-12-11 16:21:06 +01:00
alert_slaac+="$slaac\n"
2018-03-09 07:12:34 +01:00
alert_slaac+="mais adresse$pluriel MAC ($slaac_mac) visible$pluriel. cela permet potentiellement de "
2017-12-11 16:21:06 +01:00
alert_slaac+="suivre et de tracer ce PC sur les réseaux. \n"
alert_slaac+="à vérifier si cet état est souhaité."
fi
2017-11-17 07:27:10 +01:00
###
2017-12-15 01:18:35 +01:00
f_prnt tit2 "configuration"
2017-12-13 03:15:07 +01:00
f_prnt code
2017-12-15 01:18:35 +01:00
f_prnt l1 "ipv4"
2018-02-23 17:07:39 +01:00
f_prnt l2 "$ip4" '[ "$ip4" ]'
2017-12-13 03:15:07 +01:00
f_prnt
2018-03-09 07:12:34 +01:00
if [ "$(f__wcv "-l" "$gw4")" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
f_prnt l2 "passerelle$pluriel: ${gw4//$'\n'/ ⊗ }" '[ "$gw4" ]'
2017-12-13 03:15:07 +01:00
f_prnt
2017-12-11 16:21:06 +01:00
figet_ip "-6"
2017-12-15 01:18:35 +01:00
f_prnt l1 "ipv6"
2018-02-23 17:07:39 +01:00
f_prnt l2 "$ip6" '[ "$ip6" ]'
2017-12-13 03:15:07 +01:00
f_prnt
2018-03-09 07:12:34 +01:00
if [ "$(f__wcv "-l" "$gw6")" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
f_prnt l2 "passerelle$pluriel: ${gw6//$'\n'/ ⊗ }" '[ "$gw6" ]'
2017-12-16 23:31:32 +01:00
f_prnt
2018-03-09 07:12:34 +01:00
if [ "$(f__wcv "-w" "$fg_ifn_prior")" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
f_prnt l1 "interface$pluriel sortante$pluriel:"
2018-02-09 18:45:09 +01:00
f_prnt l2 "ipv6: $fg_ifn_prior" '[ "$fg_ifn_prior" ]' # proto -6 dernier appel à figet_ip
f_prnt l2 "ipv4: $ip4_p" '[ "$ip4_p" ]'
2017-12-13 03:15:07 +01:00
f_prnt code
f_prnt
2017-12-15 01:18:35 +01:00
f_prnt 1 "les adresses Mac peuvent être affichées avec \`$DIRNAME""getInfo --mac\`"
f_prnt 1 "l'IP publique peut être connue avec: \`$DIRNAME""getInfo --ip\`"
2018-02-09 18:45:09 +01:00
f_prnt
# ipv6 dépréciées
2018-02-22 01:26:29 +01:00
f_prnt code "" '[ "$fg_ip_deprec" ]'
f_prnt l1 "ipv6 dépréciées" '[ "$fg_ip_deprec" ]'
2018-02-23 17:07:39 +01:00
f_prnt l2 "$fg_ip_deprec" '[ "$fg_ip_deprec" ]'
2018-02-22 01:26:29 +01:00
f_prnt code "" '[ "$fg_ip_deprec" ]'
2017-12-13 03:15:07 +01:00
f_prnt
2017-11-17 07:27:10 +01:00
# ip a & route & interface & resolv
2017-12-15 01:18:35 +01:00
f_dspl cmd "$ip_a" "ip address"
2017-12-13 03:15:07 +01:00
f_dspl cmd "$route" "ip route show"
2018-02-09 18:45:09 +01:00
f_dspl cmd "$netplan" "grep -EHrsv '#|^$' etc/netplan/*.yaml" "netplan ubuntu"
2017-12-15 01:18:35 +01:00
f_dspl cmd "$interfaces" "grep -EHrsv '#|^$' /etc/network/interfaces*" "configuration manuelle"
f_dspl cmd "$resolv" "cat /etc/resolv.conf" "serveurs de noms DNS utilisés"
2017-11-17 07:27:10 +01:00
# iwconfig & iwlist
2017-12-15 01:18:35 +01:00
f_dspl cmd "$iwconfig" "/sbin/iwconfig 2>/dev/null" "état carte wifi"
f_dspl cmd "$canal_wifi" "/sbin/iwlist chan | grep 'Current Frequency' | grep -Eio 'channel [0-9]+'" \
"canal wifi utilisé"
2018-02-22 01:26:29 +01:00
f_prnt 1 "la configuration ssid utilisée peut être connue (si NetworkManager installé) avec \n \`$DIRNAME""getInfo --ssid\`" '[ "$iwconfig" ]'
2017-12-13 03:15:07 +01:00
f_prnt
2017-11-17 07:27:10 +01:00
# network manager
2018-02-20 03:59:50 +01:00
f_prnt 1 "gestionnaire de réseau" '[ "$netmgrrun" ]'
2018-03-09 07:12:34 +01:00
if [ "$( wc -w <<< "$netmgrinst" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
f_prnt 2 "installé$pluriel: **$netmgrinst**" '[ "$netmgrinst" ]'
2017-12-15 01:18:35 +01:00
f_prnt 2 "en fonctionnement: **$netmgrrun**" '[ "$netmgrrun" ]'
f_prnt 2 "non trouvé parmi: ${!netmgr[*]}" '[ -z "$netmgrrun" ]'
2017-12-13 03:15:07 +01:00
f_prnt flush
2017-12-11 16:21:06 +01:00
f_dspl_alrt "$alert_ifconfig" "info"
f_dspl_alrt "$alert_slaac" "info"
2017-11-17 07:27:10 +01:00
}
2018-03-09 07:12:34 +01:00
fi_serial(){ # 06/03/2018
2017-11-22 20:33:37 +01:00
local chassis_serial machineId text
2017-12-01 21:50:07 +01:00
2017-12-14 13:55:05 +01:00
(( x_disk == 1 )) || figet_disk
2018-03-09 07:12:34 +01:00
(( x_batt == 1 )) || figet_batt
2017-11-22 20:33:37 +01:00
chassis_serial=$( cat /sys/class/dmi/id/chassis_serial 2>/dev/null )
2017-12-01 21:50:07 +01:00
[ "$chassis_serial" ] || chassis_serial="n/a"
2017-11-22 20:33:37 +01:00
machineId=$( cat /etc/machine-id 2>/dev/null )
2017-12-01 21:50:07 +01:00
[ "$machineId" ] || machineId="n/a"
2017-11-17 07:27:10 +01:00
###
2017-12-15 01:18:35 +01:00
f_prnt tit1 "$BOLD""ID MAchine $BLUE$machineId$STD"
2017-12-13 03:15:07 +01:00
f_prnt
2017-12-15 01:18:35 +01:00
f_prnt 1 "$BOLD""N° Série:$STD"
2017-12-13 03:15:07 +01:00
f_prnt
2018-03-05 03:52:18 +01:00
f_prnt 2 "${GREEN}Disques:"
2017-12-15 01:18:35 +01:00
f_prnt l3 "$BLUE$fg_disk_serial$STD" '[ "$fg_disk_serial" ]'
2017-12-13 03:15:07 +01:00
f_prnt
2018-03-05 03:52:18 +01:00
f_prnt 2 "${GREEN}Batteries:"
2017-12-15 01:18:35 +01:00
f_prnt l3 "$BLUE$fg_batt_serial$STD"
2017-12-13 03:15:07 +01:00
f_prnt
2018-03-05 03:52:18 +01:00
f_prnt 2 "${GREEN}Chassis:"
2017-12-15 01:18:35 +01:00
f_prnt l3 "$BLUE$chassis_serial$STD"
2017-12-01 21:50:07 +01:00
echo -e "$text\n"
}
2018-03-09 07:12:34 +01:00
fi_ssid(){ # 06/03/2018
2017-11-22 20:33:37 +01:00
local nm_ssid text
2017-12-29 12:36:55 +01:00
local file_output="/tmp/$RANDOM-$RANDOM" # ré-assigne sortie pour f_dspl
2017-12-01 21:50:07 +01:00
2017-12-24 14:25:39 +01:00
if [ "$EUID" -ne 0 ]; then
f__info "vous devez être$RED ROOT$BLUE pour installer ce script dans le système"
f__sudo "exec $0 --ssid"
return $?
fi
2018-03-09 07:12:34 +01:00
type -p nmcli &>/dev/null || f__error "NetworkManager requis"
2017-12-11 16:21:06 +01:00
# connexion wifi?
2018-03-09 07:12:34 +01:00
/sbin/iwconfig 2>/dev/null | grep -iq ssid || f__error "pas de connexion wifi"
2017-12-11 16:21:06 +01:00
2017-11-27 06:26:24 +01:00
nm_ssid=$( f_grep_file "/etc/NetworkManager/system-connections/*" "lignevide" )
2017-12-01 21:50:07 +01:00
###
2018-03-05 03:52:18 +01:00
f__info "${RED}Attention:$BLUE la clé du réseau wifi est visible"
2017-12-15 01:18:35 +01:00
f_prnt tit1 "configuration(s) ssid networkmanager"
f_dspl cmd "$nm_ssid" "grep -Ersv '#|^$' /etc/NetworkManager/system-connections/*"
2017-12-13 03:15:07 +01:00
f_prnt flush
2017-12-29 12:36:55 +01:00
f_prnt_md "$file_output" "marge"
rm "$file_output"
2017-08-06 02:43:48 +02:00
}
2018-03-09 07:12:34 +01:00
# shellcheck disable=SC2010
# SC2010 Don't use ls | grep. Use a glob ... to allow non-alphanumeric filenames.
fi_system(){ # 08/03/2018
2018-02-23 17:07:39 +01:00
local mbr uname bootImage initDaemon upstart date_install lastboot uptime uptimePure loadAverage pluriel text
2018-02-09 18:45:09 +01:00
local enum_batt nb_desktop serverX serverType
2017-12-02 11:05:56 +01:00
local alimentation alim_total
2017-12-01 21:50:07 +01:00
2017-12-02 11:05:56 +01:00
# appels fonctions externes
2017-12-14 13:55:05 +01:00
(( x_architecture == 1 )) || f__architecture
(( x_audio == 1 )) || fi_audio "silent"
(( x_batt == 1 )) || figet_batt
(( x_bluez == 1 )) || fi_bluez "silent"
(( x_cpu == 1 )) || figet_cpu
(( x_de == 1 )) || figet_de
(( x_disk == 1 )) || figet_disk
(( x_distrib == 1 )) || figet_distrib
(( x_dm == 1 )) || figet_dm
(( x_dmi == 1 )) || figet_dmi
(( x_gpu == 1 )) || fi_gpu "silent"
(( x_net == 1 )) || fi_net "silent"
2018-03-03 07:40:41 +01:00
(( x_screen == 1 )) || figet_screen
2017-12-14 13:55:05 +01:00
(( x_shell == 1 )) || figet_shell
(( x_touchpad == 1 )) || fi_touchpad "silent"
(( x_wm == 1 )) || figet_wm
2018-03-02 06:06:51 +01:00
[ "$1" != "rc" ] && echo -n "ø"
2018-02-09 18:45:09 +01:00
2017-12-02 11:05:56 +01:00
# divers système
2017-12-07 18:06:12 +01:00
if [ -d /sys/firmware/efi ]; then
mbr="EFI"
else
mbr="Legacy (mbr)"
fi
2017-11-25 19:39:57 +01:00
uname=$( uname -rmo )
2018-02-26 13:26:50 +01:00
bootImage=$( awk '{print $1}{i=2; while (i <= NF) { print " ",$i; i++}}' /proc/cmdline )
initDaemon=$( ps -p1 -o comm --no-headers ) # ps -p1 | awk 'FNR==2 {print $4}'
2018-03-09 07:12:34 +01:00
if [ "$initDaemon" == "systemd" ] && type -p systemd &>/dev/null; then
2018-02-23 17:07:39 +01:00
initDaemon=$( systemd --version | head -n1 )
2018-03-02 06:06:51 +01:00
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
2018-02-23 17:07:39 +01:00
fi
initDaemon=${initDaemon^} # 1er car mal
if upstart --version &>/dev/null; then # encore présent sur 16.04??
upstart=$( upstart --version | head -n1 )
2017-11-25 19:39:57 +01:00
fi
2017-12-13 03:15:07 +01:00
while read -r; do
date_install=$REPLY
2018-02-23 17:07:39 +01:00
done <<< "$( ls -dlt --time-style '+FORMAT %d/%m/%Y' /home/ /root/ /bin/ /lib* )"
2017-11-11 19:41:13 +01:00
[[ "$date_install" =~ .*([0-9]{2}/[0-9]{2}/[0-9]{4}).* ]] && date_install=${BASH_REMATCH[1]}
2018-02-26 13:26:50 +01:00
# lastboot="$( last -n 1 --time-format iso reboot | awk 'FNR==1 {sub(/T/," ",$5);print $5}' )" # remis à jours en début de mois ?!!
2017-11-25 19:39:57 +01:00
lastboot=$( date -r /var/run/utmp '+%d/%m/%Y %H:%M %z' )
2017-12-06 15:00:33 +01:00
uptimePure="OUI" # si pas vide, pas d'affichage des valeurs Zéro (avec unité) dans uptime
uptime=$(
2018-02-26 13:26:50 +01:00
LC_ALL=C uptime 2>/dev/null | awk -v uptimePure="$uptimePure" -F'( |,|:)+' '{
2017-12-06 15:00:33 +01:00
# extraction selon format de sortie
if ( $7 ~ /^day/ && $9 ~ /^min/ ) { j=$6; h=0; m=$8 } # up 25 days, 30 min,
else if ( $7 ~ /^day/ ) { j=$6; h=$8; m=$9 } # up 25 days, 21:30,
else if ( $7 ~ /^min/ ) { j=0; h=0; m=$6 } # up 15 min,
else { j=0; h=$6; m=$7 } # up 12:30,
if ( j > 1 ) { pluriel="s" }
# 3 parties à afficher ou pas
groupe1 = sprintf( "%d jour%s", j,pluriel )
groupe2 = sprintf( "%02d h", h )
groupe3 = sprintf( "%02d mn", m )
# sortie
if ( uptimePure != "" ) {
printf ( j != 0 ) ? "%s " : "" , groupe1
printf ( h != 0 ) ? "%s " : "" , groupe2
printf ( m != 0 ) ? "%s" : "" , groupe3
} else {
print groupe1,groupe2,groupe3
}
2018-02-26 13:26:50 +01:00
}' )
2017-12-06 15:00:33 +01:00
loadAverage=$(
2018-02-26 13:26:50 +01:00
LC_ALL=C uptime 2>/dev/null | awk -v threads="$fg_nb_threads" -F'(, )' '{
2017-12-06 15:00:33 +01:00
gsub(/ load average: /,"")
if ( threads > 1 ) th="threads"; else th="thread"
la1 = $(NF-2)
la5 = $(NF-1)
la15 = $NF
print "charge système depuis les 1, 5 et 15 dernières minutes:", la1, la5, la15, " "
printf "%s %s %s %s", "soit avec", threads, th, ":"
printf "%d%% %d%% %d%% %s", la1/2*100, la5/2*100, la15/2*100, "d\047occupation du système (en temps)"
2018-02-26 13:26:50 +01:00
}' )
2018-02-09 18:45:09 +01:00
# nombre de bureau
2018-02-13 19:56:53 +01:00
nb_desktop=$( xprop -root 2>/dev/null | grep '^_NET_NUMBER_OF_DESKTOPS.*=' )
nb_desktop=${nb_desktop#* = }
2018-02-09 18:45:09 +01:00
2017-12-02 11:05:56 +01:00
# server X
2018-02-09 18:45:09 +01:00
if [ "$fe_Xorg" ]; then
serverX+="$fe_Xorg"
fi
2018-02-23 17:07:39 +01:00
serverType=" ${XDG_SESSION_TYPE^}" # retourne Wayland ou X11 (mir?)
if ps -e | grep -q 'unity-system-co' ; then # ps -ef | grep unity-system-compositor
serverType="Mir"
fi
2018-03-09 07:12:34 +01:00
if [[ "$serverType" =~ X11 ]]; then
serverType+=":"
fi
if [[ "$serverX" == " " && "$ENV_DISPLAY" ]]; then
serverX+=":no DISPLAY"
fi
if [[ "$serverX" == " " && "$ENV_SSH" ]]; then
serverX+=":ssh"
fi
if [ "$serverX" == " " ]; then
serverX="n/a"
fi
2018-02-09 18:45:09 +01:00
2017-12-02 11:05:56 +01:00
# alimentation
2018-02-26 13:26:50 +01:00
if ls -1 "/sys/class/power_supply/" | grep -iq '^AC' ; then
2018-03-02 06:06:51 +01:00
alim_total=$( grep -cs '1' /sys/class/power_supply/AC*/online )
2018-02-26 13:26:50 +01:00
alimentation=$( awk -v "alim_total=$alim_total" '
2017-12-02 11:05:56 +01:00
{ alim_on=sprintf("%d", $1); if (alim_on>1) pllo="s" }
END { if ( alim_total > 1 ) pllt="s"; printf alim_total " alimentation" pllt
if ( alim_total != alim_on ) print ", " alim_on " branchée" pllo; else print "" }
' /sys/class/power_supply/AC*/online )
fi
2018-02-09 18:45:09 +01:00
2017-12-09 13:21:01 +01:00
# batterie(s)
2018-02-23 17:07:39 +01:00
enum_batt=$( grep -E '[A-Z][A-Z]' <<< "$fg_batt" )
2017-12-01 21:50:07 +01:00
###
2018-03-03 07:40:41 +01:00
if [ "$operation" == "rc" ]; then
fi_system_rc
2018-03-02 06:06:51 +01:00
return
fi
2017-12-15 01:18:35 +01:00
[ "$ORIGIN" ] && f_prnt tit2 "système"
2017-12-14 13:55:05 +01:00
f_prnt
2018-02-26 13:26:50 +01:00
f_prnt 1 "$( sed -E 's/(.*)/**\1** /' <<< "$fg_dmi" )" # en gras
2017-12-13 03:15:07 +01:00
f_prnt
2017-12-15 01:18:35 +01:00
f_prnt 1 "CPU"
2018-02-23 17:07:39 +01:00
f_prnt 2 "**$( sed -n '1p' <<< "$fg_cpu" )**"
2017-12-15 01:18:35 +01:00
f_prnt 1 "Vidéo"
2018-02-23 17:07:39 +01:00
f_prnt 2 "$( sed -E 's/(.*)/**\1**/' <<< "$fe_gpu" )" '[ "$fe_gpu" ]'
2017-12-15 01:18:35 +01:00
f_prnt 2 "pas de carte graphique détectée" '[ "$fe_nb_gpu" -eq 0 ]'
f_prnt 1 "Réseau"
2018-02-23 17:07:39 +01:00
f_prnt 2 "$( sed -E 's/(.*)/**\1**/' <<< "$fe_cards_reseau" )" '[ "$fe_cards_reseau" ]'
2017-12-15 01:18:35 +01:00
f_prnt 2 "pas de carte réseau détectée" '[ "$fe_nb_reseau" -eq 0 ]'
f_prnt 1 "Audio"
2018-02-23 17:07:39 +01:00
f_prnt 2 "$( sed -E 's/(.*)/**\1**/' <<< "$fe_cards_audio" )" '[ "$fe_cards_audio" ]'
2017-12-15 01:18:35 +01:00
f_prnt 2 "pas de carte réseau détectée" '[ "$fe_nb_audio" -eq 0 ]'
2017-12-13 03:15:07 +01:00
f_prnt
2017-12-15 01:18:35 +01:00
f_prnt code
f_prnt l1 "$fg_distrib"
f_prnt l2 "$uname"
f_prnt l2 "boot: $mbr"
f_prnt l2 "architecture système: $fu_archi"
2018-03-03 07:40:41 +01:00
f_prnt l2 "installation: $date_install"
f_prnt l2 "démon init: $initDaemon"
2018-03-02 06:06:51 +01:00
f_prnt l3 "$upstart" '[ "$upstart" ]'
2017-12-15 01:18:35 +01:00
f_prnt l2 "shell actif: $fg_shell"
2018-03-09 07:12:34 +01:00
if [ "$( f__wcv -w "$fg_shells" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
f_prnt l2 "shell$pluriel installé$pluriel: $fg_shells"
2017-12-15 01:18:35 +01:00
f_prnt l2 "$bootImage"
2017-12-13 03:15:07 +01:00
f_prnt
2018-02-09 18:45:09 +01:00
f_prnt l1 Environnement
f_prnt l2 "serveur d'affichage$serverType $serverX"
2017-12-15 01:18:35 +01:00
f_prnt l2 "nombre d'écrans: $fg_nb_screen"
2018-03-09 07:12:34 +01:00
if [ "$( f__wcv "-wv" "$fg_resolution" "pixels" )" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
f_prnt l2 "résolution$pluriel: $fg_resolution"
2018-03-03 07:40:41 +01:00
f_prnt l2 "display manager: $fg_dm"
2017-12-15 01:18:35 +01:00
f_prnt l2 "desktop (DE): $fg_de"
f_prnt l2 "panel: $fg_de_panel" '[ "$fg_de_panel" ]'
f_prnt l2 "window manager: $fg_wm"
2018-02-09 18:45:09 +01:00
f_prnt l2 "nombre de bureaux: $nb_desktop" '[ "$nb_desktop" ]'
2017-12-13 03:15:07 +01:00
f_prnt
2018-02-09 18:45:09 +01:00
f_prnt l1 Matériel
2018-03-09 07:12:34 +01:00
if [ "$fg_nb_cpu" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
f_prnt l2 "$fg_nb_cpu processeur$pluriel $fg_cpu_arch"
if [ "$fe_nb_bluez" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
f_prnt l2 "$fe_nb_bluez carte$pluriel bluetooth détectée$pluriel ($fe_cards_bluez)" '[ "$fe_nb_bluez" -gt 0 ]'
2017-12-15 01:18:35 +01:00
f_prnt l2 "$alimentation" '[ "$alimentation" ]'
2018-03-09 07:12:34 +01:00
if [ "$fg_nb_batt" -gt "1" ]; then pluriel="s"; else unset pluriel; fi
f_prnt l2 "$fg_nb_batt batterie$pluriel présente$pluriel:" '[ "$fg_batt" ]'
2017-12-15 01:18:35 +01:00
f_prnt l3 "$enum_batt" '[ "$fg_batt" ]'
2018-03-09 07:12:34 +01:00
if [ "$fe_nb_touchpad" -gt "1" ]; then pluriel="s"; else unset pluriel; fi
f_prnt l2 "$fe_nb_touchpad pavé$pluriel tactile$pluriel:" '[ "$fe_touchpad" ]'
2018-02-22 01:26:29 +01:00
f_prnt l3 "$fe_touchpad" '[ "$fe_touchpad" ]'
2017-12-15 01:18:35 +01:00
f_prnt code
2017-12-13 03:15:07 +01:00
f_prnt
2018-02-23 17:07:39 +01:00
f_prnt 1 "$( sed -E 's/^(.*: )(.*)/\1**\2**/' <<< "$fg_disk_part_fix_tot" )" '[ "$fg_disk_part_fix_tot" ]'
2017-12-15 01:18:35 +01:00
f_prnt 1 "dernier boot: **$lastboot**, il y a **$uptime**"
2018-03-02 06:06:51 +01:00
f_prnt 1 "$loadAverage"
f_prnt flush
f_dspl_alrt "$alert_slim" "alert"
}
2018-03-09 07:12:34 +01:00
fi_system_analyse(){ # 06/03/2018
type -p systemd &>/dev/null || return 0 # pas systemd
2017-12-01 21:50:07 +01:00
local bootTime cmd_bootTime cmt_bootTime pluriel text
local srvcFail cmd_srvcFail cmt_srvcFail qte_srvcFail isrvc srvcFail_list info_services
local bootBlame cmd_bootBlame cmt_bootBlame bootCritic cmd_bootCritic cmt_bootCritic
local bootGraph cmd_bootGraph cmt_bootGraph file="/tmp/getInfo-graph.svg"
local alert_srvcFail
2017-11-30 20:27:02 +01:00
2017-12-01 21:50:07 +01:00
# durée du précédent boot
bootTime=$( LC_ALL=C systemd-analyze time )
bootTime=${bootTime/Startup finished in /Durée de boot: }
bootTime=${bootTime/userspace/espace utilisateur}
cmd_bootTime="systemd-analyze time"
cmt_bootTime="durée du boot, avant interface graphique"
# services en erreur
2018-02-26 13:26:50 +01:00
srvcFail=$( LC_ALL=C systemctl --state=active,failed | awk '
2018-01-26 19:56:39 +01:00
/error|not-found|failed/ { sub(/●|\*/,"");
2017-12-01 21:50:07 +01:00
printf "%-50s %-11s %-8s %-8s %s",$1,$2,$3,$4,$5; $1=$2=$3=$4=$5=""; print $0}' )
cmd_srvcFail="systemctl --state=active,failed | grep -E 'error|not-found|failed'"
2018-03-09 07:12:34 +01:00
qte_srvcFail=$( f__wcv -l "$srvcFail" )
if [ "$qte_srvcFail" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
cmt_srvcFail="service$pluriel en erreur"
2017-12-01 21:50:07 +01:00
if [ "$qte_srvcFail" -gt 0 ]; then
2018-03-09 07:12:34 +01:00
alert_srvcFail="service$pluriel en erreur, statut: \n\n"
2018-02-26 13:26:50 +01:00
srvcFail_list=$( awk '{print $1}' <<< "$srvcFail" )
2017-12-01 21:50:07 +01:00
for isrvc in $srvcFail_list; do
alert_srvcFail+="\`systemctl status $isrvc\` \n"
alert_srvcFail+='```\n'
2018-03-09 07:12:34 +01:00
alert_srvcFail+="$( systemctl status "$isrvc" 2>&1 ) \n"
2017-12-01 21:50:07 +01:00
alert_srvcFail+='```\n'
done
alert_srvcFail=${alert_srvcFail//●}
srvcFail=$( printf "%-50s %-11s %-8s %-8s %s" Unit Load Active Sub Description )$'\n'"$srvcFail"
2017-11-11 19:41:13 +01:00
fi
2017-12-01 21:50:07 +01:00
info_services="voir tous les services: **systemctl list-units --type=service | pager**"
# détail par service
bootBlame=$( LC_ALL=C systemd-analyze blame | head -n 20 )
cmd_bootBlame="systemd-analyze blame | head -n 20"
cmt_bootBlame="détail par service"
# services critiques ralentisseurs
bootCritic=$( LC_ALL=C systemd-analyze critical-chain )
bootCritic=${bootCritic/The time after the unit is active or started is printed after the \"@\" character./ @: temps auquel l\'unité est active ou démarrée}
bootCritic=${bootCritic/The time the unit takes to start is printed after the \"+\" character./ +: temps que l\'unité prend pour démarrer}
cmd_bootCritic="systemd-analyze critical-chain"
cmt_bootCritic="services critiques ralentisseurs"
# génération graphique
if [[ "$wayland" && "$EUID" -eq 0 ]]; then # évite erreur $DISPLAY en root wayland
bootGraph="n/a en root sous wayland"
else
[ -w "$file" ] || file="/tmp/getInfo-graph-$RANDOM.svg"
2018-03-09 07:12:34 +01:00
touch "$file" 2>/dev/null
2017-12-01 21:50:07 +01:00
systemd-analyze plot > "$file" 2>/dev/null
2018-03-09 07:12:34 +01:00
chown "$fu_user": "$file"
2017-12-01 21:50:07 +01:00
bootGraph="en console: **xdg-open $file** \n"
bootGraph+="* dans un navigateur: copier/coller ce lien dans la barre d'adresses "
bootGraph+="file:///$file \n" # résultat avec 4 /, ok
2017-11-11 19:41:13 +01:00
fi
2017-12-01 21:50:07 +01:00
# un lien local ne s'ouvrira pas automatiquement :( : http://kb.mozillazine.org/Links_to_local_pages_do_not_work
cmd_bootGraph="systemd-analyze plot > $file ; xdg-open graph.svg"
cmt_bootGraph="graph durées et ordre de chargement des services"
2017-11-30 20:27:02 +01:00
###
2017-12-15 01:18:35 +01:00
f_prnt tit2 "analyse boot systemd"
f_prnt 1 "pas de service en erreur" '[ -z "$srvcFail" ]'
f_dspl cmd "$bootTime" "$cmd_bootTime" "$cmt_bootTime"
f_dspl cmd "$srvcFail" "$cmd_srvcFail" "$cmt_srvcFail"
2017-12-03 13:48:03 +01:00
f_dspl_alrt "$info_services" "info"
f_dspl_alrt "$alert_srvcFail" "alert"
2017-12-15 01:18:35 +01:00
f_dspl cmd "$bootBlame" "$cmd_bootBlame" "$cmt_bootBlame"
f_dspl cmd "$bootCritic" "$cmd_bootCritic" "$cmt_bootCritic"
f_dspl cmd:text "$bootGraph" "$cmd_bootGraph" "$cmt_bootGraph"
2017-12-01 21:50:07 +01:00
}
2018-04-08 16:34:59 +02:00
fi_system_rc(){ # 12/03/2018
2018-03-03 07:40:41 +01:00
local if_actif iip ip_act
if_actif=$( ip -o link | awk '/state UP/{sub(/:/,"",$2); printf "%s ",$2}' )
for iip in $if_actif; do
2018-03-09 07:12:34 +01:00
ip_act+=$( ip -o address show dev "$iip" | awk '
2018-03-03 07:40:41 +01:00
#~ /inet/ { sub(/wl.*/,"wifi: "$2,$2); sub(/en.*|eth.*/,"rj45: "$2,$2); sub(/\/.*/,"", $4) }
/inet/ { sub(/\/.*/,"", $4) }
/inet6/ { ip6 = $4; exit }
/inet / { ip4 = $4 }
2018-04-08 16:34:59 +02:00
END { printf "%s %s %s",$2,ip4,ip6 }' )
2018-03-03 07:40:41 +01:00
done
f_prnt code
2018-04-08 16:34:59 +02:00
f_prnt 2 "$GREEN$( sed -n '1p' <<< "$fg_dmi" )$STD"
2018-03-03 07:40:41 +01:00
f_prnt 2 "$( sed -n '1p' <<< "$fg_cpu" )"
f_prnt 2 "$fe_gpu"
if grep -q 'wl.*' <<< "$ip_act"; then
toPrint=$( grep 'Wireless:' <<< "$fe_cards_reseau" )$'\n'" $(grep 'wl.*' <<< "$ip_act" )"
f_prnt l2 " * ${toPrint/Wireless: }"
fi
if grep -Eq 'en.*|eth.*' <<< "$ip_act"; then
toPrint=$( grep 'Ethernet:' <<< "$fe_cards_reseau" )$'\n'" $(grep -E 'en.*|eth.*' <<< "$ip_act" )"
f_prnt l2 " * ${toPrint/Ethernet: }"
fi
2018-04-08 16:34:59 +02:00
f_prnt
2018-03-03 07:40:41 +01:00
f_prnt l2 "distrib: $fg_distrib (installation: $date_install)"
f_prnt l2 "kernel : $uname"
f_prnt l2 "boot: $mbr, init: $initDaemon $upstart"
f_prnt l2 "shell : $fg_shell"
f_prnt l2 "serveur d'affichage$serverType $serverX"
f_prnt l2 "nombre d'écrans: $fg_nb_screen"
2018-03-09 07:12:34 +01:00
f_prnt l2 "résolution$pluriel: $fg_resolution"
2018-03-03 07:40:41 +01:00
f_prnt l2 "display manager: $fg_dm"
f_prnt l2 "desktop (DE) : $fg_de"
f_prnt l2 "window manager : $fg_wm"
f_prnt
f_prnt l3 "$fg_disk_part_syst"
f_prnt l3 "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 l3 "$loadAverage"
f_prnt code
f_prnt flush
}
2017-12-14 13:55:05 +01:00
# [$1=silent], assigne $fe_touchpad, fe_nb_touchpad
2018-03-09 07:12:34 +01:00
fi_touchpad(){ # 06/03/2018
2017-12-15 01:18:35 +01:00
local device cmd_device toScrut xfile file_logs type type_pt pilote cmd_pilote cmt_pilote info_driver
2017-12-14 13:55:05 +01:00
x_touchpad=1
2018-03-09 07:12:34 +01:00
2018-02-20 03:59:50 +01:00
unset fe_touchpad
fe_nb_touchpad=0
2018-02-14 10:59:27 +01:00
device=$( grep -Ei -B1 -A8 'touchpad|trackpoint|synaptics|alps|etps|elan' /proc/bus/input/devices ) || return 0
2018-02-09 06:07:03 +01:00
while read -r; do
REPLY=${REPLY#*Name=\"} # suppression début
REPLY=${REPLY%\"} # suppression fin
fe_touchpad+="$REPLY "$'\n'
2018-02-23 17:07:39 +01:00
done <<< "$( grep -i 'Name=' <<< "$device" )"
2018-02-09 06:07:03 +01:00
fe_touchpad=${fe_touchpad%$'\n'} # suppression \n final
2018-02-14 16:48:53 +01:00
cmd_device="grep -Ei -B1 -A8 'touchpad|trackpoint|synaptics|alps|etps|elan' /proc/bus/input/devices"
2017-12-15 01:18:35 +01:00
# recherche Xorg.log
toScrut=(
/var/log/Xorg.0.log
/home/$fu_user/.local/share/xorg/Xorg.0.log
/var/lib/gdm3/.local/share/xorg/Xorg.0.log
)
2018-03-09 07:12:34 +01:00
for xfile in "${toScrut[@]}"; do
2017-12-15 01:18:35 +01:00
[ -e "$xfile" ] && file_logs+="$xfile "
done
[ "$file_logs" ] || file_logs="nologs"
if [ "$file_logs" != "nologs" ]; then
type=$( grep -is 'touchpad: buttons:' $file_logs )
2018-03-09 07:12:34 +01:00
# essai détection multitouch
2018-02-23 17:07:39 +01:00
grep -iq 'left' <<< "$type" && type_pt="non multitouch"
grep -iq 'double' <<< "$type" && type_pt="2"
grep -iq 'triple' <<< "$type" && type_pt+="3"
grep -iq '[0-9]' <<< "$type" && type_pt=" multitouch $type_pt points"
2017-12-15 01:18:35 +01:00
type_pt=${type_pt/23/ 2\/3}
fe_touchpad+="$type_pt"
fi
2018-02-09 06:07:03 +01:00
fe_nb_touchpad=$( f__wcv -l "$fe_touchpad" )
2017-12-14 13:55:05 +01:00
[[ "$1" == "silent" ]] && return 0
###
if [ "$ENV_DEBIAN" ]; then
2018-02-26 13:26:50 +01:00
pilote=$( dpkg -l | grep -E 'synaptics|libinput' | awk '
/^ii/ { printf "%-30s", $2; $1=$2=$3=$4=""; print $0 }' )
2018-02-23 17:07:39 +01:00
cmd_pilote="dpkg -l | grep -E 'synaptics|libinput'"
2017-12-18 13:46:50 +01:00
cmt_pilote="paquets installés"
2017-12-14 13:55:05 +01:00
info_driver="consulter d'éventuels fichiers *synaptics *libinput dans /etc/X11/xorg.conf.d/ "
info_driver+="pour voir les configurations personnalisées"
fi
###
2018-02-14 10:40:17 +01:00
f_prnt tit2 "touchpad"
2018-02-23 17:07:39 +01:00
f_prnt 1 "$( sed -E 's/(.*)/**\1** /' <<< "$fe_touchpad" )" # mise en gras
2017-12-15 01:18:35 +01:00
f_prnt
2018-03-09 07:12:34 +01:00
f_prnt l1 "Multitouch non détecté" '[ -z "$type_pt" ]'
f_prnt
2018-02-14 10:40:17 +01:00
f_dspl cmd "$device" "$cmd_device"
2017-12-15 01:18:35 +01:00
f_dspl cmd "$pilote" "$cmd_pilote" "$cmt_pilote"
2017-12-14 13:55:05 +01:00
f_dspl_alrt "$info_driver" "info"
}
2018-03-09 07:12:34 +01:00
fi_usb(){ # 05/03/2018
local lsusb size lsusb_t ls lst ils motif result ls_p device id
2017-12-01 21:50:07 +01:00
2017-11-25 19:39:57 +01:00
lsusb=$( lsusb )
2017-11-30 20:27:02 +01:00
[ "$lsusb" ] || return 0
2017-12-14 20:07:23 +01:00
lsusb=$( sort <<< "$lsusb" )
2017-12-16 23:31:32 +01:00
lsusb=$( f_lifting "$lsusb" ) # cosmétique
2017-12-15 09:14:02 +01:00
# largeur max initiale de lsusb
2017-12-16 23:31:32 +01:00
# formation index bus-device de lsub
2017-12-17 05:11:11 +01:00
# 1-1 | 1d6b:0002 Linux Foundation 2.0 root hub
2018-02-26 13:26:50 +01:00
ls=$( awk '{
2017-12-17 05:11:11 +01:00
bus=sprintf("%d",$2)
device=sprintf("%d",$4)
id=sprintf("%s",$6)
$1=$2=$3=$4=$5=$6=""
sub(/^[[:blank:]]*/,"",$0)
periph=$0
printf "%03d-%03d | %s %s\n",bus,device,id,periph
2018-02-26 13:26:50 +01:00
}' <<< "$lsusb" )
2017-12-17 05:11:11 +01:00
# extraction Class Driver de lsusb -t et formation index bus-device
# 1-1 | root_hub ehci-pci/8p
lsusb_t=$( lsusb -t )
2018-02-26 13:26:50 +01:00
lst=$( awk '
2017-12-14 20:07:23 +01:00
BEGIN {FS=", "}
2018-02-26 13:26:50 +01:00
{
2017-12-14 20:07:23 +01:00
sub(/^.*Bus /,"",$1)
sub(/Human Interface Device/,"HID")
2017-12-16 23:31:32 +01:00
sub(/\(Defined at Interface level\)/,"Defined Interf")
sub(/Vendor Specific Class/,"Vend. Specific")
sub(/Application Specific Interface/,"App. Specific")
2017-12-14 20:07:23 +01:00
split($1,tab,".Port [0-9]+: Dev ")
if ( tab[1] ~ /[0-9]+/ ) bus=sprintf("%d",tab[1]); else bus=bus
device=tab[2]
if ( $2 ~ /If/) {
sub(/Class=/,"",$3)
class=$3
sub(/.*Driver=/,"",$4)
driver=$4
} else {
sub(/Class=/,"",$2)
class=$2
sub(/.*Driver=/,"",$3)
driver=$3
}
2017-12-17 05:11:11 +01:00
printf( "%03d-%03d | %-14s %s\n",bus,device,class,driver )
2018-02-26 13:26:50 +01:00
}' <<< "$lsusb_t" )
2017-12-14 20:07:23 +01:00
IFS=$'\n'
2017-12-17 05:11:11 +01:00
# calcul largeur max $ls
size=$(( 0 ))
for ils in $ls; do
if [ ${#ils} -gt "$size" ]; then
size=$(( ${#ils} ))
fi
done
# assemblage et suppression index bus-device
2017-12-14 20:07:23 +01:00
for ils in $ls; do
2017-12-17 05:11:11 +01:00
motif=${ils% |*} # extraction bus-device
result=$( grep -w -m1 "$motif" <<< "$lst" ) # extraction ligne correspondante dans lst
result=${result#* | } # suppression bus-device
2018-03-09 07:12:34 +01:00
ls_p+=$( printf "%-""$size""s %s" "$ils" "$result" )$'\n' # assemblage
2017-12-14 20:07:23 +01:00
done
ls_p=${ls_p%[[:cntrl:]]}
2017-12-17 05:11:11 +01:00
ls_p=${ls_p//|}
ls_p=${ls_p//-/ }
ls_p=$( printf "%s %s %6s %28s %17s %17s" bus dev id périphérique class driver )"\n$ls_p"
2017-12-14 20:07:23 +01:00
IFS="$IFS_INI"
2017-12-01 21:50:07 +01:00
###
2017-12-15 01:18:35 +01:00
f_prnt tit2 "USB"
2017-12-17 05:11:11 +01:00
f_dspl cmd "$ls_p" "lsusb + lsusb -t" "affichage modifié, ajout Class & Driver"
2017-08-02 01:16:24 +02:00
}
2018-03-09 07:12:34 +01:00
fi_vrms(){ # 06/03/2018
local vrms non_free contrib text pluriel tempo
2017-11-30 20:27:02 +01:00
2018-03-09 07:12:34 +01:00
type -p vrms &>/dev/null || return 0
2017-12-01 21:50:07 +01:00
vrms=$( vrms )
non_free=$(( $( sed -En 's/([0-9]+) non-free packages,.*/\1/p' <<< "$vrms" ) ))
contrib=$(( $( sed -En 's/([0-9]+) contrib packages,.*/\1/p' <<< "$vrms" ) ))
if [[ "$non_free" -gt 0 || "$contrib" -gt 0 ]]; then
2018-03-09 07:12:34 +01:00
if [ "$non_free" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
2017-12-01 21:50:07 +01:00
vrms=$( sed -E "s/Non-free packages installed on.*/$non_free paquet$pluriel non libre$pluriel installé$pluriel:/
" <<< "$vrms" )
2018-03-09 07:12:34 +01:00
if [ "$contrib" -gt 1 ]; then pluriel="s"; else unset pluriel; fi
2017-12-01 21:50:07 +01:00
vrms=$( sed -E "s/Contrib packages installed on.*/$contrib paquet$pluriel contrib installé$pluriel:/
" <<< "$vrms" )
vrms=$( sed -E '/[0-9]+ non-free packages,/d; /[0-9]+ contrib packages,/d;
2018-02-23 17:07:39 +01:00
/^[[:space:]]*$/d' <<< "$vrms" )
2017-12-01 21:50:07 +01:00
elif grep -iq 'proud' <<< "$vrms" ; then
tempo="Aucun paquet non libre ou contrib installé sur ce système \n\t\t **rms serait fier ☺**"
vrms=$( sed -E "s/.*rms would be proud.*/$tempo/" <<< "$vrms" )
fi
###
2017-12-15 01:18:35 +01:00
f_prnt tit2 "paquets non-libres"
f_dspl cmd "$vrms" "vrms" "détection des paquets non libres par RMS"
2017-12-13 03:15:07 +01:00
f_prnt flush
2017-10-30 10:50:22 +01:00
}
2017-11-06 13:25:09 +01:00
# informations batterie(s), assigne $fg_nb_batt $fg_batt $fg_batt_serial
2018-03-09 07:12:34 +01:00
figet_batt(){ # 06/03/2018
2017-12-09 17:15:18 +01:00
local batt_detail batt_unit batt_capa_design batt_capa_full batt_capa_now batt_conso
2017-11-06 13:25:09 +01:00
local batt_volt_min batt_volt_now batt_status batt_cycle alert_batt_alarm
2017-10-15 00:42:44 +02:00
local batt_sante batt_restant tempo batRep ibat uevent
2017-12-14 13:55:05 +01:00
x_batt=1
2018-03-09 07:12:34 +01:00
2017-12-09 17:15:18 +01:00
fg_nb_batt=0
2017-10-12 08:45:16 +02:00
if [ ! -d /sys/class/power_supply ]; then # anciennes interfaces ou inconnu
2017-12-09 17:15:18 +01:00
[ -d /proc/acpi/battery ] && fg_batt="ancienne interface ACPI non gérée (obsolète)"
[ -e /proc/apm ] && fg_batt="anciennes batteries APM non gérées (obolète)"
[ "$fg_batt" ] || fg_batt="répertoire power_supply inaccessible"
2017-10-12 08:45:16 +02:00
return 1
fi
2018-03-02 06:06:51 +01:00
fg_nb_batt=$( grep -is 'Battery' /sys/class/power_supply/*/type | grep -c . )
2017-12-09 17:15:18 +01:00
if [ "$fg_nb_batt" -eq 0 ]; then
return 0
2017-12-09 16:26:37 +01:00
fi
2017-12-13 03:15:07 +01:00
batRep="/sys/class/power_supply/"
2017-10-14 17:54:16 +02:00
unset batt_detail
2017-12-13 03:15:07 +01:00
for ibat in $batRep*; do
grep -qi 'Battery' "$ibat/type" || continue # plus loin si non batterie
[ -e "$ibat/uevent" ] || batt_detail="${ibat#$batRep}: **uevent** inexistant"
[ -e "$ibat/uevent" ] || continue
2018-03-09 07:12:34 +01:00
uevent=$( grep -s . "$ibat/uevent" )
2017-10-14 17:54:16 +02:00
# extractions valeur de calcul selon type
2018-02-23 17:07:39 +01:00
if grep -q 'POWER_SUPPLY_CHARGE_' <<< "$uevent" ; then
2017-10-14 17:54:16 +02:00
batt_unit="mAh"
2018-02-26 13:26:50 +01:00
batt_capa_design=$( awk -F '=' '/POWER_SUPPLY_CHARGE_FULL_DESIGN=/ {printf "%d", $2/1000}' <<< "$uevent" ) # mA
batt_capa_full=$( awk -F '=' '/POWER_SUPPLY_CHARGE_FULL=/ {printf "%d", $2/1000}' <<< "$uevent" ) # mA
batt_capa_now=$( awk -F '=' '/POWER_SUPPLY_CHARGE_NOW=/ {printf "%d", $2/1000}' <<< "$uevent" ) # mA
batt_conso=$( awk -F '=' '/POWER_SUPPLY_CURRENT_NOW=/ {printf "%d", $2/1000}' <<< "$uevent" ) # mA
2018-02-23 17:07:39 +01:00
elif grep -q 'POWER_SUPPLY_ENERGY_' <<< "$uevent" ; then
2017-10-25 10:03:56 +02:00
batt_unit="Wh"
2018-02-26 13:26:50 +01:00
batt_capa_design=$( awk -F '=' '/POWER_SUPPLY_ENERGY_FULL_DESIGN=/ {printf "%.2f", $2/1000000}' <<< "$uevent" ) # W
batt_capa_full=$( awk -F '=' '/POWER_SUPPLY_ENERGY_FULL=/ {printf "%.2f", $2/1000000}' <<< "$uevent" ) # W
batt_capa_now=$( awk -F '=' '/POWER_SUPPLY_ENERGY_NOW=/ {printf "%.2f", $2/1000000}' <<< "$uevent" ) # W
batt_conso=$( awk -F '=' '/POWER_SUPPLY_POWER_NOW=/ {printf "%.2f", $2/1000000}' <<< "$uevent" ) # W
2017-10-14 17:54:16 +02:00
fi
# extractions simples
2018-02-26 13:26:50 +01:00
batt_volt_min=$( awk -F '=' '/POWER_SUPPLY_VOLTAGE_MIN_DESIGN=/ {printf "%.2f", $2/1000000}' <<< "$uevent" ) # V
batt_volt_now=$( awk -F '=' '/POWER_SUPPLY_VOLTAGE_NOW=/ {printf "%.2f", $2/1000000}' <<< "$uevent" ) # V
batt_status=$( awk -F '=' '/POWER_SUPPLY_STATUS=/ {print $2}' <<< "$uevent" )
batt_cycle=$( awk -F '=' '/POWER_SUPPLY_CYCLE_COUNT=/ {print $2}' <<< "$uevent" )
fg_batt_serial=$( awk -F '=' '/POWER_SUPPLY_SERIAL_NUMBER=/ {sub(/^ | $|0/,"",$2); print $2}' <<< "$uevent" )
2018-03-09 07:12:34 +01:00
alert_batt_alarm=$( cat "$ibat/alarm" 2>/dev/null )
if [ "$alert_batt_alarm" == "0" ]; then
unset alert_batt_alarm
else
alert_batt_alarm="$( basename "$ibat" ) ($alert_batt_alarm)"
fi
2017-10-14 17:54:16 +02:00
# calculs
2018-02-26 13:26:50 +01:00
batt_sante=$( awk '$1 != "na" && $2 != "" && $2 != 0 {printf "%.1f", $1/$2*100}' <<< "$batt_capa_full $batt_capa_design" )
2017-10-15 00:33:34 +02:00
if [[ "$batt_status" == "Full" || "$batt_status" == "Unknown" ]]; then
2017-10-14 17:54:16 +02:00
batt_restant="totalement chargée"
2017-10-23 03:52:48 +02:00
elif [ "$batt_status" == "Discharging" ]; then
2017-10-14 17:54:16 +02:00
batt_restant="en décharge, reste approximativement: "
2018-02-26 13:26:50 +01:00
tempo=$( awk '$1+$2 != "" && $2!=0 {print $1*0.9/$2}' <<< "$batt_capa_now $batt_conso" )
2017-10-14 17:54:16 +02:00
elif [ "$batt_status" == "Charging" ]; then
batt_restant="en charge, reste approximativement: "
2018-02-26 13:26:50 +01:00
tempo=$( awk '$1+$2+$3 != "" && $3 != 0 {print ($1-$2)/$3}' <<< "$batt_capa_full $batt_capa_now $batt_conso" )
2017-10-14 17:54:16 +02:00
fi
2018-02-26 13:26:50 +01:00
batt_restant+=$( awk '$1 != "" {printf "%d h %02d mn \n", $1, $1*60%60}' <<< "$tempo" )" "
2017-10-14 17:54:16 +02:00
# mise en forme pour sortie, séparateur milliers
2017-10-25 10:23:24 +02:00
if [ "$batt_unit" == "mAh" ]; then
2018-03-09 07:12:34 +01:00
batt_capa_design=$( printf "%'d" "$batt_capa_design" )
batt_capa_full=$( printf "%'d" "$batt_capa_full" )
batt_conso=$( printf "%'d" "$batt_conso" )
batt_capa_now=$( printf "%'d" "$batt_capa_now" )
2017-10-25 10:23:24 +02:00
fi
2017-10-26 19:31:32 +02:00
# sortie
2017-11-06 13:25:09 +01:00
# ligne 1 && n° série
2018-03-09 07:12:34 +01:00
batt_detail+=${ibat#$batRep}": $( cat "$ibat/manufacturer" 2>/dev/null ) "
batt_detail+="($( cat "$ibat/model_name" 2>/dev/null )) $( cat "$ibat/technology" 2>/dev/null ), "
batt_detail+="$batt_capa_design$batt_unit - $batt_volt_min""V / ${batt_volt_now}V (mini/actuel)"
2018-02-23 17:07:39 +01:00
[ "$( xargs <<< "$fg_batt_serial" )" ] && fg_batt_serial="$batt_detail, n° série: $fg_batt_serial" || fg_batt_serial="n/a"
2017-11-06 13:25:09 +01:00
[ "$batt_cycle" != "0" ] && batt_detail+=", $batt_cycle cycles "$'\n' || batt_detail+=" "$'\n' #ln 1fin
# ligne 2
2017-10-14 17:54:16 +02:00
[ "$batt_capa_full" ] && batt_detail+="pleine charge effective: $batt_capa_full$batt_unit, "
batt_detail+="pleine charge théorique: $batt_capa_design$batt_unit => "
2017-10-27 14:59:30 +02:00
if [[ "$batt_conso" != "0" && "$batt_conso" != "0.00" ]]; then # conso éventuelle
2018-02-23 17:07:39 +01:00
batt_restant+="(consommation en cours: $batt_conso$( sed 's/h//' <<< "$batt_unit" ), "
2017-11-06 09:24:58 +01:00
batt_restant+="charge actuelle: $batt_capa_now$batt_unit)"
2017-10-14 17:54:16 +02:00
fi
2017-11-06 13:25:09 +01:00
[ "$batt_sante" ] && batt_detail+="$batt_sante% (indicateur) "$'\n' #ln 2fin
# ligne 3
[ "$batt_restant" ] && batt_detail+="$batt_restant "$'\n' #ln 3fin
2017-10-14 17:54:16 +02:00
# alertes batterie
2017-11-06 13:25:09 +01:00
# ligne 4 éventuelle (alarme batterie)
2017-10-26 00:40:16 +02:00
[ "$alert_batt_alarm" ] && batt_detail+="**batterie en alarme** $alert_batt_alarm "$'\n' #[ln 4]
2017-11-06 13:25:09 +01:00
# lignes 5 alertes
2017-10-14 17:54:16 +02:00
if [ "$batt_capa_design" == "$batt_capa_full" ] && [ "$batt_volt_min" == "$batt_volt_now" ]; then
2017-10-15 00:42:44 +02:00
batt_detail+="les pleines charges et les voltages sont incohérents, batterie "
2017-11-06 13:25:09 +01:00
batt_detail+="mal gérée ou batterie HS? "$'\n' #[ln 5]
2017-10-14 17:54:16 +02:00
fi
2018-03-09 07:12:34 +01:00
if [ "${batt_sante%.*}" -lt 50 ] && [[ "$batt_status" == "Full" || "$batt_status" == "Unknown" ]]; then
batt_detail+="taux de charge batterie faible (moins de 50%): mauvais état? "$'\n' #[ln 5]
2017-10-14 17:54:16 +02:00
fi
done
2017-12-09 17:15:18 +01:00
if [ "$batt_detail" ]; then
fg_batt=${batt_detail::-1} # suppression dernier $'\n'
fi
2018-02-23 17:07:39 +01:00
if [ -z "$( xargs <<< "$fg_batt_serial" )" ] ; then
2017-12-09 17:15:18 +01:00
fg_batt_serial+="n/a"
fi
2017-08-26 09:05:54 +02:00
}
2018-02-23 17:07:39 +01:00
# assigne $fg_cpu (description cpu), fg_nb_threads, $fg_cpu_arch, $fg_vendor=AMD|Intel, $fg_nb_cpu
2018-03-09 07:12:34 +01:00
figet_cpu(){ # 05/03/2018
2017-11-25 21:37:19 +01:00
local cpuinfo speedNom speedMax speedMin speedCpu descrCpu cpu1 cpu2 cpu3
2017-12-14 13:55:05 +01:00
x_cpu=1
2018-03-09 07:12:34 +01:00
2017-12-18 13:46:50 +01:00
fg_nb_threads=0
fg_nb_cpu=0
2017-10-22 06:45:56 +02:00
cpuinfo="$(cat /proc/cpuinfo)"
# speed
2018-02-26 13:26:50 +01:00
speedNom=$( awk -F ':' '/cpu MHz/ { printf "%.2f", $2/1000;exit }' <<< "$cpuinfo" )
speedMax=$( awk '{ printf "%.2f", $1/1000000 }' /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq 2>/dev/null )
speedMin=$( awk '{printf "%.2f", $1/1000000}' /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq 2>/dev/null )
2017-10-22 06:45:56 +02:00
speedCpu=""
2017-11-25 21:37:19 +01:00
if [ "$speedMin" ]; then
speedCpu+="$speedMin/"
2018-02-22 01:26:29 +01:00
descrCpu+="min/"
2017-11-25 21:37:19 +01:00
fi
if [ "$speedNom" ]; then
speedCpu+="$speedNom"
2018-02-22 01:26:29 +01:00
descrCpu+="nom."
2017-11-25 21:37:19 +01:00
fi
if [[ "$speedMax" && "$speedMax" != "$speedNom" ]]; then
speedCpu+="/$speedMax"
descrCpu+="/max"
fi
2018-02-22 01:26:29 +01:00
if [ "$descrCpu" ]; then
descrCpu="fréq. $descrCpu"
fi
2018-01-26 19:56:39 +01:00
if [ "$speedCpu" ]; then
2018-03-09 07:12:34 +01:00
speedCpu=$( printf "%sGHz" "$speedCpu" )
2018-01-26 19:56:39 +01:00
else
2018-02-26 13:26:50 +01:00
speedCpu=$( awk -F '@' '/model name/ {sub(/^ | $/,"",$2); print $2;exit}' <<< "$cpuinfo" )
2018-01-26 19:56:39 +01:00
fi
2017-11-02 05:22:23 +01:00
# motifs?: Processor Dual-Core Quad-Core Six-Core Eight-Core Core 'with Radeon * Graphics'
2017-12-01 22:37:47 +01:00
# nb proc
fg_nb_cpu=$(
2018-02-26 13:26:50 +01:00
awk -F ':|@' '
2017-12-01 22:37:47 +01:00
/^physical id/ { if ($2+1 != nbCpu) nbCpu=$2+1 }
2018-02-26 13:26:50 +01:00
END { printf "%d",nbCpu }' <<< "$cpuinfo" )
2017-11-02 05:22:23 +01:00
# traitement fg_cpu
2017-10-22 06:45:56 +02:00
cpu1=$(
2018-02-26 13:26:50 +01:00
awk -v "speedCpu=$speedCpu" -v "descrCpu=$descrCpu" -F ':|@' '
2018-02-20 03:59:50 +01:00
/^model name/ { gsub(/\(R\)|\(TM\)|\(r\)|\(tm\)|CPU| width/,"",$2); cpu=$2 }
2017-10-22 06:45:56 +02:00
/^physical id/ { if ($2+1 != nbCpu) nbCpu=$2+1 }
/cpu cores/ { procCore=sprintf("%d",$2); if (procCore>1) pllc="s" }
/siblings/ { procThread=sprintf("%d",$2); if (procThread>1) pllt="s" }
2017-11-03 11:28:45 +01:00
END {
2018-02-20 03:59:50 +01:00
printf nbCpu " x " cpu " (" procCore "core" pllc ", " procThread "thread" pllt;
2018-02-22 01:26:29 +01:00
print ") { " speedCpu " (" descrCpu ") }"
2017-11-03 11:28:45 +01:00
}' <<< "$cpuinfo "
2017-10-22 06:45:56 +02:00
)
cpu2=$(
2018-02-26 13:26:50 +01:00
awk -F ':' '
2017-11-25 06:34:56 +01:00
/^vendor_id/{gsub(/ /,"");gsub(/AuthenticAMD/,"AMD");gsub(/GenuineIntel/,"Intel");vendor=$2}
2017-11-03 11:28:45 +01:00
/^cpu family/{family=$2}
2017-10-22 06:45:56 +02:00
/^model[^ ]/{model=$2}; /^stepping/{rev=$2}
2018-02-22 01:26:29 +01:00
/microcode/ { sub(/^ /,"",$2); microCode=$2 }
2017-11-03 11:28:45 +01:00
END {
code=sprintf("{0x%.2X|0x%.2X}",family,model);
2018-02-22 01:26:29 +01:00
print vendor" famille" family", modèle"model,code", révision" rev ", microcode:" microCode
2017-11-03 11:28:45 +01:00
}' <<< "$cpuinfo"
2017-10-22 06:45:56 +02:00
)
cpu3=$(
2018-02-26 13:26:50 +01:00
awk -F ':' '
2017-10-22 06:45:56 +02:00
/address sizes/ { gsub(/ bits/,"b",$2); sub(/physical/,"physique",$2);
2017-11-03 11:28:45 +01:00
sub(/virtual/,"virtuel",$2); sub(/^ | $/,"",$2); add=$2 }
2017-10-22 06:45:56 +02:00
/cache size/ {gsub(/ /,"",$2); gsub(/B/,"o",$2); gsub(/K/,"k",$2); cache=$2}
/bogomips/ { bogomips=sprintf("%d",$2) }
2017-11-03 11:28:45 +01:00
END { print add ", bogomips: " bogomips ", cache: " cache }' <<< "$cpuinfo"
2017-10-22 06:45:56 +02:00
)
2018-02-23 17:07:39 +01:00
fg_cpu="${cpu1// / } "$'\n'"${cpu2// / } "$'\n'${cpu3// / }
fg_nb_threads=$( grep -c '^processor' <<< "$cpuinfo" )
2017-11-02 05:22:23 +01:00
# arch processeur
2017-11-24 18:00:20 +01:00
[ "$( grep -cm1 'flags.* lm ' /proc/cpuinfo )" -ge 1 ] && fg_cpu_arch="64bits" || fg_cpu_arch="32bits"
# fabricant
2018-02-23 17:07:39 +01:00
fg_vendor=$( grep -m1 '^vendor_id' <<< "$cpuinfo" )
2017-11-24 18:00:20 +01:00
fg_vendor=${fg_vendor#*: } # extraction valeur vendor
fg_vendor=${fg_vendor#*: } # extraction valeur vendor
2017-12-16 23:31:32 +01:00
fg_vendor=${fg_vendor//AuthenticAMD/AMD} # allègement
2017-11-24 18:00:20 +01:00
fg_vendor=${fg_vendor//GenuineIntel/Intel} # allègement
2017-11-02 05:22:23 +01:00
# traitement µarchitecture
2017-12-14 13:55:05 +01:00
(( x_cpu_uarch == 1 )) || figet_cpu_uarch
2017-11-06 09:24:58 +01:00
}
2018-02-23 17:07:39 +01:00
# stockage des flags cpu extraits du kernel, assigne $CPU_FLAGS
2017-12-14 20:07:23 +01:00
figet_cpu_flags(){ # 14/12/2017
2017-12-14 13:55:05 +01:00
x_cpu_flags=1
2018-03-09 07:12:34 +01:00
2017-12-14 13:55:05 +01:00
CPU_FLAGS="
2017-11-24 18:00:20 +01:00
# https://github.com/torvalds/linux/blob/master/arch/x86/include/asm/cpufeatures.h
# 11/2017
## Intel-defined CPU features, CPUID level 0x00000001 (edx), word 0
FPU ⟷ Onboard FPU
VME ⟷ Virtual Mode Extensions
DE ⟷ Debugging Extensions
PSE ⟷ Page Size Extensions
TSC ⟷ Time Stamp Counter
MSR ⟷ Model-Specific Registers
PAE ⟷ Physical Address Extensions
MCE ⟷ Machine Check Exception
CX8 ⟷ CMPXCHG8 instruction
APIC ⟷ Onboard APIC
SEP ⟷ SYSENTER/SYSEXIT
MTRR ⟷ Memory Type Range Registers
PGE ⟷ Page Global Enable
MCA ⟷ Machine Check Architecture
CMOV ⟷ CMOV instructions (plus FCMOVcc, FCOMI with FPU)
PAT ⟷ Page Attribute Table
PSE36 ⟷ 36-bit PSEs
PN ⟷ Processor serial number
CLFLUSH ⟷ CLFLUSH instruction
DTS ⟷ Debug Store
ACPI ⟷ ACPI via MSR
MMX ⟷ Multimedia Extensions
FXSR ⟷ FXSAVE/FXRSTOR, CR4.OSFXSR
SSE ⟷ sse
SSE2 ⟷ sse2
SS ⟷ CPU self snoop
HT ⟷ Hyper-Threading
TM ⟷ Automatic clock control
IA64 ⟷ IA-64 processor
PBE ⟷ Pending Break Enable
## AMD-defined CPU features, CPUID level 0x80000001, word 1 Don't duplicate feature flags which are redundant with Intel!
SYSCALL ⟷ SYSCALL/SYSRET
MP ⟷ MP Capable.
NX ⟷ Execute Disable
MMXEXT ⟷ AMD MMX extensions
FXSR_OPT ⟷ FXSAVE/FXRSTOR optimizations
PDPE1GB ⟷ GB pages
RDTSCP ⟷ RDTSCP
LM ⟷ Long Mode (x86-64)
3DNOWEXT ⟷ AMD 3DNow! extensions
3DNOW ⟷ 3DNow!
## Transmeta-defined CPU features, CPUID level 0x80860001, word 2
RECOVERY ⟷ CPU in recovery mode
LONGRUN ⟷ Longrun power control
LRTI ⟷ LongRun table interface
## Other features, Linux-defined mapping, word 3 This range is used for feature bits which conflict or are synthesized
CXMMX ⟷ Cyrix MMX extensions
K6_MTRR ⟷ AMD K6 nonstandard MTRRs
CYRIX_ARR ⟷ Cyrix ARRs (= MTRRs)
CENTAUR_MCR ⟷ Centaur MCRs (= MTRRs)
## cpu types for specific tunings:
K8 ⟷ Opteron, Athlon64
K7 ⟷ Athlon
P3 ⟷ P3
P4 ⟷ P4
CONSTANT_TSC ⟷ TSC ticks at a constant rate
UP ⟷ smp kernel running on up
ART ⟷ Platform has always running timer (ART)
ARCH_PERFMON ⟷ Intel Architectural PerfMon
PEBS ⟷ Precise-Event Based Sampling
BTS ⟷ Branch Trace Store
SYSCALL32 ⟷ syscall in ia32 userspace
SYSENTER32 ⟷ sysenter in ia32 userspace
REP_GOOD ⟷ rep microcode works well
MFENCE_RDTSC ⟷ Mfence synchronizes RDTSC
LFENCE_RDTSC ⟷ Lfence synchronizes RDTSC
ACC_POWERAMD ⟷ Accumulated Power Mechanism
NOPL ⟷ instructions
ALWAYS ⟷ Always-present feature
XTOPOLOGY ⟷ cpu topology enum extensions
TSC_RELIABLE ⟷ TSC is known to be reliable
NONSTOP_TSC ⟷ TSC does not stop in C states
CPUID ⟷ CPU has CPUID instruction itself
EXTD_APICID ⟷ has extended APICID (8 bits)
AMD_DCM ⟷ multi-node processor
APERFMPERF ⟷ APERFMPERF
NONSTOP_TSC_S3 ⟷ TSC doesn't stop in S3 state
TSC_KNOWN_FREQ ⟷ TSC has known frequency
## Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4
PNI ⟷ SSE-3
PCLMULQDQ ⟷ PCLMULQDQ instruction
DTES64 ⟷ 64-bit Debug Store
MONITOR ⟷ Monitor/Mwait support
DS_CPL ⟷ CPL Qual. Debug Store
VMX ⟷ Hardware virtualization
SMX ⟷ Safer mode
EST ⟷ Enhanced SpeedStep
TM2 ⟷ Thermal Monitor 2
SSSE3 ⟷ Supplemental SSE-3
CID ⟷ Context ID
SDBG ⟷ Silicon Debug
FMA ⟷ Fused multiply-add
CX16 ⟷ CMPXCHG16B
XTPR ⟷ Send Task Priority Messages
PDCM ⟷ Performance Capabilities
PCID ⟷ Process Context Identifiers
DCA ⟷ Direct Cache Access
SSE4_1 ⟷ SSE-4.1
SSE4_2 ⟷ SSE-4.2
X2APIC ⟷ x2APIC
MOVBE ⟷ MOVBE instruction
POPCNT ⟷ POPCNT instruction
TSC_DEADLINE_TIMER ⟷ Tsc deadline timer
AES ⟷ AES instructions
XSAVE ⟷ XSAVE/XRSTOR/XSETBV/XGETBV
OSXSAVE ⟷ XSAVE enabled in the OS
AVX ⟷ Advanced Vector Extensions
F16C ⟷ 16-bit fp conversions
RDRAND ⟷ The RDRAND instruction
HYPERVISOR ⟷ Running on a hypervisor
## VIA/Cyrix/Centaur-defined CPU features, CPUID level 0xC0000001, word 5
RNG ⟷ RNG present (xstore)
RNG_EN ⟷ RNG enabled
ACE ⟷ on-CPU crypto (xcrypt)
ACE_EN ⟷ on-CPU crypto enabled
ACE2 ⟷ Advanced Cryptography Engine v2
ACE2_EN ⟷ ACE v2 enabled
PHE ⟷ PadLock Hash Engine
PHE_EN ⟷ PHE enabled
PMM ⟷ PadLock Montgomery Multiplier
PMM_EN ⟷ PMM enabled
## More extended AMD flags: CPUID level 0x80000001, ecx, word 6
LAHF_LM ⟷ LAHF/SAHF in long mode
CMP_LEGACY ⟷ If yes HyperThreading not valid
SVM ⟷ Secure virtual machine
EXTAPIC ⟷ Extended APIC space
CR8_LEGACY ⟷ CR8 in 32-bit mode
ABM ⟷ Advanced bit manipulation
SSE4A ⟷ SSE-4A
MISALIGNSSE ⟷ Misaligned SSE mode
3DNOWPREFETCH ⟷ 3DNow prefetch instructions
OSVWOS ⟷ Visible Workaround
IBS ⟷ Instruction Based Sampling
XOP ⟷ extended AVX instructions
SKINIT ⟷ SKINIT/STGI instructions
WDT ⟷ Watchdog timer
LWP ⟷ Light Weight Profiling
FMA44 ⟷ operands MAC instructions
TCE ⟷ translation cache extension
NODEID_MSR ⟷ NodeId MSR
TBM ⟷ trailing bit manipulations
TOPOEXT ⟷ topology extensions CPUID leafs
PERFCTR_CORE ⟷ core performance counter extensions
PERFCTR_NB ⟷ NB performance counter extensions
BPEXT ⟷ data breakpoint extension
PTSC ⟷ performance time-stamp counter
PERFCTR_LLC ⟷ Last Level Cache performance counter extensions
MWAITX ⟷ MWAIT extension (MONITORX/MWAITX)
## Auxiliary flags: Linux defined - For features scattered in various CPUID levels like 0x6, 0xA etc, word 7.
RING3MWAIT ⟷ Ring 3 MONITOR/MWAIT
CPUID_FAULT ⟷ Intel CPUID faulting
CPB ⟷ AMD Core Performance Boost
EPB ⟷ IA32_ENERGY_PERF_BIAS support
CAT_L3 ⟷ Cache Allocation Technology L3
CAT_L2 ⟷ Cache Allocation Technology L2
CDP_L3 ⟷ Code and Data Prioritization L3
HW_PSTATE ⟷ AMD HW-PState
PROC_FEEDBACK ⟷ AMD ProcFeedbackInterface
SME ⟷ AMD Secure Memory Encryption
INTEL_PPIN ⟷ Intel Processor Inventory Number
INTEL_PT ⟷ Intel Processor Trace
AVX512_4VNNIW ⟷ AVX-512 Neural Network Instructions
AVX512_4FMAPS ⟷ AVX-512 Multiply Accumulation Single precision
MBA ⟷ Memory Bandwidth Allocation
## Virtualization flags: Linux defined, word 8
TPR_SHADOW ⟷ Intel TPR Shadow
VNMI ⟷ Intel Virtual NMI
FLEXPRIORITY ⟷ Intel FlexPriority
EPT ⟷ Intel Extended Page Table
VPID ⟷ Intel Virtual Processor ID
VMMCALL ⟷ Prefer vmmcall to vmcall
XENPV ⟷ Xen paravirtual guest
## Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9
FSGSBASE ⟷ {RD/WR}{FS/GS}BASE instructions
TSC_ADJUST ⟷ TSC adjustment MSR 0x3b
BMI1 ⟷ 1st group bit manipulation extensions
HLE ⟷ Hardware Lock Elision
AVX2 ⟷ AVX2 instructions
SMEP ⟷ Supervisor Mode Execution Protection
BMI2 ⟷ 2nd group bit manipulation extensions
ERMS ⟷ Enhanced REP MOVSB/STOSB
INVPCID ⟷ Invalidate Processor Context ID
RTM ⟷ Restricted Transactional Memory
CQM ⟷ Cache QoS Monitoring
MPX ⟷ Memory Protection Extension
RDT_A ⟷ Resource Director Technology Allocation
AVX512F ⟷ AVX-512 Foundation
AVX512DQ ⟷ AVX-512 DQ (Double/Quad granular) Instructions
RDSEED ⟷ The RDSEED instruction
ADX ⟷ The ADCX and ADOX instructions
SMAP ⟷ Supervisor Mode Access Prevention
AVX512IFMA ⟷ AVX-512 Integer Fused Multiply-Add instructions
CLFLUSHOPT ⟷ CLFLUSHOPT instruction
CLWB ⟷ CLWB instruction
AVX512PF ⟷ AVX-512 Prefetch
AVX512ER ⟷ AVX-512 Exponential and Reciprocal
AVX512CD ⟷ AVX-512 Conflict Detection
SHA_NI ⟷ SHA1/SHA256 Instruction Extensions
AVX512BW ⟷ AVX-512 BW (Byte/Word granular) Instructions
AVX512VL ⟷ AVX-512 VL (128/256 Vector Length) Extensions
#Extended state features, CPUID level 0x0000000d:1 (eax), word 10
XSAVEOPT ⟷ XSAVEOPT
XSAVEC ⟷ XSAVEC
XGETBV1 ⟷ XGETBV with ECX = 1
XSAVES ⟷ XSAVES/XRSTORS
## Intel-defined CPU QoS Sub-leaf, CPUID level 0x0000000F:0 (edx), word 11
CQM_LLC ⟷ LLC QoS if 1
## Intel-defined CPU QoS Sub-leaf, CPUID level 0x0000000F:1 (edx), word 12
CQM_OCCUP_LLC ⟷ LLC occupancy monitoring if 1
CQM_MBM_TOTAL ⟷ LLC Total MBM monitoring
CQM_MBM_LOCAL ⟷ LLC Local MBM monitoring
## AMD-defined CPU features, CPUID level 0x80000008 (ebx), word 13
CLZERO ⟷ CLZERO instruction
IRPERF ⟷ Instructions Retired Count
## Thermal and Power Management Leaf, CPUID level 0x00000006 (eax), word 14
DTHERM ⟷ Digital Thermal Sensor
IDA ⟷ Intel Dynamic Acceleration
ARAT ⟷ Always Running APIC Timer
PLN ⟷ Intel Power Limit Notification
PTS ⟷ Intel Package Thermal Status
HWP ⟷ Intel Hardware P-states
HWP_NOTIFY ⟷ HWP Notification
HWP_ACT_WINDOW ⟷ HWP Activity Window
HWP_EPP ⟷ HWP Energy Perf. Preference
HWP_PKG_REQ ⟷ HWP Package Level Request
## AMD SVM Feature Identification, CPUID level 0x8000000a (edx), word 15
NPT ⟷ Nested Page Table support
LBRV ⟷ LBR Virtualization support
SVM_LOCK ⟷ SVM locking MSR
NRIP_SAVE ⟷ SVM next_rip save
TSC_SCALE ⟷ TSC scaling support
VMCB_CLEAN ⟷ VMCB clean bits support
FLUSHBYASID ⟷ flush-by-ASID support
DECODEASSISTS ⟷ Decode Assists support
PAUSEFILTER ⟷ filtered pause intercept
PFTHRESHOLD ⟷ pause filter threshold
AVIC ⟷ Virtual Interrupt Controller
V_VMSAVE_VMLOAD ⟷ Virtual VMSAVE VMLOAD
VGIF ⟷ Virtual GIF
## Intel-defined CPU features, CPUID level 0x00000007:0 (ecx), word 16
AVX512VBMI ⟷ AVX512 Vector Bit Manipulation instructions
PKU ⟷ Protection Keys for Userspace
OSPKEOS ⟷ Protection Keys Enable
AVX512_VPOPCNTDQ ⟷ POPCNT for vectors of DW/QW
LA57 ⟷ 5-level page tables
RDPID ⟷ RDPIDinstruction
## AMD-defined CPU features, CPUID level 0x80000007 (ebx), word 17
OVERFLOW_RECOV ⟷ MCA overflow recovery support
SUCCOR ⟷ Uncorrectable error containment and recovery
SMCA ⟷ Scalable MCA
"
}
# assigne $fg_uarch
2018-03-09 07:12:34 +01:00
figet_cpu_uarch(){ # 05/03/2018
2017-11-06 09:24:58 +01:00
local var_temp vendor family model
local defaut_model="modèle non répertorié" defaut_family="famille non répertoriée"
local defaut_vendor="fabricant non répertorié"
2017-12-14 13:55:05 +01:00
x_cpu_uarch=1
2018-03-09 07:12:34 +01:00
2017-12-14 13:55:05 +01:00
(( x_cpu == 1 )) || figet_cpu # obtention $fg_vendor
2018-03-09 07:12:34 +01:00
var_temp=$( grep -m1 '^cpu family' /proc/cpuinfo ) # family cpuinfo
2017-11-02 08:40:41 +01:00
var_temp=${var_temp#*: } # extraction valeur family
2018-03-09 07:12:34 +01:00
family=$( printf "%.2X" "$var_temp" ) # conversion hexa family
2017-11-02 08:40:41 +01:00
var_temp=$(grep -m1 '^model' /proc/cpuinfo) # model cpuinfo
var_temp=${var_temp#*: } # extraction valeur model
2018-03-09 07:12:34 +01:00
model=$( printf "%.2X" "$var_temp" ) # conversion hexa model
2017-11-03 11:28:45 +01:00
{
2017-11-24 18:00:20 +01:00
case ${fg_vendor,,} in
2017-11-02 05:22:23 +01:00
*intel*)
case $family in
2017-11-05 06:33:36 +01:00
04) fg_uarch="Intel 80486, 1000 à 600nm";; # arch_x86
2017-11-02 08:40:41 +01:00
05)
case $model in
01 | 02 | 03 | 07) fg_uarch="Intel P5 (Pentium)";; # arch_x86
04 | 08) fg_uarch="Intel P5 (Pentium MMX)";; # arch_x86
09) fg_uarch="Intel Quark";; # arch_x86
*) fg_uarch="Intel $defaut_model";;
esac ;;
0B) fg_uarch="Knights Corner (Xeon Phi)";; # arch_x86?
0F)
case $model in
00 | 01 | 02) fg_uarch="Intel NetBurst (P4)";; # arch_x86?
03 | 04 | 06) fg_uarch="Intel NetBurst (Nocona Prescott)";; # arch_x86?
*) fg_uarch="Intel $defaut_model";;
esac ;;
2017-11-02 05:22:23 +01:00
06)
case $model in
2017-11-02 08:40:41 +01:00
01) fg_uarch="Intel Pentium Pro";; # arch_x86
03 | 04 | 05) fg_uarch="Intel Prescott (Pentium II) 90nm";; # arch_x86
06) fg_uarch="Intel Presler (Pentium II) 65nm";; # arch_x86
07 | 08 | 0A | 0B) fg_uarch="Intel (Pentium III)";; # arch_x86
09 | 15 | 0D) fg_uarch="Intel Dothan (Pentium M) 90nm";; # arch_x86
0E) fg_uarch="Intel Core";; # arch_x86
0F | 16) fg_uarch="Intel Merom (Core2) 65nm";;
17 | 1D) fg_uarch="Intel Penryn (Core2) 45nm";;
1A | 1E | 1F | 2E) fg_uarch="Intel Nehalem 45nm";;
25 | 2C | 2F) fg_uarch="Intel Westmere 32nm";;
2A | 2D) fg_uarch="Intel Sandy Bridge 32nm";;
3A | 3E) fg_uarch="Intel Ivy Bridge 22nm";;
3C | 3F | 45 | 46) fg_uarch="Intel Haswell 22nm";;
3D | 47 | 4F | 56) fg_uarch="Intel Broadwell 14nm";;
4E | 55 | 5E) fg_uarch="Intel Skylake 14nm";;
8E | 9E) fg_uarch="Intel Kaby Lake 14nm";;
2017-11-02 05:22:23 +01:00
# atom
2017-11-05 06:33:36 +01:00
1C | 26) fg_uarch="Intel Atom Bonnell 45nm";;
2017-11-02 08:40:41 +01:00
27 |35 |36) fg_uarch="Intel Atom Saltwell 32nm";;
37 | 4A | 4D | 5A) fg_uarch="Intel Atom Silvermont 22nm";;
4C | 5D | 5F) fg_uarch="Intel Atom Airmont 14nm";;
2017-11-02 05:22:23 +01:00
# Knights-series cores
2017-11-03 11:28:45 +01:00
57) fg_uarch="Intel knights_landing";;
85) fg_uarch="Intel knights_mill";;
2017-11-02 08:40:41 +01:00
*) fg_uarch="Intel $defaut_model";;
2017-11-02 05:22:23 +01:00
esac ;;
2017-11-02 08:40:41 +01:00
*) fg_uarch="Intel $defaut_family";;
esac ;;
2017-11-03 11:28:45 +01:00
*amd*)
case $family in
04) # arch_x86
case $model in
03 | 07 | 08 | 09 | 0A) fg_uarch="AMD Am486";; # années 90
0E | 0F) fg_uarch="AMD Am5x86, 350nm";; # 1995-1999
*) fg_uarch="AMD ?86 $defaut_model";;
esac ;;
05) # arch_x86
case $model in
00 | 01 | 02 | 03) fg_uarch="AMD K5 SSA/5 ou 5k86, 350nm";; # 1996
06 | 07) fg_uarch="AMD K6 350, 250nm";; # 1997-1998
08) fg_uarch="AMD K6-2, 250nm";; # 1998-1999
09 | 0D) fg_uarch="AMD K6-3 Sharptooth, 250, 180nm";; # 1999-2000
*) fg_uarch="AMD K5/K6 $defaut_model";;
esac ;;
06) fg_uarch="AMD K7 Athlon, 250, 180, 130nm, (Classic/T-Bird/Palomino/T-Bred/Barton and Thorton";; # arch_x86 1999-2005
0F) # 2003-?
case $model in
0? | 1?) fg_uarch="AMD K8 Hammer (SledgeHammer), 130-65nm";;
2?) fg_uarch="AMD K8 Hammer (SledgeHammer) (rev.E), 130-65nm";;
4? | 5? | 6? | 7? | C?) fg_uarch="AMD K8 Hammer (SledgeHammer) (rev.F+), 130-65nm";;
*) fg_uarch="AMD K8 Hammer (SledgeHammer) $defaut_model";;
esac ;;
10) fg_uarch="AMD Barcelona K10, 65, 45, 32nm";; # 2007-2012 Agena, Toliman, Thuban, Deneb, Heka, Callisto, Regor, Propus APU: Llano
11) fg_uarch="AMD Turion X2 Ultra/Puma mobile, dérivée K8/K10, 65, 45nm";; # mixture of K8/K10 designs with lower power consumption
12) fg_uarch="AMD Fusion, dérivée K10, 32nm";; # Llano
15)
case $model in
00 | 01) fg_uarch="AMD Bulldozer 1ère génération, 32nm";; # 2011- success to K10,
02 | 1?) fg_uarch="AMD Piledriver (Enhanced Bulldozer) (Bulldozer 2e génération), 32nm";; # 2012- APU: Trinity, Richland
3?) fg_uarch="AMD Steamroller (Bulldozer 3e génération), 28nm";; # 2014- APU: Kaveri
6? | 7?) fg_uarch="AMD Excavator (Bulldozer 4e génération), 28nm";; # 2015- gén. finale APU: Carrizo, Bristol Ridge, Stoney Ridge
*) fg_uarch="AMD Bulldozer, $defaut_model";;
esac ;;
17)
case $model in
*) "AMD Zen, 14nm";; # 2017- APU: Raven Ridge
esac ;;
2017-11-03 12:02:23 +01:00
# basse consommation
14) fg_uarch="AMD Bobcat, 40nm";; # 2011- APU: Desna, Ontario, Zacate
16)
case $model in
0?) "AMD Jaguar 28nm";; # 2013- APU: Kabini, Temash
3?) "AMD Puma ou Puma+ (family 16h 2e génération), 28nm";; # 2014- APU: Beema, Mullins, Puma+ APU: Carrizo-L
*) fg_uarch="AMD family 16h (Jaguar/Puma) $defaut_model";;
esac ;;
2017-11-03 11:28:45 +01:00
*) fg_uarch="AMD $defaut_family";;
esac ;;
2017-11-06 09:24:58 +01:00
*arm*) fg_uarch="ARM (avec quelques processeurs VIA) $defaut_vendor";; # à vérifier, info kernel, récente fonctionnalité 2016?
*centaur*) fg_uarch="Centaur (avec quelques processeurs VIA) $defaut_vendor";;
*cyrix*) fg_uarch="Cyrix $defaut_vendor";;
*nexgen*) fg_uarch="NexGen $defaut_vendor";;
*nsc*) fg_uarch="National Semiconductor $defaut_vendor";;
*rise*) fg_uarch="Rise $defaut_vendor";;
*sis*) fg_uarch="SiS $defaut_vendor";;
*transmeta* | *TMx86*) fg_uarch="Transmeta $defaut_vendor";;
*umc*) fg_uarch="UMC $defaut_vendor";;
*via*) fg_uarch="VIA $defaut_vendor";;
*vortex*) fg_uarch="Vortex $defaut_vendor";;
2017-11-05 06:33:36 +01:00
*) fg_uarch="$defaut_vendor";;
2017-11-02 05:22:23 +01:00
esac
2017-11-03 11:28:45 +01:00
}
[ "$fg_uarch" ] && fg_uarch+=" {0x$family|0x$model}"
2017-08-26 09:05:54 +02:00
}
2017-11-30 20:27:02 +01:00
# assigne $fg_de, $fg_de_panel
2018-03-09 07:12:34 +01:00
figet_de(){ # 06/03/2018 # thanks neofetch
2018-02-26 13:26:50 +01:00
local de="n/a" ps_e version tmp_version
2017-12-14 13:55:05 +01:00
x_de=1
2018-03-09 07:12:34 +01:00
2017-11-21 22:44:56 +01:00
fg_de="n/a"
2017-11-25 19:39:57 +01:00
[ "$ENV_DISPLAY" ] && fg_de+=":no Display"
[ "$ENV_SSH" ] && fg_de+=":ssh"
[[ "$fg_de" =~ : ]] && return 0 # retourne n/a ...
##
2017-10-31 06:52:36 +01:00
de="$XDG_CURRENT_DESKTOP"
2018-02-24 11:59:27 +01:00
de=${de/X-} # Cinnamon
de=${de/Budgie:GNOME/Budgie} # Budgie
2017-11-25 19:39:57 +01:00
if [[ "$wayland" && "$EUID" -eq 0 && -z "$de" ]]; then
fg_de="n/a:wayland root"
2017-11-21 22:44:56 +01:00
return 0
2017-12-09 22:27:46 +01:00
# fallback to using xprop
2017-11-25 19:39:57 +01:00
elif [[ -z "$de" ]]; then
2018-02-24 11:59:27 +01:00
de=$( xprop -root -notype 2>/dev/null )
2018-02-26 13:26:50 +01:00
de=$( grep -E '^KDE_SESSION_VERSION|^_MUFFIN_|^XFCE_' <<< "${de^^}" )
de=${de/KDE_SESSION_VERSION*/kde}
de=${de/_MUFFIN_*/cinnamon}
de=${de/XFCE_*/xfce}
2017-10-02 15:34:29 +02:00
fi
2018-02-23 17:07:39 +01:00
# Mise en forme
2017-12-09 22:27:46 +01:00
if [[ "${de,,}" =~ kde ]]; then # test sur minuscules
2018-02-26 13:26:50 +01:00
de="$de$KDE_SESSION_VERSION"
if type -p plasmashell &>/dev/null; then
# LC_ALL=C kf5-config --version
2018-03-09 07:12:34 +01:00
de+=" ($( plasmashell --version 2>/dev/null ))"
2018-02-26 13:26:50 +01:00
elif type -p kde4-config &>/dev/null; then
tmp_version=$( kde4-config --version &>/dev/null )
tmp_version=${tmp_version#*(KDE }
tmp_version=${tmp_version%)*}
de+=" ($tmp_version)"
fi
2017-11-21 22:44:56 +01:00
elif [[ "${de,,}" =~ tde_full_session ]]; then
2017-11-25 19:39:57 +01:00
de="trinity" # fork kde 3.5
elif [[ "${de,,}" =~ muffin || "${de,,}" =~ cinnamon ]]; then
2017-11-21 22:44:56 +01:00
de=$( cinnamon --version )
2017-11-25 19:39:57 +01:00
de=${de:-cinnamon} # si nul, cinnamon
2018-02-23 17:07:39 +01:00
elif [[ "${de,,}" =~ unity ]]; then
de=$( unity --version )
elif [ "${de,,}" == "xfce" ]; then
version=$( xfce4-about --version | head -n1 )
2018-03-03 07:40:41 +01:00
version=${version#*\(Xfce}
version=${version%\)*}
2018-02-23 17:07:39 +01:00
de="$de$version"
2017-11-21 22:44:56 +01:00
fi
2018-02-26 13:26:50 +01:00
if [ "$de" ]; then
fg_de=${de,,} # minuscule
fg_de=${fg_de^} # caractère 1 en majuscule
fi
2018-02-20 03:59:50 +01:00
2017-11-30 20:27:02 +01:00
###
# panel
2018-02-22 01:26:29 +01:00
ps_e=$( ps -e )
2018-02-26 13:26:50 +01:00
fg_de_panel=$( awk '
2018-02-14 16:48:53 +01:00
#inclus lxpanel, mate-panel, gnome-panel, xfce4-panel, lxqt-panel
/(gnome-shell|kicker|plasma-desktop|plasma-netbook|lxpanel|panel|deepin-dock|ede|sugar|theshell|kicker)$|liri-shell/ { print $NF; exit }
2018-02-23 17:07:39 +01:00
' <<< "${ps_e,,}" )
2018-02-22 01:26:29 +01:00
fg_de_panel=${fg_de_panel^}
2017-08-26 09:05:54 +02:00
}
2017-11-06 13:25:09 +01:00
# $fg_nb_disk : nb disk fixe & amovible, $fg_disk_table : tableau sommaire, fg_disk_serial
2017-10-29 07:39:51 +01:00
# $fg_disk_fixe : liste devices block fixes, $fg_disk_amov : liste devices block amovibles
2018-03-09 07:12:34 +01:00
# $fg_disk_part_fix_tot : espace des partitions fixes montées, fg_disk_part_syst: espace partition système
2017-10-29 07:39:51 +01:00
# $fg_disk_ata, $fg_disk_usb, $fg_disk_mmc, $fg_disk_nvme : liste disk ata, usb...
# $fg_disk_part_fixe_m, $fg_disk_part_amov_m : liste partitions montées, fixes ou amovibles
# $fg_disk_part_swap : liste partitions swap
# $fg_disk_part_fixe_nm, $fg_disk_part_amov_nm : liste partitions non montées, fixes ou amovibles
2018-03-09 07:12:34 +01:00
# shellcheck disable=SC2046,SC2086
# SC2046 Quote this to prevent word splitting
# SC2086 Double quote to prevent globbing and word splitting
figet_disk(){ # 08/03/2018
local idisk size type rev type_disk vendor model serial lsblk
declare -a disk_ls disk_lsblk
2017-12-14 13:55:05 +01:00
x_disk=1
2018-03-09 07:12:34 +01:00
unset fg_disk_fixe fg_disk_amov fg_disk_ata fg_disk_usb fg_disk_mmc fg_disk_nvme
2017-12-18 13:46:50 +01:00
fg_nb_disk=0
2018-03-09 07:12:34 +01:00
# bug ou unicode? printf: caractères accentués diminuent 1 caractère sur arguments suivants, ajouter autant d'espaces
fg_disk_table="$( printf '%-5s %-9s %-6s %-10s %-18s %-6s' "disk" "taille" "type" "vendeur" "modèle" " rév." )"$'\n'
fg_disk_serial="$( printf '%-5s %-10s %-18s %-24s' "disk" "vendeur" "modèle " " n° série" )"$'\n'
for idisk in /sys/block/* ; do # /sys/block/sda ...
idisk=${idisk##*/}
disk_lsblk=( $( lsblk -d -no SIZE,HOTPLUG,REV "/dev/$idisk" ) )
size=${disk_lsblk[0]:-n/a}
type=${disk_lsblk[1]:-n/a}
rev=${disk_lsblk[2]:-n/a}
# ata HITACHI HTS723232A7A364 E3834563HWLWBN
disk_ls=( $( stat -c %N "/dev/disk/by-id/"* | awk -F'/dev/disk/by-id/|-|_' '/'"$idisk"'\047$/ && !/-part/ && !/wwn-/ {gsub(/\047/,"");print $2,$3,$4,$5}' ) )
type_disk=${disk_ls[0]:-n/a}
vendor=${disk_ls[1]:-n/a}
model=${disk_ls[2]:-n/a}
serial=${disk_ls[3]:-n/a}
# bug lsblk, sur disk fixe, sort ata comme vendor
# vendor=$( lsblk -d -no VENDOR "/dev/$idisk" )
# model=$( lsblk -d -no MODEL "/dev/$idisk" )
# serial=$( lsblk -d -no SERIAL "/dev/$idisk" )
size=${size/G/Go}
size=${size/M/Mo}
size=${size/K/ko}
2017-10-28 15:06:37 +02:00
# liste disques fixes ou amovibles
2018-03-09 07:12:34 +01:00
if [ "$type" == "0" ]; then
fg_disk_fixe+="$idisk " # "sda ... sdx"
type="Fixe"
2017-09-27 20:40:28 +02:00
else
2017-10-29 07:39:51 +01:00
fg_disk_amov+="$idisk "
2018-03-09 07:12:34 +01:00
type="Amov"
fi
# liste des disques par type
if [[ "$type_disk" =~ ^ata ]]; then
fg_disk_ata+="$idisk "
elif [[ "$type_disk" =~ ^usb ]]; then
fg_disk_usb+="$idisk "
elif [[ "$type_disk" =~ ^mmc ]]; then
fg_disk_mmc+="$idisk "
elif [[ "$type_disk" =~ ^nvme ]]; then
fg_disk_nvme+="$idisk "
2017-09-27 20:40:28 +02:00
fi
2018-03-09 07:12:34 +01:00
# sorties tables
fg_disk_table+=$( printf '%-5s %-9s %-6s %-10s %-18s %-6s' "$idisk" "$size" "$type" "$vendor" "$model" "$rev")$'\n'
fg_disk_serial+=$( printf '%-5s %-10s %-18s %-24s' "$idisk" "$vendor" "$model" "$serial")$'\n'
2017-09-27 20:40:28 +02:00
done
2018-02-27 09:31:41 +01:00
[ "$fg_disk_table" ] && fg_disk_table=${fg_disk_table::-1} # suppression dernier $'\n'
2017-11-22 20:33:37 +01:00
[ "$fg_disk_serial" ] && fg_disk_serial=${fg_disk_serial::-1} # suppression dernier $'\n'
2018-02-27 09:31:41 +01:00
# nb de disques (fixe+amovible)
2017-12-09 22:27:46 +01:00
fg_nb_disk=$( tr ' ' '\n' <<< "$fg_disk_fixe$fg_disk_amov" | grep -c . )
2017-10-19 01:02:41 +02:00
# séquences partitions fixes, montées (m) et non montées (nm)
2018-02-27 09:31:41 +01:00
lsblk=$( lsblk -no KNAME,MOUNTPOINT $( printf '/dev/%s ' $fg_disk_fixe ) 2>/dev/null )
fg_disk_part_fixe_m=$( awk '/\// {printf "%s ",$1}' <<< "$lsblk" )
fg_disk_part_fixe_nm=$( awk '!/\// && /[0-9]+/ && !/\[SWAP\]/{printf "%s ",$1}' <<< "$lsblk" )
2017-10-19 01:02:41 +02:00
# séquences partitions amovibles, montées (m) et non montées (nm)
2018-02-27 09:31:41 +01:00
lsblk=$( lsblk -no KNAME,MOUNTPOINT $( printf '/dev/%s ' $fg_disk_amov ) 2>/dev/null )
fg_disk_part_amov_m=$( awk '/\// {printf "%s ",$1}' <<< "$lsblk" )
fg_disk_part_amov_nm=$( awk '!/\// && /[0-9]+/ && !/\[SWAP\]/{printf "%s ",$1}' <<< "$lsblk" )
2017-10-20 03:10:56 +02:00
# partitions swap
2018-03-09 07:12:34 +01:00
fg_disk_part_swap=$( lsblk -no KNAME,MOUNTPOINT | awk '/\[SWAP\]/ {printf "%s ",$1}' )
fg_disk_fixe=${fg_disk_fixe:--}
fg_disk_amov=${fg_disk_amov:--}
fg_disk_part_fixe_m=${fg_disk_part_fixe_m:--}
fg_disk_part_swap=${fg_disk_part_swap:--}
fg_disk_part_fixe_nm=${fg_disk_part_fixe_nm:--}
fg_disk_part_amov_m=${fg_disk_part_amov_m:--}
fg_disk_part_amov_nm=${fg_disk_part_amov_nm:--}
2017-10-28 15:06:37 +02:00
# total espaces partitions fixes montées
2017-12-02 11:05:56 +01:00
fg_disk_part_fix_tot="partitions fixes montées (total, utilisé, dispo): "
2018-02-27 09:31:41 +01:00
fg_disk_part_fix_tot+=$( df -h --total --output=size,used,avail $( printf '/dev/%s ' $fg_disk_part_fixe_m ) 2>/dev/null | tail -n-1 )
2018-03-03 07:40:41 +01:00
f__trim "fg_disk_part_fix_tot"
2018-03-09 07:12:34 +01:00
fg_disk_part_fix_tot=$( f__unit_french "$fg_disk_part_fix_tot" )
2017-10-31 09:10:14 +01:00
[ "$fg_disk_part_fix_tot" ] || fg_disk_part_fix_tot="n/a"
2018-03-03 07:40:41 +01:00
# espace partition système
fg_disk_part_syst=$(df -h --output=source,size,used,avail,target | awk '
/\/$/ {gsub(/G/,"Go"); gsub(/M/,"Mo"); gsub(/k/,"ko")
2018-03-03 23:48:13 +01:00
printf "partition système: %s, total: %s, occupé: %s, libre: %s (%d%%)",$1,$2,$3,$4, $4/$2*100}' )
2017-08-26 09:05:54 +02:00
}
2017-10-29 03:19:47 +01:00
# assigne $fg_distrib
2018-03-09 07:12:34 +01:00
figet_distrib(){ # 06/03/2017
2017-10-29 03:19:47 +01:00
local prefix version
2017-12-14 13:55:05 +01:00
x_distrib=1
2018-03-09 07:12:34 +01:00
2017-10-29 03:19:47 +01:00
# priorité /etc/os-release, version officielle systemd
2018-03-09 07:12:34 +01:00
if [ -e "/etc/os-release" ]; then
source "/etc/os-release"
else
source "/usr/lib/os-release"
fi
2017-10-29 03:19:47 +01:00
if [ "$PRETTY_NAME" ] && [ "${PRETTY_NAME,,}" != "Linux" ]; then
fg_distrib="${PRETTY_NAME:-${NAME} ${ID}}" # si PRETTY_NAME null, alors tentative sur NAME et ID
fg_distrib=${fg_distrib//'"'} # suppression "
fi
# essai version sur fichier
2017-12-13 03:15:07 +01:00
version=$( cat /etc/*version 2>/dev/null ) # fichier *version?
2017-10-29 03:19:47 +01:00
[[ $version =~ [0-9.]+ ]] || unset version # qui contient des chiffres
# essai lsb_release, antique méthode
2017-12-13 03:15:07 +01:00
if [ "$fg_distrib" ]; then
2018-03-09 07:12:34 +01:00
if grep -iqs 'microsoft' /proc/version ; then
fg_distrib=$( lsb_release -sd 2>/dev/null )"/windows"
fi
if grep -iqs 'chrome-' /proc/version || [ -f "/dev/cros_ec" ] ; then
fg_distrib=$( lsb_release -sd 2>/dev/null )"/chrome-os"
fi
fi
if [ -z "$fg_distrib" ]; then
fg_distrib=$( lsb_release -sd 2>/dev/null )
2017-12-13 03:15:07 +01:00
fi
2017-10-29 03:54:14 +01:00
# prefix sur nom fichier éventuels *[_-][version|release]
2018-03-09 07:12:34 +01:00
if [ -z "$prefix" ]; then
prefix=$( f__dir -l /etc/*_version | sed -En 's#/etc/(.*)_version#\1#p' )
fi
if [ -z "$prefix" ]; then
prefix=$( f__dir -l /etc/*-version | sed -En 's#/etc/(.*)-version#\1#p' )
fi
if [ -z "$prefix" ]; then
prefix=$( f__dir -l /etc/*-release "os" | sed -En 's#/etc/(.*)-release#\1#p' )
fi
2017-10-29 03:19:47 +01:00
# spécial complément
2018-03-09 07:12:34 +01:00
if [ "$prefix" == "redstar" ]; then
prefix="Red Star OS"
fi
prefix=${prefix^} # 1er caractère majuscule
2017-10-29 03:19:47 +01:00
# final
if [[ "$fg_distrib" && ! "$fg_distrib" =~ $prefix ]]; then # si fg_distrib et ne contient pas prefix
2018-02-23 17:07:39 +01:00
fg_distrib="$prefix - $fg_distrib $( xargs <<< "$version" )"
elif [ -z "$fg_distrib" ] && [ "$prefix" ]; then # si fg_distrib vide et si prefix
fg_distrib="$prefix $( xargs <<< "$version" )"
2017-08-26 09:05:54 +02:00
else
2018-02-23 17:07:39 +01:00
fg_distrib="$fg_distrib $( xargs <<< "$version" )" # utilisation fg_distrib "normal", sans préfixe (compris dans fg_distrib)
2017-08-06 02:43:48 +02:00
fi
2017-11-24 18:00:20 +01:00
fg_distrib=${fg_distrib% } # suppression espace final éventuel
2018-03-09 07:12:34 +01:00
if [ -z "$fg_distrib" ]; then
fg_distrib="${OS^} (distribution indéterminée)"
fi
2017-08-06 02:43:48 +02:00
}
2018-02-13 19:56:53 +01:00
# display manager, assigne $fg_dm (liste éventuelle) ou 'n/a'
2018-03-09 07:12:34 +01:00
figet_dm(){ # 05/03/2018
2018-02-22 01:26:29 +01:00
local dm_list="cdm entranced gdm3 'gdm[^-3]' qingy kdm ldm lightdm lxdm mdm nodm orthos sddm slim startx tint2 wdm xdm"
2018-03-09 07:12:34 +01:00
local idm x11
2017-12-14 13:55:05 +01:00
x_dm=1
2018-03-09 07:12:34 +01:00
2017-12-14 13:55:05 +01:00
fg_dm=""
for idm in $dm_list; do
2018-02-26 13:26:50 +01:00
if ps -e | grep -iqw "$idm" ; then
2018-02-23 17:07:39 +01:00
fg_dm+="${idm} "
2018-02-13 19:56:53 +01:00
elif [[ -e "/var/run/${idm}.pid" || -e "/run/${idm}.pid" || -d "/var/run/$idm/" || -d "/run/$idm/" ]]; then
2018-02-23 17:07:39 +01:00
fg_dm+="${idm} "
2017-12-14 13:55:05 +01:00
fi
done
fg_dm=${fg_dm% } # supression espace final
2018-02-13 19:56:53 +01:00
if [ -z "$fg_dm" ]; then
x11=$( cat /etc/X11/default-display-manager 2>/dev/null )
2017-12-14 13:55:05 +01:00
fg_dm=${x11##*/} # conservation dernier champs ifs '/'
fi
2018-02-24 11:59:27 +01:00
if [ -z "$fg_dm" ]; then
fg_dm=$( systemctl status display-manager 2>/dev/null | grep 'Main PID' )
2018-02-13 19:56:53 +01:00
fg_dm=${fg_dm##* } # conservation dernier champs (ifs ' ')
fg_dm=${fg_dm/\(/} # suppression (
fg_dm=${fg_dm/\)/} # suppression )
2017-12-14 13:55:05 +01:00
fi
2018-02-23 17:07:39 +01:00
# mise en forme finale
if [[ "$fg_dm" == "lightdm" ]]; then
fg_dm=$( lightdm --version 2>&1 )
fi
fg_dm=${fg_dm^} # 1er car maj
2017-12-14 13:55:05 +01:00
[ "$fg_dm" ] || fg_dm="n/a"
}
2018-03-09 07:12:34 +01:00
# informations DMI (firmware partie matériel), assigne $fg_dmi
figet_dmi(){ # 06/03/2018
local product board bios tempo idmi indic1 indic2
2017-11-06 09:24:58 +01:00
local chassis_type=( # type de chassis selon smbios janvier 2017
# http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.1.1.pdf
# DSP0134 version: 3.1.1, janvier 2017, $ 7.4.1 System Enclosure or Chassis Types, table 17
'Other' #01h
'Unknown' #02h
'Desktop' #03h
'Low Profile Desktop' #04h
'Pizza Box' #05h
'Mini Tower' #06h
'Tower' #07h
'Portable' #08h
'Laptop' #09h
'Notebook' #0Ah
'Hand Held' #0Bh
'Docking Station' #0Ch
'All in One' #0Dh
'Sub Notebook' #0Eh
'Space-saving' #0Fh
'Lunch Box' #10h
'Main Server Chassis' #11h
'Expansion Chassis' #12h
'SubChassis' #13h
'Bus Expansion Chassis' #14h
'Peripheral Chassis' #15h
'RAID Chassis' #16h
'Rack Mount Chassis' #17h
'Sealed-case PC' #18h
'Multi-system chassis' #19h
'Compact PCI' #1Ah
'Advanced TCA' #1Bh
'Blade' #1Ch
'Blade Enclosure' #1Dh
'Tablet' #1Eh
'Convertible' #1Fh
'Detachable' #20h
)
2017-12-14 13:55:05 +01:00
x_dmi=1
2018-03-09 07:12:34 +01:00
2017-11-06 09:24:58 +01:00
# ligne1 $product
2017-10-12 08:45:16 +02:00
for idmi in sys_vendor product_name product_version chassis_type; do
2017-12-16 23:31:32 +01:00
tempo=$( cat /sys/class/dmi/id/$idmi 2>/dev/null ) # extraction valeur
tempo=${tempo/x.x*} # ménage
tempo=${tempo/To be filled by O.E.M.} # ménage
tempo=${tempo/Not Specified} # ménage
2018-02-23 17:07:39 +01:00
tempo=$( xargs <<< "$tempo" )
2017-10-12 08:45:16 +02:00
if [ "$idmi" == "chassis_type" ]; then
2017-12-16 23:31:32 +01:00
tempo=" • "${chassis_type[ $(( ${tempo##0} - 1 )) ]} # valeur tableau après mise en forme index
2017-10-12 08:45:16 +02:00
fi
2017-11-06 09:24:58 +01:00
# indic1 pour tester égalité avec $board
2017-10-12 08:45:16 +02:00
[[ "$idmi" == "sys_vendor" || "$idmi" == "product_name" ]] && indic1+="$tempo "
2017-11-06 09:24:58 +01:00
product+="$tempo "
2017-10-12 08:45:16 +02:00
done
2018-03-09 07:12:34 +01:00
unset chassis_type
2017-11-06 09:24:58 +01:00
# ligne2 $board (carte mère) éventuellement pas affiché
2017-10-12 08:45:16 +02:00
for idmi in board_vendor board_name board_version; do
2017-11-30 00:56:31 +01:00
tempo=$( cat /sys/class/dmi/id/$idmi 2>/dev/null )
2018-02-23 17:07:39 +01:00
tempo=$( sed 's/x.xx*//; s/To be filled by O\.E\.M\.//g' <<< "$tempo" | xargs )
2017-11-06 09:24:58 +01:00
# indic2 pour tester égalité avec $product
2017-10-12 08:45:16 +02:00
[[ "$idmi" == "board_vendor" || "$idmi" == "board_name" ]] && indic2+="$tempo "
2017-11-06 09:24:58 +01:00
board+="$tempo "
2017-10-12 08:45:16 +02:00
done
2017-11-06 09:24:58 +01:00
# ligne3 $bios
2017-10-12 08:45:16 +02:00
for idmi in bios_vendor bios_version bios_date; do
2017-11-30 00:56:31 +01:00
tempo=$( cat /sys/class/dmi/id/$idmi 2>/dev/null )
2018-02-23 17:07:39 +01:00
tempo=$( sed 's/x.xx*//; s/To be filled by O\.E\.M\.//g' <<< "$tempo" | xargs )
2017-11-30 00:56:31 +01:00
bios+="$tempo "
2017-10-12 08:45:16 +02:00
done
2018-03-09 07:12:34 +01:00
2017-12-01 21:50:07 +01:00
[ "$product" ] && fg_dmi="$product "$'\n'
[[ "$board" && "$indic1" != "$indic2" ]] && fg_dmi+="$board "$'\n'
[ "$bios" ] && fg_dmi+="$bios "
2017-12-16 23:31:32 +01:00
fg_dmi=$( f_lifting "$fg_dmi" )
2017-11-06 09:24:58 +01:00
}
2017-10-31 09:10:14 +01:00
# infos température et fan via acpi, assigne $fg_hw
2018-03-09 07:12:34 +01:00
# shellcheck disable=SC2010
# SC2010 Don't use ls | grep. Use a glob ... to allow non-alphanumeric filenames.
figet_hw(){ # 05/03/2018
2017-10-20 18:39:46 +02:00
local name labelF inputF labelT inputT critT hystT maxiT fan temp ihw
2017-12-14 13:55:05 +01:00
x_hw=1
2018-03-09 07:12:34 +01:00
2017-10-20 18:39:46 +02:00
if [ ! -d /sys/class/hwmon/ ]; then
2017-10-31 09:10:14 +01:00
fg_hw="gestion acpi hwmon non accessible"
2017-10-12 21:49:57 +02:00
return 1
fi
2018-02-26 13:26:50 +01:00
for ihw in /sys/class/hwmon/* ; do
ihw=${ihw%\*} # fix à la rache, quand /sys/class/hwmon/* est vide, le développement du chemin ne se fait pas (vbox), reste * finale, et erreur sir ls suivants
2018-03-09 07:12:34 +01:00
name=$( cat "$ihw/name" 2>/dev/null )
2018-02-26 13:26:50 +01:00
name=${name:-indéfini} # indéfini si null
2017-10-21 06:54:22 +02:00
## TEMPÉRATURE
2018-02-26 13:26:50 +01:00
if ls "$ihw" | grep -Eq 'temp[0-9]+' ; then # tempX dans un nom de fichier
2017-10-20 18:39:46 +02:00
# extraction label
2018-03-09 07:12:34 +01:00
labelT=$( cat "$ihw"/temp*_label 2>/dev/null | tr ' ' '-' | tr '\n' '/' )
2017-10-20 18:39:46 +02:00
# extraction températures
2018-03-09 07:12:34 +01:00
inputT=$( awk '$0!="" && $0!=0 {printf "%.1f/", $1/1000}' "$ihw"/temp*_input 2>/dev/null )
critT=$( awk '$0!="" && $0!=0 {printf "%.1f/", $1/1000}' "$ihw"/temp*_crit 2>/dev/null )
hystT=$( awk '$0!="" && $0!=0 {printf "%.1f/", $1/1000}' "$ihw"/temp*_crit_hyst 2>/dev/null )
maxiT=$( awk '$0!="" && $0!=0 {printf "%.1f/", $1/1000}' "$ihw"/temp*_max 2>/dev/null )
2017-10-20 18:39:46 +02:00
# suppression doublons
2018-03-09 07:12:34 +01:00
critT=$( echo "$critT" | tr '/' '\n' | sort --unique | tr '\n' '/' )
hystT=$( echo "$hystT" | tr '/' '\n' | sort --unique | tr '\n' '/' )
maxiT=$( echo "$maxiT" | tr '/' '\n' | sort --unique | tr '\n' '/' )
2017-10-20 18:39:46 +02:00
# suppression premier /
2018-02-26 13:26:50 +01:00
critT=${critT#/}
hystT=${hystT#/}
2017-11-01 07:45:18 +01:00
maxiT=${maxiT#/}
2017-10-20 18:39:46 +02:00
# suppression dernier caractère (/) fin (nécessaire si multi-valeurs)
2018-02-26 13:26:50 +01:00
inputT=${inputT%/}
labelT=${labelT%/}
critT=${critT%/}
hystT=${hystT%/}
maxiT=${maxiT%/}
2017-10-20 18:39:46 +02:00
# formation affichage
2017-10-23 03:52:48 +02:00
if [ "$inputT" ]; then
2018-02-26 13:26:50 +01:00
temp+=$( printf "%-8s %s°C %s " "$name" "$inputT" "$labelT" )
[ "$critT" ] && temp+=" (crit: ${critT}°C) "
[ "$hystT" ] && temp+=" (hyst: ${hystT}°C) "
[ "$maxiT" ] && temp+=" (maxi: ${maxiT}°C) "
2017-10-26 00:40:16 +02:00
[ "$temp" ] && temp+=$'\n'
2017-10-23 03:52:48 +02:00
fi
2017-10-20 18:39:46 +02:00
fi
2017-10-21 06:54:22 +02:00
## FAN
2018-02-26 13:26:50 +01:00
if ls "$ihw" | grep -Eq 'fan[0-9]+' ; then # fanX dans un nom de fichier
# extraction label (si existe?)
2018-03-09 07:12:34 +01:00
labelF=$( cat "$ihw"/fan*_label 2>/dev/null | tr ' ' '-' | tr '\n' '/' )
2018-02-26 13:26:50 +01:00
# extraction vitesse fan
2018-03-09 07:12:34 +01:00
inputF=$( cat "$ihw"/fan*_input 2>/dev/null | tr '\n' '/' )
2018-02-26 13:26:50 +01:00
# suppression dernier caractère (/) fin
labelF=${labelF%/}
inputF=${inputF%/}
2017-10-20 18:39:46 +02:00
# formation affichage
2017-10-23 03:52:48 +02:00
if [ "$inputF" ]; then
2018-02-26 13:26:50 +01:00
fan+=$( printf "%-8s %'dt/mn %s " "$name" "$inputF" "$labelF" )$'\n'
2017-10-23 03:52:48 +02:00
fi
2017-10-12 21:49:57 +02:00
fi
done
2017-10-31 09:10:14 +01:00
fg_hw="$temp$fan"
2018-02-26 13:26:50 +01:00
fg_hw=${fg_hw%$'\n'}
2017-10-12 21:49:57 +02:00
}
2018-02-22 01:26:29 +01:00
# $1=-4|-6, assigne $fg_ip, $fg_gws, $fg_ifn, $fg_mac, fg_ip_deprec (ipv6)
2018-03-09 07:12:34 +01:00
figet_ip(){ # 06/03/2018
2017-12-11 16:21:06 +01:00
local target ifn
2018-02-22 01:26:29 +01:00
unset fg_ip fg_ip_deprec fg_gws fg_ifn_prior fg_ifn fg_mac
2017-12-11 16:21:06 +01:00
2018-03-09 07:12:34 +01:00
type -p ip &>/dev/null || return 1
2017-12-11 16:21:06 +01:00
[ "$1" ] && proto="$1" || proto="-4"
2018-02-09 18:45:09 +01:00
2017-12-11 16:21:06 +01:00
# adresses ip
2018-02-26 13:26:50 +01:00
fg_ip=$( ip $proto -o address | awk -v proto="$proto" '
2018-03-03 07:40:41 +01:00
BEGIN { if (proto == -6) larg=41; else larg=16 }
2017-12-11 16:21:06 +01:00
/scope global/ {
sub(/wl.*/,$2" (wifi)",$2); sub(/.*en.*|.*eth.*/,$2" (ethernet)",$2);
2018-03-03 07:40:41 +01:00
printf "%-17s: %-"larg"s ",$2,$4
if (proto == -6) {
match($0,/scope .*\\/); scope=substr($0,RSTART,RLENGTH)
sub(/scope /,"",scope); sub(/\\/,"",scope)
match($0,/preferred_lft .*sec/); lft=substr($0,RSTART,RLENGTH)
sub(/sec/,"s",lft); sub(/preferred_lft/,"lft",lft)
printf "(%s) %s \n",lft,scope }
else printf "\n" }
2017-12-11 16:21:06 +01:00
/fe80::/ {
sub(/wl.*/,$2" (wifi)",$2)
match($0,/scope .* \\/); scope=substr($0,RSTART,RLENGTH); sub(/scope /,"",scope); sub(/ \\/,"",scope)
link=link"\n"sprintf("%-17s: %-22s %s",$2,$4,scope) }
/ lo / { lo=sprintf("%s (loopback) : %s",$2,$4) }
END { printf "%s\n%s",link,lo }
2018-02-26 13:26:50 +01:00
' )
2018-02-09 18:45:09 +01:00
# ipv6, traitemenent adresses dynamiques
if [ "$proto" == "-6" ]; then
2018-02-23 17:07:39 +01:00
fg_ip_deprec=$( sed -n '/temporary deprecated dynamic/p' <<< "$fg_ip" )
fg_ip=$( sed '/temporary deprecated dynamic/d; /preferred_lft 0sec/d' <<< "$fg_ip" )
2018-02-09 18:45:09 +01:00
fi
2017-12-11 16:21:06 +01:00
# passerelles
2018-02-26 13:26:50 +01:00
fg_gws=$( ip $proto route | awk '
2018-03-03 07:40:41 +01:00
BEGIN { if (proto == -6) larg=42; else larg=12 }
/default via/ { printf "%-"larg"s (%s)\n",$3,$5 }
2018-02-26 13:26:50 +01:00
' )
2017-12-11 16:21:06 +01:00
# interface sortante
if [ "$proto" == "-6" ]; then
2018-02-26 13:26:50 +01:00
target=$( ip $proto -o route | awk '/proto ra / { print $1; exit}' )
2018-02-22 01:26:29 +01:00
if [ "$target" ]; then
2018-03-09 07:12:34 +01:00
fg_ifn_prior=$( ip $proto route get "$target" | sed -En 's/.*dev (.*) proto.*src ([0-9a-f:]+).*/\1 (\2)/p' )
2018-02-22 01:26:29 +01:00
fi
2017-12-11 16:21:06 +01:00
else
2017-12-16 23:31:32 +01:00
fg_ifn_prior=$( ip $proto route get 255.255.255.255 | sed -En 's/.*dev (.*) src ([0-9.]+) .*/\1 (\2)/p' )
2017-12-11 16:21:06 +01:00
fi
# ifnames & mac
fg_ifn="" fg_mac=""
2017-12-13 03:15:07 +01:00
for ifn in $( f__dir -l /sys/class/net/ ) ; do
2017-12-11 16:21:06 +01:00
if [ "$ifn" != "lo" ]; then
fg_ifn+="$ifn "
2018-03-09 07:12:34 +01:00
fg_mac+="$ifn: $( cat "/sys/class/net/$ifn/address" )"$'\n'
2017-12-11 16:21:06 +01:00
fi
2017-09-04 13:35:14 +02:00
done
2017-12-11 16:21:06 +01:00
fg_ifn=${fg_ifn% } # suppression dernier espace
fg_mac=${fg_mac%[[:cntrl:]]} # suppression dernier $'\n'
2017-08-26 09:05:54 +02:00
}
2017-12-14 13:55:05 +01:00
# $1=-4|-6, assigne $fg_ip_pub
2018-03-09 07:12:34 +01:00
figet_ip_pub(){ # 08/03/2018
local dig_test ip_test telnet_test iip
2017-12-14 13:55:05 +01:00
2018-03-04 06:04:40 +01:00
list_ip4(){ # testé 11/12/2017
2017-12-14 13:55:05 +01:00
ip_test=( # pas de https
http://whatismyip.akamai.com
http://eth0.me
ipinfo.io/ip # http & https
http://alma.ch/myip.cgi # peu fiable curl
http://checkip.amazonaws.com # peu fiable wget
api.infoip.io/ip # http & https fiable wget
api.ipify.org # http & https fiable wget
http://ipecho.net/plain # peu fiable wget / curl
# http://ipof.in/txt # fail wget
)
dig_test=(
whoami.akamai.net/@ns1-1.akamaitech.net
myip.opendns.com/@resolver1.opendns.com
myip.opendns.com/@resolver2.opendns.com
myip.opendns.com/@resolver3.opendns.com
myip.opendns.com/@resolver4.opendns.com
)
2018-03-09 07:12:34 +01:00
telnet_test=( 212.83.150.199 4.ifcfg.me )
2017-08-26 09:05:54 +02:00
}
2018-03-04 06:04:40 +01:00
list_ip6(){ # testé 11/12/2017
2017-12-14 13:55:05 +01:00
ip_test=(
http://ipv6.whatismyip.akamai.com
ip.tyk.nu # http & https
wgetip.com # http & https
l2.io/ip # http & https peu fiable wget
icanhazip.com # http & https peu fiable wget
http://bot.whatismyipaddress.com # peu fiable wget
https://canhazip.com # peu fiable wget
https://tnx.nl/ip # peu fiable wget
ident.me # http & https peu fiable curl
)
dig_test=(
-6/myip.opendns.com/aaaa/@resolver1.ipv6-sandbox.opendns.com
-6/myip.opendns.com/aaaa/@resolver2.ipv6-sandbox.opendns.com
)
2018-03-09 07:12:34 +01:00
telnet_test=( 2001:bc8:3cc9:100::1 6.ifcfg.me )
2017-08-26 09:05:54 +02:00
}
2017-12-14 13:55:05 +01:00
unset fg_ip_pub
2018-03-09 07:12:34 +01:00
# assignation variables & test connectivité
2017-12-14 13:55:05 +01:00
if [ "$1" == "-4" ]; then
2018-03-09 07:12:34 +01:00
f__test_cnx "-4" || return 1 # test connectivité ipv4
2017-08-26 09:05:54 +02:00
list_ip4
2017-12-14 13:55:05 +01:00
elif [ "$1" == "-6" ]; then
2018-03-09 07:12:34 +01:00
f__test_cnx "-6" || return 1 # test connectivité ipv6
2017-08-26 09:05:54 +02:00
list_ip6
2018-03-09 07:12:34 +01:00
fi
# TELNET
if type -p telnet &>/dev/null && [ -z "$fg_ip_pub" ]; then
for iip in "${telnet_test[@]}"; do
fg_ip_pub=$( telnet "$iip" 23 2>/dev/null )
fg_ip_pub=${fg_ip_pub#*Your IP*is }
[ "$fg_ip_pub" ] && break
done
2017-09-03 09:37:47 +02:00
fi
2017-12-14 13:55:05 +01:00
# DIG
if type -p dig &>/dev/null && [ -z "$fg_ip_pub" ]; then
2018-03-09 07:12:34 +01:00
for iip in "${dig_test[@]}"; do
fg_ip_pub=$( eval dig +short "${iip//\// }" )
2017-12-14 13:55:05 +01:00
[ "$fg_ip_pub" ] && break
2017-08-26 09:05:54 +02:00
done
fi
2017-12-14 13:55:05 +01:00
# WGET
if type -p wget &>/dev/null && [ -z "$fg_ip_pub" ]; then
2018-03-09 07:12:34 +01:00
cmd="wget --quiet --tries=1 -o /dev/null -O - "
for iip in "${ip_test[@]}"; do
fg_ip_pub=$( eval "$cmd" "$iip" )
2017-12-14 13:55:05 +01:00
[ "$fg_ip_pub" ] && break
2017-08-26 09:05:54 +02:00
done
fi
2017-12-14 13:55:05 +01:00
# CURL
if type -p curl &>/dev/null && [ -z "$fg_ip_pub" ]; then
2018-03-09 07:12:34 +01:00
cmd="curl --silent --location --retry 0 "
for iip in "${ip_test[@]}"; do
fg_ip_pub=$( eval "$cmd" "$iip" )
2017-12-14 13:55:05 +01:00
[ "$fg_ip_pub" ] && break
2017-08-26 09:05:54 +02:00
done
2017-08-06 02:43:48 +02:00
fi
2017-12-14 13:55:05 +01:00
# NC
2018-03-09 07:12:34 +01:00
if type -p nc &>/dev/null && [ -z "$fg_ip_pub" ] && [ "$1" == "-4" ]; then
for iip in "${telnet_test[@]}"; do
fg_ip_pub=$( nc "$iip" 23 2>/dev/null )
fg_ip_pub=${fg_ip_pub#*Your IP*is }
[ "$fg_ip_pub" ] && break
done
2017-08-17 10:49:12 +02:00
fi
2017-08-26 09:05:54 +02:00
2017-12-14 13:55:05 +01:00
if [ -z "$fg_ip_pub" ]; then
2017-08-26 09:05:54 +02:00
f__error "il manque une des commandes suivantes:\n" \
2018-03-09 07:12:34 +01:00
"dig / wget / curl / telnet / nc ?\n" \
"ou les ip de test sont devenues défaillantes ?\n" \
"réessayer avant de d'approndir les diagnostiques"
2017-08-06 02:43:48 +02:00
fi
2017-08-02 01:16:24 +02:00
}
2018-02-09 06:07:03 +01:00
# $1=audio|video|net|ethernet|wireless, $2 objet raw|name|module REQUIS: declare -A lspci
# $2=name: device(s) (name) -> assigne ${lspci[name]} ${lspci[nb_card]}
2018-02-22 01:26:29 +01:00
# $2=raw: détail lspci (-nnv) -> assigne ${lspci[card]} [${lspci[prefix_gpu]}]
# $2=module: (module kernel) -> assigne ${lspci[module]} ${lspci[srch_mod]} ${lspci[card]} [${lspci[prefix_gpu]}]
2018-03-09 07:12:34 +01:00
# shellcheck disable=SC2034
# SC2034 foo appears unused. Verify it or export it.
figet_lspci(){ # 07/03/2018
2018-02-09 06:07:03 +01:00
local motif field1 pci slots nb_slots pci modLspci mod_file
2017-11-30 20:27:02 +01:00
if [ "$1" = "audio" ]; then
motif="Audio device|Audio controller|Multimedia audio controller"
elif [ "$1" = "video" ]; then
2017-12-18 13:46:50 +01:00
motif="VGA .* controller|Display controller|3D controller" # |multimedia|Graphic
2017-11-30 20:27:02 +01:00
elif [ "$1" = "net" ]; then
motif="Ethernet controller|Network controller"
2017-12-09 00:19:29 +01:00
elif [ "$1" = "ethernet" ]; then
motif="Ethernet controller"
elif [ "$1" = "wireless" ]; then
motif="Network controller"
2017-11-30 20:27:02 +01:00
fi
2018-02-22 01:26:29 +01:00
2018-02-09 06:07:03 +01:00
# les devices
2017-11-30 20:27:02 +01:00
if [ "$2" == "name" ]; then
2018-03-09 07:12:34 +01:00
unset 'lspci[name]'
2018-02-09 06:07:03 +01:00
while read -r field1 pci; do
pci=${pci%(rev *)}
2018-02-23 17:07:39 +01:00
lspci[name]+="$pci "$'\n'
done <<< "$( lspci | grep -Ei "$motif" )"
2018-02-09 06:07:03 +01:00
lspci[name]=$( f_lifting "${lspci[name]}" )
lspci[name]=${lspci[name]%[[:cntrl:]]} # suppression \n final
lspci[nb_card]=$( grep -cEv '^[[:space:]]*$' <<< "${lspci[name]}" )
return 0
fi
# lspci détaillé RAW (servira à MODULE pour extraire les drivers utilisés)
if [[ "$2" == "raw" || "$2" == "module" ]]; then
2018-03-09 07:12:34 +01:00
unset "lspci[card]"
2017-11-30 20:27:02 +01:00
slots=$( lspci | grep -Ei "$motif" | cut -d" " -f1 )
2017-12-09 00:19:29 +01:00
if ! lspci -nnv &>/dev/null ; then # commande/option indisponible
2017-11-30 20:27:02 +01:00
display="lspci -nnv -s <device> non disponible"
2017-12-13 20:44:22 +01:00
return 1
2018-02-09 06:07:03 +01:00
fi
nb_slots=$( grep -cEv '^[[:space:]]*$' <<< "$slots" )
for pci in $slots; do
if [[ "$1" == "video" && "$nb_slots" -gt 1 ]]; then # multi-cartes graphiques
2018-03-09 07:12:34 +01:00
if type -p optirun &>/dev/null; then
pci=$( optirun lspci -nnv -s "$pci" )
2018-02-09 06:07:03 +01:00
lspci[prefix_gpu]="optirun "
2017-11-30 20:27:02 +01:00
else
2018-03-09 07:12:34 +01:00
pci=$( DRI_PRIME=1 lspci -nnv -s "$pci" )
2018-02-09 06:07:03 +01:00
lspci[prefix_gpu]="DRI_PRIME=1 "
2017-11-30 20:27:02 +01:00
fi
2018-02-09 06:07:03 +01:00
else
2018-03-09 07:12:34 +01:00
pci=$( lspci -nnv -s "$pci" )
2018-02-09 06:07:03 +01:00
fi
pci=${pci/(prog-if*])} # suppression (prog-if...])
pci=${pci/Capabilities: <access denied>[[:cntrl:]][[:blank:]]} # suppression Capabilities: <access denied> (user)
lspci[card]+="$pci"$'\n\n' # double \n pour espace entre card
done
2018-02-22 01:26:29 +01:00
lspci[card]=${lspci[card]%$'\n\n'} # suppression double \n final
2017-11-30 20:27:02 +01:00
fi
2017-12-16 23:31:32 +01:00
2017-12-09 00:19:29 +01:00
# module kernel
if [ "$2" == "module" ]; then
2018-03-09 07:12:34 +01:00
unset "lspci[module]" "lspci[srch_mod]"
2018-02-22 01:26:29 +01:00
[ "${lspci[card]}" ] || return # pas de cards, sortie
2017-12-16 23:31:32 +01:00
2017-12-09 00:19:29 +01:00
# module utilisé
2018-02-26 13:26:50 +01:00
modLspci=$( awk -F ': ' '
2017-12-09 00:19:29 +01:00
/Kernel modules/ {print $2}
2018-02-09 06:07:03 +01:00
' <<< "${lspci[card]}" )
2017-12-09 00:19:29 +01:00
modLspci=${modLspci// /|} # si jamais plusieurs modules ??..
modLspci=${modLspci%|} # si | final
modLspci=${modLspci#|} # si | au début
# modules et emplacement
2018-02-09 06:07:03 +01:00
lspci[module]=$( lsmod | grep -Ew "$modLspci" )
2017-12-13 20:44:22 +01:00
mod_file=$( f_search_ko "$modLspci" )
if [ "$mod_file" ]; then
2018-02-09 06:07:03 +01:00
lspci[module]="${lspci[module]}\n\n$mod_file"
2017-12-09 00:19:29 +01:00
fi
2018-02-09 06:07:03 +01:00
lspci[srch_mod]="$modLspci"
2017-12-09 00:19:29 +01:00
fi
2017-11-30 20:27:02 +01:00
}
2018-03-09 07:12:34 +01:00
# $1=mem|swap [total|notitle|nocoltitle], assigne $fg_mem
2017-11-09 07:00:30 +01:00
# indépendant de procps, affichage plus clair que free, mais résultats identiques
2018-03-09 07:12:34 +01:00
# shellcheck disable=SC2034
# SC2034 foo appears unused. Verify it or export it.
figet_mem(){ # 06/03/2018
local MemTotal MemFree MemAvailable Buffers Cached SReclaimable Shmem MemUsed
2017-12-09 17:15:18 +01:00
local SwapTotal SwapFree SwapCached col a b c MemLibre
2017-12-14 13:55:05 +01:00
2017-12-13 03:15:07 +01:00
while read -r a b c; do
2018-02-23 17:07:39 +01:00
[ "$a" == "MemTotal:" ] && MemTotal="$b" #echo "$a $(( ${b/kB}/1024 ))" ! partie entière !
2017-12-09 17:15:18 +01:00
[ "$a" == "MemAvailable:" ] && MemAvailable="$b"
[ "$a" == "MemFree:" ] && MemFree="$b"
[ "$a" == "Buffers:" ] && Buffers="$b"
[ "$a" == "Cached:" ] && Cached="$b"
[ "$a" == "SReclaimable:" ] && SReclaimable="$b"
[[ "$a" =~ Shmem$|MemShared$ ]] && Shmem="$b" # = free shared
[ "$a" == "SwapTotal:" ] && SwapTotal="$b"
[ "$a" == "SwapFree:" ] && SwapFree="$b"
[ "$a" == "SwapCached:" ] && SwapCached="$b"
2018-02-23 17:07:39 +01:00
done <<< "$(< /proc/meminfo)"
2017-12-09 22:27:46 +01:00
if [ -z "$MemFree" ]; then
fg_mem="debug: pas de calcul mémoire, erreur implémentation bash"
return 1
fi
2018-03-09 07:12:34 +01:00
MemLibre=$(( MemFree+Buffers+Cached+SReclaimable ))
MemUsed=$(( MemTotal - MemLibre ))
SwapUsed=$(( SwapTotal-SwapFree ))
totalTotal=$(( MemTotal+SwapTotal ))
totalUsed=$(( MemUsed+SwapUsed ))
totalAvailable=$(( MemAvailable+SwapFree ))
MemTotal=$( printf '%10s' "$( f__unit_human "$MemTotal" )" )
MemUsed=$( printf '%10s' "$( f__unit_human "$MemUsed" )" )
MemAvailable=$( printf '%10s' "$( f__unit_human "$MemAvailable" )" )
MemFree=$( printf '%10s' "$( f__unit_human "$MemFree" )" )
Buffers=$( printf '%10s' "$( f__unit_human "$Buffers" )" )
Cached=$(( Cached+SReclaimable ))
Cached=$( printf '%10s' "$( f__unit_human "$Cached" )" )
Shmem=$( printf '%10s' "$( f__unit_human "$Shmem" )" )
SwapTotal=$( printf '%10s' "$( f__unit_human "$SwapTotal" )" )
SwapFree=$( printf '%10s' "$( f__unit_human "$SwapFree" )" )
SwapUsed=$( printf '%10s' "$( f__unit_human "$SwapUsed" )" )
SwapCached=$( printf '%10s' "$( f__unit_human "$SwapCached" )" )
totalTotal=$( printf '%10s' "$( f__unit_human "$totalTotal" )" )
totalUsed=$( printf '%10s' "$( f__unit_human "$totalUsed" )" )
totalAvailable=$( printf '%10s' "$( f__unit_human "$totalAvailable" )" )
2017-10-31 09:10:14 +01:00
unset fg_mem
2017-10-04 23:26:27 +02:00
if [[ ! "$*" =~ notitle ]]; then
2017-11-09 07:00:30 +01:00
[[ "$*" =~ nocoltitle ]] || col="mémoire"
fg_mem="$col totale utilisée disponible"$'\n'
2017-10-04 23:26:27 +02:00
fi
if [[ "$*" =~ mem ]]; then
2017-11-09 07:00:30 +01:00
[[ "$*" =~ nocoltitle ]] || col="vive:"
2017-10-31 09:10:14 +01:00
fg_mem+="$col$MemTotal$MemUsed$MemAvailable"$'\n'
2017-10-04 23:26:27 +02:00
fi
if [[ "$*" =~ swap ]]; then
[[ "$*" =~ nocoltitle ]] || col="swap:"
2017-10-31 09:10:14 +01:00
fg_mem+="$col$SwapTotal$SwapUsed$SwapFree"$'\n'
2017-10-04 23:26:27 +02:00
fi
if [[ "$*" =~ total ]]; then
[[ "$*" =~ nocoltitle ]] || col="tot.:"
2017-10-31 09:10:14 +01:00
fg_mem+="$col$totalTotal$totalUsed$totalAvailable"$'\n'
2017-10-04 23:26:27 +02:00
fi
2018-03-09 07:12:34 +01:00
if [ "$fg_mem" ]; then
fg_mem=${fg_mem::-1} # suppression dernier $'\n'
2017-10-09 20:19:07 +02:00
fi
2017-08-17 17:32:34 +02:00
}
2017-12-13 20:44:22 +01:00
# $1=bluetooth, assigne $fg_modules, $fg_mod_motif, fg_srch_mod
2018-03-09 07:12:34 +01:00
figet_modules(){ # 05/03/2018
2017-12-13 20:44:22 +01:00
local modules dir separator mod_ko
2017-12-09 00:19:29 +01:00
if [ "$1" == "bluetooth" ]; then
dir="/lib/modules/$(uname -r)/kernel/drivers/bluetooth" # répertoire à scruter
# recherche modules/formation motif ou liste
2018-03-02 06:06:51 +01:00
separator="|" # séparateur | par défaut
2017-12-13 03:15:07 +01:00
modules=$( f__dir -l "$dir" )
modules=${modules//.ko}
modules=${modules// /|}
2017-12-09 00:19:29 +01:00
modules=${modules%$separator} # suppression dernier séparateur
modules=${modules//$separator/$'\n'}
2018-02-23 17:07:39 +01:00
modules=$( sort <<< "$modules" )
2017-12-09 00:19:29 +01:00
modules=${modules//$'\n'/$separator}
2017-12-13 20:44:22 +01:00
modules=${modules%$separator} # suppression dernier séparateur
2017-12-09 00:19:29 +01:00
fi
2017-11-30 20:27:02 +01:00
# recherche modules chargés
fg_modules="$( lsmod | grep -Ew "$modules" )"
2017-12-09 00:19:29 +01:00
# motif de recherche des modules trouvés dans le kernel
if [ "$modules" ]; then
fg_mod_motif="$modules"
else
unset fg_mod_motif
fi
# extraction 1ère lignes modules chargés = module kernel
2018-02-26 13:26:50 +01:00
fg_srch_mod=$( awk '{ print $1; exit }' <<< "$fg_modules" )
2017-12-09 00:19:29 +01:00
# recherche emplacement modules
2017-12-13 20:44:22 +01:00
mod_ko=$( f_search_ko "$fg_srch_mod" )
if [ "$mod_ko" ]; then
2017-12-09 00:19:29 +01:00
fg_modules="$fg_modules\n\n$mod_ko"
fi
2017-08-17 17:32:34 +02:00
}
2018-02-26 13:26:50 +01:00
# assigne $fg_nb_screen, $fg_resolution. return possible fg_resolution=n/a[:ssh][:no Display][:xrandr absent][:wayland root]
2018-03-09 07:12:34 +01:00
figet_screen(){ # 06/03/2018
2017-12-14 13:55:05 +01:00
x_screen=1
2018-02-26 13:26:50 +01:00
2018-02-07 13:27:59 +01:00
# remplissage infos soucis éventuels, écrasé par résolution quand possible
2017-10-30 10:50:22 +01:00
fg_resolution="n/a"
2017-11-25 19:39:57 +01:00
[ "$ENV_DISPLAY" ] && fg_resolution+=":no Display"
[ "$ENV_SSH" ] && fg_resolution+=":ssh"
2018-03-09 07:12:34 +01:00
type -p xrandr &>/dev/null || fg_resolution+=":xrandr absent"
2017-11-25 19:39:57 +01:00
[[ "$wayland" && "$EUID" -eq 0 ]] && fg_resolution+=":wayland root"
[[ "$fg_resolution" =~ : ]] && return 0 # retourne n/a ... toutes les causes dans $fg_resolution
2017-11-21 22:44:56 +01:00
##
2018-02-07 13:27:59 +01:00
# résolution
2018-02-26 13:26:50 +01:00
fg_resolution=$( xrandr --query 2>/dev/null | awk '
/[0-9]\*/ {gsub(/\*\+/,"",$2); printf "%s pixels (%dHz), ", $1, $2}' )
2018-02-07 13:27:59 +01:00
fg_resolution=${fg_resolution%,*} # suppression ',*' final
2018-02-26 13:26:50 +01:00
# nombre d'écran, xrandr ne retourne pas de nombre correct
if [ "$fg_resolution" ]; then
2018-02-23 17:07:39 +01:00
fg_nb_screen=$( grep -o 'pixels' <<< "$fg_resolution" | grep -c . )
2018-02-26 13:26:50 +01:00
else
fg_resolution="n/a"
2018-02-07 13:27:59 +01:00
fi
2017-11-25 19:39:57 +01:00
}
# assigne $fg_shell, $fg_shells
2018-03-09 07:12:34 +01:00
figet_shell(){ # 06/03/2018 # thanks neofetch
2017-11-25 19:39:57 +01:00
local shell ish
2017-12-14 13:55:05 +01:00
x_shell=1
2018-03-01 08:18:19 +01:00
2018-03-02 06:06:51 +01:00
fg_shell=${SHELL##*/} # suppression jusqu'au dernier /, altern: ps -p $BASHPID -o comm --no-heading
2017-11-25 23:34:31 +01:00
fg_shell=${fg_shell,,}
2018-03-01 08:18:19 +01:00
case ${shell:=$fg_shell} in # shell null, donc assigné avec $fg_shell
2017-11-25 19:39:57 +01:00
bash )
2018-03-01 08:18:19 +01:00
shell=${BASH_VERSION%-*} # 4.4.12(1)-release, suppression -* final
2017-11-25 19:39:57 +01:00
;;
* )
2017-11-25 23:34:31 +01:00
shell=" "$( $SHELL --version 2>/dev/null )
2017-11-25 19:39:57 +01:00
;;
2017-08-26 09:05:54 +02:00
esac
2017-11-25 19:39:57 +01:00
shell=${shell/$fg_shell} # suppression ' nomDuShell'
shell=${shell/, version}
shell=${shell/xonsh\//xonsh }
shell=${shell/options*}
shell=${shell/\(*\)}
shell=${shell/ / } # suppression espace double
2017-11-25 23:34:31 +01:00
fg_shell="${fg_shell^} $shell"
2017-11-25 19:39:57 +01:00
# shells installés détectés
2018-03-01 08:18:19 +01:00
if [ -e "/etc/shells" ]; then
for ish in $( f_grep_file "/etc/shells" "notitre" ); do
fg_shells+=${ish##*/}" " # conservation dernier "champs"
2017-11-25 19:39:57 +01:00
done
fg_shells=${fg_shells% } # suppression espace de fin
2018-02-23 17:07:39 +01:00
fg_shells=$( tr ' ' '\n' <<< "$fg_shells" | sort -u | tr '\n' ' ' ) # tri et suppression doublons
2017-11-25 19:39:57 +01:00
else
fg_shells="n/a"
fi
2017-08-26 09:05:54 +02:00
}
2017-11-24 18:00:20 +01:00
# debian indépendant, assigne $fg_ucode (commentaire), $ucode (paquet deb) & return O|1 (1 si pas d'installation)
2018-03-09 07:12:34 +01:00
figet_ucode(){ # 05/03/2018
2017-11-24 18:00:20 +01:00
local flagRep xfile xfileTest=""
2017-12-14 13:55:05 +01:00
(( x_cpu == 1 )) || figet_cpu
2017-11-24 18:00:20 +01:00
# recherche flags cpu rep_good (besoin réel?)
[ "$( grep -cm1 'flags.*rep_good ' /proc/cpuinfo )" -ge 1 ] && flagRep="rep_good ⟷ rep microcode works well"
# test possible installation
2017-11-29 19:30:16 +01:00
[ "${fg_vendor,,}" == "amd" ] && ucode="amd64-microcode" # si $ucode, µmicorcode possible (amd|intel)
2017-11-24 18:00:20 +01:00
[ "${fg_vendor,,}" == "intel" ] && ucode="intel-microcode"
# test emplacements possibles
amd64=(
/etc/default/amd64-microcode
/etc/modprobe.d/amd64-microcode-blacklist.conf
/lib/firmware/amd-ucode/microcode_amd.bin
)
intel=(
/etc/kernel/preinst.d/intel-microcode
/etc/modprobe.d/intel-microcode-blacklist.conf
/lib/firmware/intel-ucode/
#$( which iucode_tool 2>/dev/null )
)
[[ "${fg_vendor,,}" == "amd" ]] && toScrut=( "${amd64[@]}" ) # array à utiliser selon fabricant
[ "${fg_vendor,,}" == "intel" ] && toScrut=( "${intel[@]}" )
for xfile in "${toScrut[@]}"; do
[ -e "$xfile" ] && xfileTest+="y" # un emplacement, un marqueur
done
if [[ ${#xfileTest} -eq 0 && "$ucode" ]]; then # non installé, possible ($ucode)
2017-11-29 19:30:16 +01:00
fg_ucode="pas de microcode installé bien que existant"
[ "$flagRep" ] && fg_ucode+=", flag Cpu: REP_GOOD"
2017-11-24 18:00:20 +01:00
return 1
elif [[ ${#xfileTest} -eq 0 && -z "$ucode" ]]; then # non installé, non possible
2017-11-29 19:30:16 +01:00
[ "$flagRep" ] && fg_ucode="pas de microcode existant, mais flag Cpu: REP_GOOD ?!" # pas de commentaire sauf si flag
2017-11-24 18:00:20 +01:00
return 0
2017-11-29 19:30:16 +01:00
elif [[ ${#xfileTest} -gt 0 && "$ucode" ]]; then # installé, possible
2017-11-24 18:00:20 +01:00
fg_ucode="microcode installé"
2017-11-29 19:30:16 +01:00
[ "$flagRep" ] && fg_ucode+=", flag Cpu: REP_GOOD" || fg_ucode+=", pas de flag Cpu REP_GOOD"
2017-11-24 18:00:20 +01:00
return 0
elif [[ ${#xfileTest} -gt 0 && -z "$ucode" ]]; then
fg_ucode="microcode: détection défaillante" #installé, non possible ?!
return 0
fi
}
2018-02-20 03:59:50 +01:00
# assigne $fg_wm, contient 'n/a' ou égal 'non trouvé' ou WM
2018-03-09 07:12:34 +01:00
figet_wm(){ # 06/03/2018 base départ neofetch
2018-02-22 01:26:29 +01:00
local id xprop_id wm xprop_root ps_e version compositor
2017-12-14 13:55:05 +01:00
x_wm=1
2018-02-13 19:56:53 +01:00
2017-11-21 22:44:56 +01:00
fg_wm="n/a"
2018-03-09 07:12:34 +01:00
type -p xprop &>/dev/null || fg_wm+=":xprop absent" # pas de xprop, pas de wm?!
2017-11-25 19:39:57 +01:00
[ "$ENV_DISPLAY" ] && fg_wm+=":no Display"
[ "$ENV_SSH" ] && fg_wm+=":ssh"
[[ "$wayland" && "$EUID" -eq 0 ]] && fg_wm+=":wayland root"
[[ "$fg_wm" =~ : ]] && return 0 # retourne n/a ...
2018-02-13 19:56:53 +01:00
2018-02-20 03:59:50 +01:00
## WM
id=$( xprop -root -notype _NET_SUPPORTING_WM_CHECK 2>/dev/null )
id=${id##* } # suppression plus grande chaîne au début jusqu"à ' '
xprop_id=$( xprop -id "$id" -notype 2>/dev/null ) # xprop -id "$id" -notype _NET_WM_NAME
xprop_id=${xprop_id,,} # minuscules
wm=${xprop_id/*_net_wm_name = } # suppression jusqu'à 'name = '
wm=${wm/\"} # suppression premier "
wm=${wm/\"*} # suppression 2e " avec éventuels caractères suivants
if [ -z "$wm" ]; then
xprop_root=$( xprop -root 2>/dev/null )
xprop_root=${xprop_root,,} # tout en minuscule
ps_e=$( ps -e )
ps_e=${ps_e,,} # tout en minuscule
if [[ -z ${xprop_root/*blackbox_pid*/} ]]; then
if [[ -z ${ps_e/*fluxbox*/} ]]; then
wm='fluxbox'
else
wm='blackbox'
fi
elif [[ -z ${xprop_root/*enlightenment*/} ]]; then wm="enlightenment"
elif [[ -z ${xprop_root/*herbstluftwm*/} ]]; then wm="herbstluftwm"
elif [[ -z ${xprop_root/*icewm*/} ]]; then wm="iceWm"
elif [[ -z ${xprop_root/*openbox_pid*/} ]]; then wm="openbox"
elif [[ -z ${xprop_root/*windowmaker*/} ]]; then wm="windowmaker"
elif [[ -z ${ps_e/*afterstep*/} ]]; then wm='afterstep'
elif [[ -z ${ps_e/*awesome*/} ]]; then wm='awesome'
2018-02-22 01:26:29 +01:00
elif [[ -z ${ps_e/*cinnamon*/} ]]; then wm='cinnamon'
2018-02-23 17:07:39 +01:00
elif [[ -z ${ps_e/*compiz*/} ]]; then wm='compiz'
2018-02-20 03:59:50 +01:00
elif [[ -z ${ps_e/*fvwm*/} ]]; then wm='fvwm'
elif [[ -z ${ps_e/*fvwm-crystal*/} ]]; then wm='fvwm-Crystal'
elif [[ -z ${ps_e/*pekwm*/} ]]; then wm='pekwm'
elif [[ -z ${ps_e/*sawfish*/} ]]; then wm='sawfish'
elif [[ -z ${ps_e/*scrotwm*/} ]]; then wm='scrotwm'
elif [[ -z ${ps_e/*spectrwm*/} ]]; then wm='spectrwm'
elif [[ -z ${ps_e/*xfwm4*/} ]]; then wm='xfwm4'
elif [[ -z ${ps_e/*wmii*/} ]]; then wm='wmii'
elif [[ -z ${ps_e/*wmii2*/} ]]; then wm='wmii2'
elif [[ -z ${ps_e/*smithay*/} ]]; then wm='smithay' # aveugle
if [[ "$wm" == +(*wlc|swc|waysome) ]]; then
wm=$( grep -Eo 'sway|orbment|velox|orbital|waysome|loliwm|Way-Cooler|fireplace' <<< "$ps_e" )
fi
2018-02-13 19:56:53 +01:00
2018-02-20 03:59:50 +01:00
elif grep -q "/i3_" <<< "$xprop_root"; then wm="i3"
elif grep -q "/_wm2" <<< "$xprop_root"; then wm="wm2"
elif grep -q "/dwm" <<< "$ps_e"; then wm='dwm'
elif grep -q "/jwm" <<< "$ps_e"; then wm='jwm'
elif grep -q "/twm" <<< "$ps_e"; then wm='twm'
fi
2018-02-13 19:56:53 +01:00
fi
2018-02-23 17:07:39 +01:00
if [ "${wm,,}" == "gnome shell" ]; then
version=$( gnome-shell --version )
2018-02-22 01:26:29 +01:00
version=${version/GNOME Shell}
wm="$wm$version"
2018-02-23 17:07:39 +01:00
elif [ "${wm,,}" == "xfwm4" ]; then
version=$( xfwm4 --version | head -n1 )
version=${version#*version}
version=${version%)*}")"
wm="$wm$version"
2018-02-22 01:26:29 +01:00
fi
2018-02-23 17:07:39 +01:00
2018-02-20 03:59:50 +01:00
## Compositor
2018-02-22 01:26:29 +01:00
if [[ "$xprop_id" =~ marco_version ]]; then # mate, ok
2018-02-20 03:59:50 +01:00
compositor=${xprop_id/*_marco_version = } # suppression jusqu'à ...
2017-11-21 22:44:56 +01:00
compositor=${compositor/\"} # suppression premier"
compositor=${compositor/\"*} # suppression 2e " avec éventuels caractères suivants
2018-02-22 01:26:29 +01:00
compositor="Marco $compositor"
2018-02-20 03:59:50 +01:00
wm=${wm/ (marco)} # suppression (marco) dans wm
2017-11-21 22:44:56 +01:00
fi
2018-02-22 01:26:29 +01:00
if [[ "$xprop_id" =~ mutter_version ]]; then # gnome3 ok
2018-02-20 03:59:50 +01:00
compositor=${xprop_id/*_mutter_version = } # suppression jusqu'à ...
2017-11-21 22:44:56 +01:00
compositor=${compositor/\"} # suppression premier"
compositor=${compositor/\"*} # suppression 2e " avec éventuels caractères suivants
2018-02-22 01:26:29 +01:00
compositor="Mutter $compositor"
2017-11-21 22:44:56 +01:00
fi
2018-02-20 03:59:50 +01:00
if [[ "$xprop_id" =~ muffin_version ]]; then # cinnamon, ok
compositor=${xprop_id/*muffin_version = } # suppression jusqu'à ...
2017-11-21 22:44:56 +01:00
compositor=${compositor/\"} # suppression premier"
compositor=${compositor/\"*} # suppression 2e " avec éventuels caractères suivants
2018-02-22 01:26:29 +01:00
compositor="Muffin $compositor"
2018-02-20 03:59:50 +01:00
wm=${wm/ (muffin)} # suppression (muffin) dans wm
fi
2018-02-22 01:26:29 +01:00
if [[ "$wm" == kwin ]]; then # kde ok
2018-02-20 03:59:50 +01:00
compositor=$( kwin --version )
compositor=${compositor/kwin } # suppression kwin, conservation n° version
fi
if [[ "$wm" =~ sway ]]; then
compositor+=$( sway -v )
fi
if [ -z "$compositor" ]; then
# en aveugle, pour test et adaptations futures
2018-02-23 17:07:39 +01:00
[[ "$xprop_id" =~ compiz ]] && compositor='compiz'
2018-02-20 03:59:50 +01:00
[[ "$xprop_id" =~ compton ]] && compositor+='compton'
[[ "$xprop_id" =~ dwc ]] && compositor+='dwc'
[[ "$xprop_id" =~ fireplace ]] && compositor+='fireplace'
2018-02-23 17:07:39 +01:00
[[ "$xprop_id" =~ gnome-shell ]] && compositor='gnome-shell'
2018-02-20 03:59:50 +01:00
[[ "$xprop_id" =~ grefson ]] && compositor+='grefson'
[[ "$xprop_id" =~ kmscon ]] && compositor+='kmscon'
[[ "$xprop_id" =~ moblin ]] && compositor+='moblin'
[[ "$xprop_id" =~ rustland ]] && compositor+='rustland'
[[ "$xprop_id" =~ sway ]] && compositor+='sway'
[[ "$xprop_id" =~ swc ]] && compositor+='swc'
[[ "$xprop_id" =~ wayhouse ]] && compositor+='wayhouse'
[[ "$xprop_id" =~ westford ]] && compositor+='westford'
[[ "$xprop_id" =~ weston ]] && compositor+='weston'
fi
2018-02-23 17:07:39 +01:00
[ "${compositor,,}" == "${wm,,}" ] && unset wm
# mise en forme finale
if [ "$compositor" == "compiz" ]; then
compositor=$( compiz --version )
fi
2018-02-20 03:59:50 +01:00
wm=${wm^} # 1er caractère en majuscule
2018-02-23 17:07:39 +01:00
compositor=${compositor^} # 1er caractère en majuscule
if [[ "$wm" && "$compositor" ]]; then
fg_wm="$wm ($compositor)"
elif [[ "$wm" ]]; then
fg_wm="$wm"
elif [[ "$compositor" ]]; then
fg_wm="$compositor"
fi
2018-02-20 03:59:50 +01:00
if [ -z "${fg_wm^}" ]; then
fg_wm="non trouvé"
fi
2017-08-06 02:43:48 +02:00
}
2018-02-22 01:26:29 +01:00
# aiguillage export paste, insertion fichier log (debug script)
2018-03-09 07:12:34 +01:00
fipaste(){ # 06/03/2018
if ! f__requis "curl"; then
2017-11-10 12:47:20 +01:00
f__info "une fois Curl installé, inutile de relancer la détection" \
2017-11-24 18:00:20 +01:00
"$GREEN $DIRNAME""getInfo -p" "pour exporter le rapport existant"
2017-11-10 12:47:20 +01:00
return 1
fi
2018-02-22 01:26:29 +01:00
if [ -e "$debug_output" ]; then
echo -e "\n\n# debug script\n" >> "$file_output"
echo '```' >> "$file_output"
cat "$debug_output" >> "$file_output"
echo '```' >> "$file_output"
rm -f "$debug_output"
fi
2017-12-29 12:36:55 +01:00
fipaste_curl_pastery "$file_output" "$pasteDuration" "$optDebug"
# à tester fipaste_curl_markdownshare "$file_output"
2017-08-06 02:43:48 +02:00
}
2017-12-14 20:07:23 +01:00
# $1=fichier à exporter, $2 durée de conservation en jour; $3 debug
2018-03-09 07:12:34 +01:00
fipaste_curl_pastery(){ # 06/03/2018
2017-10-11 02:06:15 +02:00
local curl id pluriel
2018-03-09 07:12:34 +01:00
[ -e "$1" ] || f__error "fichier $1 inexistant"
2017-08-19 03:45:31 +02:00
# curl -X POST "https://www.pastery.net/api/paste/?title=getInfo&language=markdown" -F file=@$1
2017-11-25 20:13:54 +01:00
# un fichier simple curl https://www.pastery.net/api/paste/ -F file=@data.txt
2018-03-09 07:12:34 +01:00
curl=$( curl --silent -X POST "https://www.pastery.net/api/paste/?title=getInfo_$version&language=markdown&duration=$(( $2*1440 ))" --data-binary @"$1" )
2017-10-14 18:20:26 +02:00
if grep -q '"result": "error' <<< "$curl" ;then
2018-03-05 03:52:18 +01:00
f__info "${RED}Erreur critique export rapport:"
2017-10-14 17:54:16 +02:00
f__info "$curl"
else
2018-03-09 07:12:34 +01:00
id=$( echo "$curl" | cut -d '"' -f 4 )
if [ $(( pasteDuration )) -gt 1 ]; then pluriel="s"; else unset pluriel; fi
2017-10-25 10:03:56 +02:00
f__info "votre paste:$GREEN https://www.pastery.net/$id/" \
2018-03-09 07:12:34 +01:00
"(valide pendant $RED$pasteDuration jour$pluriel)"
2017-12-29 12:36:55 +01:00
echo -e "exporté sur https://www.pastery.net/$id/ \n\n" >> "$file_output"
2017-10-14 17:54:16 +02:00
fi
[ "$3" == "debugPaste" ] && f__info "$curl"
# UTF-8
2017-08-19 03:45:31 +02:00
# ?api_key=<api_key>
# &duration=<duration> en mn, 1 jour par défaut
# &language=autodetect possible
# &max_views=<max_views>
# 100ko max
2017-10-14 17:54:16 +02:00
#{"id": "kddgar", "title": "getInfo_2.5.0", "url": "https://www.pastery.net/kddgar/", "language": "markdown", "duration": 1439}
#{"result": "error", "error_msg": "Your request body was not valid UTF-8."}
2017-08-19 03:45:31 +02:00
}
2017-10-02 15:34:29 +02:00
fipaste_curl_markdownshare(){ # à tester/finir
2017-08-19 03:45:31 +02:00
[ -e "$1" ] || f__error "fichier $1 inexistant"
curl -H "Accept: application/json" -X POST -F "text=<$1" https://markdownshare.com/create/
#-A, --user-agent and -e, --referer options
#If you wish to allow a post to expire then add an expire= parameter too:
#expire=Nh Expire in N hours.
#expire=Nd Expire in N days.
#-d expire ? ou --data expire
}
2018-03-03 07:40:41 +01:00
# fonction spécifique à l'installation
2018-03-09 07:12:34 +01:00
fscript_install_special(){ # 08/03/2018
2018-03-03 07:40:41 +01:00
local bashrc
2018-03-09 07:12:34 +01:00
# lanceur dans /usr/bin
2018-03-03 23:48:13 +01:00
echo "#!/bin/bash" > "/usr/bin/gfetch"
echo "$script_install --rc" >> "/usr/bin/gfetch"
chmod +x "/usr/bin/gfetch"
2018-03-09 07:12:34 +01:00
# inscription dans bashrc si trouvé
2018-03-03 23:48:13 +01:00
for ifile in "/etc/bash.bashrc" "/etc/bashrc" "/etc/bash.bashrc.local"; do
if [ -e "$ifile" ]; then
bashrc="$ifile"
break
fi
done
[ "$bashrc" ] || return
2018-03-03 07:40:41 +01:00
grep -q "$script_install --rc" "$bashrc" && return # déjà inscrit
echo -e "\n### add by getInfo" >> "$bashrc"
echo "$script_install --rc" >> "$bashrc"
}
# fonction spécifique à la désinstallation
2018-03-03 23:48:13 +01:00
fscript_remove_special(){ # 03/03/2018
2018-03-03 07:40:41 +01:00
local bashrc
2018-03-03 23:48:13 +01:00
# lanceur
rm -f "/usr/bin/gfetch"
# bashrc
for ifile in "/etc/bash.bashrc" "/etc/bashrc" "/etc/bash.bashrc.local"; do
if [ -e "$ifile" ]; then
bashrc="$ifile"
break
fi
done
2018-03-03 07:40:41 +01:00
sed -i "/$script/d" "$bashrc"
}
2018-03-09 07:12:34 +01:00
# anacron hebdomadaire, via cron horaire, $1=upgrade|install|remove
fscript_cronAnacron(){ # 07/03/2018
2017-08-30 22:46:26 +02:00
local dirAnacron dirSpool fileAnacron
2017-12-05 14:28:41 +01:00
2018-01-26 17:05:36 +01:00
type -t fscript_cronAnacron_special &>/dev/null && fscript_cronAnacron_special # test, si fonction spécifique, appel
2017-12-02 18:24:34 +01:00
dirAnacron="/home/$fu_user/.config/anacron"
2017-08-30 22:46:26 +02:00
dirSpool="$dirAnacron/spool"
fileAnacron="$dirAnacron/$script.anacrontab"
2017-09-06 14:08:03 +02:00
[ "$EUID" -eq 0 ] && sed -i "/$script.anacrontab/d" /etc/crontab
2017-08-26 09:05:54 +02:00
case "$1" in
install | upgrade )
mkdir -p "$dirAnacron"
# table anacron
2017-12-24 14:25:39 +01:00
echo "7 10 $script nice $script_install --upgrade 1>/dev/null" > "$fileAnacron" # juste erreurs en syslog
2017-08-26 09:05:54 +02:00
## anacron journalier pour dev logname
2017-08-27 07:05:26 +02:00
if [ -e "$fileDev" ]; then
2017-12-24 14:25:39 +01:00
echo "1 00 $script""Dev nice $script_install --upgrade 1>/dev/null" >> "$fileAnacron"
2017-08-26 09:05:54 +02:00
fi
# création spool anacron utilisateur
mkdir -p "$dirSpool"
2017-12-02 18:24:34 +01:00
chown -R "$fu_user:" "$dirAnacron" "$dirSpool"
2017-09-06 14:08:03 +02:00
if [ "$EUID" -eq 0 ]; then
2017-08-26 09:05:54 +02:00
# crontab pour activation horaire anacron
2017-12-02 18:24:34 +01:00
echo "@hourly $fu_user /usr/sbin/anacron -t $fileAnacron -S $dirSpool" >> /etc/crontab
2017-08-26 09:05:54 +02:00
fi
2017-12-24 14:25:39 +01:00
grep -q "$script" "/etc/crontab" || echo f__error "inscription crontab"
2017-08-26 09:05:54 +02:00
;;
remove )
2018-03-09 07:12:34 +01:00
rm -f "${dirSpool:?}/$script"* 2>/dev/null
rm -f "$fileAnacron"
rmdir "$${dirSpool:?}" "${dirAnacron:?}" 2>/dev/null
2017-08-26 09:05:54 +02:00
;;
esac
}
2018-03-09 07:12:34 +01:00
# [$1=quiet], assigne $ver_script_install, $ver_script_online, $script_a_jour=ok|KO
# shellcheck disable=SC2120
# SC2120 function references arguments, but none are ever passed. (quiet)
fscript_get_version(){ # 06/03/2018
2017-12-24 14:25:39 +01:00
x_script_get_version=1
2018-03-09 07:12:34 +01:00
2017-12-29 12:36:55 +01:00
# version online
2018-03-09 07:12:34 +01:00
if ! ver_script_online=$( wget -q --timeout=15 -o /dev/null -O - "$url_script" | grep -m1 '^version=' | cut -d'=' -f2 ); then
f__wget_test "$url_script"
fi
2017-12-29 12:36:55 +01:00
# version installée
if [ -e "$script_install" ]; then
2018-03-09 07:12:34 +01:00
ver_script_install=$( grep -m1 '^version=' "$script_install" | cut -d'=' -f2 )
2017-10-17 18:33:12 +02:00
fi
2017-12-29 12:36:55 +01:00
if [[ "$ver_script_online" && "$script_install" ]]; then
[ "$ver_script_install" != "$ver_script_online" ] && script_a_jour="KO" || script_a_jour="ok"
fi
2018-03-05 03:52:18 +01:00
[ "$ver_script_online" ] || ver_script_online="${RED}n/a"
2017-12-29 12:36:55 +01:00
[ "$ver_script_install" ] || ver_script_install="Non installé"
[ "$1" == "quiet" ] && return 0
f__info "raw" "script en place: $GREEN$ver_script_install"
f__info "script en ligne: $YELLOW$ver_script_online"
2017-08-26 09:05:54 +02:00
}
2018-02-26 13:26:50 +01:00
fscript_install(){ # 24/02/2018
2017-12-18 22:12:44 +01:00
2018-02-26 13:26:50 +01:00
if grep -Eq "$script_install|/usr/bin/$script" <<< "$0"; then
2018-03-05 03:52:18 +01:00
f__info "${RED}l'installation dans le système doit se faire depuis le script non installé $GREEN(./$script -i )"
2017-10-09 20:19:07 +02:00
return 1
2017-08-26 09:05:54 +02:00
fi
2018-01-26 17:05:36 +01:00
type -t fscript_install_special &>/dev/null && fscript_install_special # test, si fonction spécifique, appel
2017-11-10 12:47:20 +01:00
f__requis "wget anacron cron" || exit 1
2017-08-26 09:05:54 +02:00
# install /opt
mkdir -p /opt/bin/
2017-12-24 14:25:39 +01:00
cp -d "$0" "$script_install"
ln -s "$script_install" "/usr/bin/$script" &>/dev/null
chmod 775 "$script_install" # rwx rwx r-x, proprio fu_user
2017-08-26 09:05:54 +02:00
# cron/anacron install
fscript_cronAnacron "install"
# création fichier log
2017-12-24 14:25:39 +01:00
touch "$script_logs"
chmod 664 "$script_logs" # rw- rw- r--, proprio fu_user
chown "$fu_user:" "$script_logs" "$script_install"
2017-12-29 12:36:55 +01:00
[ -e "$fileDev" ] || rm -f "$0" ## on efface pas si fileDev (dev)
2017-10-09 20:19:07 +02:00
f__info "log" "$script $version installé dans le système." "maintenant, appel du script par: $GREEN$script$BLUE (sans ./)"
2017-08-26 09:05:54 +02:00
}
2018-02-26 13:26:50 +01:00
fscript_remove(){ # 24/02/2018
2017-12-18 22:12:44 +01:00
2018-02-26 13:26:50 +01:00
if ! grep -Eq "$script_install|/usr/bin/$script" <<< "$0"; then
2018-03-05 03:52:18 +01:00
f__info "${RED}cette fonction doit être appelée depuis le script installé dans le système $GREEN($script -r)"
2017-08-30 01:04:45 +02:00
return 1
fi
2017-12-24 14:25:39 +01:00
if [ ! -x "$script_install" ];then
2017-10-09 20:19:07 +02:00
f__info "$RED$script n'est pas installé"
return 1
2017-08-30 01:04:45 +02:00
fi
2017-12-29 12:36:55 +01:00
2018-01-26 17:05:36 +01:00
type -t fscript_remove_special &>/dev/null && fscript_remove_special # test, si fonction spécifique, appel
2018-03-03 23:48:13 +01:00
# suppression /opt, lien /usr/bin
2017-12-29 12:36:55 +01:00
rm -f "$script_install"
2017-09-06 14:08:03 +02:00
unlink "/usr/bin/$script" &>/dev/null
2017-08-26 09:05:54 +02:00
# cron/anacron remove
fscript_cronAnacron "remove"
2017-12-29 12:36:55 +01:00
2017-08-26 09:05:54 +02:00
f__info "log" "$script $version supprimé du système."
}
2018-03-09 07:12:34 +01:00
# si upgrade en place, $1 != "", [$1 message info]
2018-03-09 17:11:49 +01:00
# shellcheck disable=SC2120
# function references arguments, but none are ever passed.
fscript_update(){ # 09/03/2018
2018-01-24 17:29:41 +01:00
local dirTemp="/tmp/$script-maj" upgradeEnPlace="$1"
2017-12-05 14:28:41 +01:00
2018-01-26 17:05:36 +01:00
type -t fscript_update_special &>/dev/null && fscript_update_special # test, si fonction spécifique, appel
2018-02-26 13:26:50 +01:00
if [ -z "$upgradeEnPlace" ] && ! grep -Eq "$script_install|/usr/bin/$script" <<< "$0"; then
2018-03-05 03:52:18 +01:00
f__info "${RED}cette fonction doit être appelée depuis le script installé dans le système $GREEN($script -u)"
2017-10-27 14:59:30 +02:00
return 1
2017-08-30 01:04:45 +02:00
fi
2017-12-24 14:25:39 +01:00
(( x_script_get_version == 1 )) || fscript_get_version
2017-12-29 12:36:55 +01:00
if [ "$script_a_jour" == "ok" ]; then
2017-08-30 01:04:45 +02:00
f__info "log" "pas de mise à jour disponible pour $script $version"
2017-08-26 09:05:54 +02:00
return 0
2017-12-24 14:25:39 +01:00
else
2018-03-02 06:06:51 +01:00
f__info "mise à jour en cours"
2017-08-26 09:05:54 +02:00
fi
mkdir -p "$dirTemp"
2018-03-09 07:12:34 +01:00
if ! wget -q --tries=2 --timeout=15 -o /dev/null -O "$dirTemp/$script" "$url_script"; then
2018-03-09 17:11:49 +01:00
rm -fr "$dirTemp"
2017-12-24 14:25:39 +01:00
f__wget_test "$url_script"
fi
2017-12-05 20:12:07 +01:00
if grep -q '#!/bin/bash' "$dirTemp/$script" && grep -q '^### END CONTROL' "$dirTemp/$script"; then
2017-12-24 14:25:39 +01:00
cp -d "$dirTemp/$script" "$script_install"
chmod 775 "$script_install" # rwx rwx r-x, proprio fu_user
chown "$fu_user:" "$script_install"
2017-12-29 12:36:55 +01:00
[ -z "$upgradeEnPlace" ] && fscript_cronAnacron "upgrade"
2018-03-09 07:12:34 +01:00
f__info "log" "$script mis à jour en version $ver_script_online $upgradeEnPlace"
2017-11-06 14:22:26 +01:00
else
2017-12-24 14:25:39 +01:00
f_info "log" "$script: échec update" "mauvais téléchargement, réessayer plus tard"
2017-11-06 14:22:26 +01:00
fi
2018-03-09 17:11:49 +01:00
rm -fr "$dirTemp"
2017-08-26 09:05:54 +02:00
}
2017-07-30 17:08:05 +02:00
2018-04-08 16:34:59 +02:00
prg_init(){ # 08/04/2018
2017-12-05 14:28:41 +01:00
2017-11-22 20:33:37 +01:00
PATH='/usr/sbin:/usr/bin:/sbin:/bin'
TERM=xterm
2017-11-27 15:00:49 +01:00
IFS_INI="$IFS"
2017-11-22 20:33:37 +01:00
IFS=$' \t\n'
export PATH TERM IFS
2017-12-05 14:28:41 +01:00
2018-03-02 06:06:51 +01:00
# 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é
2018-03-03 07:40:41 +01:00
# shopt -s nocasematch ( case, [[ ), nocaseglob ( fichier )
2018-03-02 06:06:51 +01:00
2018-03-04 06:04:40 +01:00
# test bash v4
2018-03-09 07:12:34 +01:00
[ "${BASH_VERSINFO[0]}" == 4 ] || f__error "bash v4 requis" "version installée: $BASH_VERSION"
2018-03-04 06:04:40 +01:00
2017-11-24 18:00:20 +01:00
# whereis script retourne vide si installé
2018-03-09 07:12:34 +01:00
DIRNAME=$( dirname "$0" )
2017-11-24 18:00:20 +01:00
DIRNAME=${DIRNAME#/usr/bin} # suppression /usr/bin éventuel au début ( lien )
DIRNAME=${DIRNAME#/opt/bin} # suppression /opt/bin éventuel au début ( install )
[ "$DIRNAME" ] && DIRNAME+="/"
2017-11-22 20:33:37 +01:00
# test /proc
2017-12-11 16:21:06 +01:00
if [ ! -e /proc/cpuinfo ]; then
if ! mount | grep -q "type proc"; then
f__error "/proc non monté"
else
f__error "/proc/cpuinfo non trouvé"
fi
fi
2017-11-22 20:33:37 +01:00
# test OS
OS=$(uname -s)
[[ ${OS,,} =~ linux || ${OS,,} =~ gnu ]] && OS="linux"
[[ ${OS,,} =~ bsd || ${OS,,} =~ Bitrig || ${OS,,} =~ DragonFly ]] && OS="bsd"
[[ ${OS,,} =~ cygwin || ${OS,,} =~ msys || ${OS,,} =~ mingw ]] && OS="windows"
[ "$OS" == "bsd" ] && f__info "ce script pour Linux n'est pas prévu de fonctionner sur BSD..."
[ "$OS" == "windows" ] && f__info "ce script pour Linux n'est pas prévu de fonctionner sous windows..."
[ "$OS" != "linux" ] && f__error "Linux requis"
2017-11-25 19:39:57 +01:00
2017-11-22 20:33:37 +01:00
# recherche wayland
2018-03-09 07:12:34 +01:00
if ps -e | grep -iq 'wayland' ; then
wayland="wayland"
elif [ "$WAYLAND_DISPLAY" ]; then
wayland="wayland"
fi
2017-11-22 20:33:37 +01:00
# test SSH
2018-03-01 08:18:19 +01:00
[[ "$SSH_CLIENT" || "$SSH_CONNECTION" || "$SSH_TTY" || ${DISPLAY%:*} ]] && ENV_SSH="ssh"
2018-02-07 13:27:59 +01:00
# test $DISPLAY => $ENV_DISPLAY vide (null) si pas de serveurX
2017-11-25 19:39:57 +01:00
[ -z "$DISPLAY" ] && ENV_DISPLAY="no DISPLAY"
2017-11-22 20:33:37 +01:00
# détermination user derrière root
f__user
retourFUser="$?"
[ "$retourFUser" -eq 1 ] && f__error "user indéterminé" \
"pour contourner, lancer le script avec:\n$GREEN USER_INSTALL=<user> $0 \n"
if [ "$retourFUser" -eq 2 ]; then
2018-03-09 07:12:34 +01:00
if [ "$EUID" -eq 0 ]; then
fu_user="root"
else
f__error "user détecté, mais pas de home: /home/$fu_user"
fi
2017-11-22 20:33:37 +01:00
f__info "user root"
fi
# requis pour fonctionnement programme
2018-02-07 13:27:59 +01:00
f__requis "gawk|mawk>gawk wget ip>iproute2 lspci>pciutils wc>coreutils uptime>procps" || exit 1
2018-01-26 19:56:39 +01:00
2018-02-20 03:59:50 +01:00
# essai évitement awk à la voidlinux (souci avec awk -F ou -F ' | ')
2018-04-08 16:34:59 +02:00
if ! echo 'abc=123' | awk -F '=|:' {} &>/dev/null; then
2018-02-20 03:59:50 +01:00
f__error "awk en place va poser problème." "Pour participer au débuggage, vous pouvez contacter:" "$contact"
2018-02-14 07:50:17 +01:00
fi
2017-11-22 22:50:00 +01:00
2018-01-26 19:56:39 +01:00
# détection rapide systeme deb
2018-03-09 17:11:49 +01:00
type -p dpkg &>/dev/null && ENV_DEBIAN="oui"
2017-12-24 14:25:39 +01:00
# définition couleurs
f__color
2017-11-22 20:33:37 +01:00
}
2018-03-09 07:12:34 +01:00
prg_1(){ # 02/12/2017 début
2017-12-29 12:36:55 +01:00
echo > "$file_output"
chown $fu_user: "$file_output" &>/dev/null
chmod 666 "$file_output" &>/dev/null # rw-rw-rw-, si root permet écriture & effacement à tous
echo -e "* **$script** sur *$(uname -n)* \n" > "$file_output"
echo -e "$ligneRapport \n" >> "$file_output"
echo -e "--- \n" >> "$file_output"
2017-08-06 19:10:10 +02:00
}
2018-03-09 07:12:34 +01:00
prg_2(){ # 08/03/2018 traitements principaux
2017-10-09 20:19:07 +02:00
if [[ "$1" == all || "$1" =~ s ]]; then #systeme, matériel -cs
2017-12-29 12:36:55 +01:00
echo -e "# ▷ Système" >> "$file_output"
2017-12-17 05:11:11 +01:00
for i in fi_system fi_cpu fi_mem fi_hw fi_batt fi_gpu fi_net fi_audio fi_touchpad fi_bluez fi_usb fi_disk ; do
2017-11-20 17:30:53 +01:00
echo -n "•"
2018-03-09 07:12:34 +01:00
[ "$debugScript" == "ok" ] && echo -e "\n$i : " 1>&2
2017-11-17 07:27:10 +01:00
$i
2017-10-09 20:19:07 +02:00
done
fi
2018-01-26 19:56:39 +01:00
if [[ "$1" == all || "$1" =~ c ]]; then #configuration #debian, packages -cc
2017-12-29 12:36:55 +01:00
echo -e "# ▷ Configuration" >> "$file_output"
2017-12-07 18:06:12 +01:00
for i in fi_efi fi_locale fi_conf fi_vrms fi_packagers ; do
2017-11-17 07:27:10 +01:00
echo -n "•"
2018-03-09 07:12:34 +01:00
[ "$debugScript" == "ok" ] && echo -e "\n$i : " 1>&2
2017-10-09 20:19:07 +02:00
$i
done
fi
if [[ "$1" == all || "$1" =~ r ]]; then #reseau -cr
2017-12-29 12:36:55 +01:00
echo -e "# ▷ Réseau" >> "$file_output"
2018-02-01 18:36:24 +01:00
for i in fi_reseau fi_nm ; do
2017-11-17 07:27:10 +01:00
echo -n "•"
2018-03-09 07:12:34 +01:00
[ "$debugScript" == "ok" ] && echo -e "\n$i : " 1>&2
2017-10-09 20:19:07 +02:00
$i
done
fi
if [[ "$1" == all || "$1" =~ a ]]; then #analyse -ca
2017-12-29 12:36:55 +01:00
echo -e "# ▷ Analyse" >> "$file_output"
2018-03-09 07:12:34 +01:00
for i in fi_system_analyse fi_journal_xorg fi_journal ; do
2017-11-17 07:27:10 +01:00
echo -n "•"
2018-03-09 07:12:34 +01:00
[ "$debugScript" == "ok" ] && echo -e "\n$i : " 1>&2
2017-10-09 20:19:07 +02:00
$i
done
fi
2018-03-09 07:12:34 +01:00
echo -e "\n"
2018-02-24 11:59:27 +01:00
if [[ "$1" != all ]]; then
2018-03-09 07:12:34 +01:00
if [ "$DISPLAY" ]; then f_prnt_md "$file_output"; else pager "$file_output"; fi
2018-02-24 11:59:27 +01:00
fi
2017-08-03 02:44:53 +02:00
}
2018-03-09 07:12:34 +01:00
prg_3(){ # 22/02/2018 fin de traitements
2017-12-29 12:36:55 +01:00
echo -e "--- \n" >> "$file_output"
echo -e "$ligneRapport \n" >> "$file_output"
2018-02-22 01:26:29 +01:00
if [ "$debugScript" == "ok" ]; then
2018-02-23 17:07:39 +01:00
echo -e "\n ***** fin script ***** \n" 1>&2
2018-02-22 01:26:29 +01:00
exec 2>&4 # restauration
exec 4>&- # fermeture FD4
fi
2018-02-01 18:36:24 +01:00
f__dialog_oui_non "non clear" "\n exporter sur le pastebin par défaut?" && fipaste
2017-12-29 12:36:55 +01:00
f__info "le rapport est disponible en local, fichier:$YELLOW $file_output" \
2017-10-11 02:06:15 +02:00
"vous pouvez le visualiser ultérieurement avec $GREEN$script -l" \
2017-12-14 13:55:05 +01:00
"vous pourrez aussi l'exporter avec $BLUE$script -p"
2017-10-09 20:19:07 +02:00
}
2018-03-09 07:12:34 +01:00
prg_menu(){ # 08/03/2018
2017-10-09 20:19:07 +02:00
2018-03-09 07:12:34 +01:00
function prg_menu_display { # 06/03/2018
2017-12-13 03:15:07 +01:00
local centre=50 left=2 larg=60
2017-10-09 20:19:07 +02:00
if [ $(( $(tput cols) )) -le 80 ]; then
2018-03-09 07:12:34 +01:00
centre=$(( $(tput cols)/2+left ))
larg=$(( centre+3*left ))
2017-10-09 20:19:07 +02:00
fi
tput cud 1
tput hpa $left
printf '%.'$larg's' "$1"
tput hpa $centre
printf '%.'$larg's' "$2"
2017-08-03 02:44:53 +02:00
}
2017-12-13 03:15:07 +01:00
2017-12-05 14:28:41 +01:00
echo -en " $GREEN$script -h$STD : afficher l'aide \n"
2018-03-09 07:12:34 +01:00
prg_menu_display "$GREEN$script -c${RED}s$STD : catégorie système" \
2018-03-05 03:52:18 +01:00
"$GREEN$script -c${RED}c$STD : catégorie configuration"
2018-03-09 07:12:34 +01:00
prg_menu_display "$GREEN$script -c${RED}r$STD : catégorie réseau" \
2018-03-05 03:52:18 +01:00
"$GREEN$script -c${RED}a$STD : catégorie analyse"
2017-10-09 20:19:07 +02:00
echo -e "\n\n les catégories peuvent être cumulées: \n" \
2018-03-05 03:52:18 +01:00
" $GREEN$script -c${RED}sa$STD générera un rapport sur le système & l'analyse"
2017-12-05 14:28:41 +01:00
echo -en "\n ( ne pas saisir le préfixe $YELLOW-c$STD, all par défaut)\n"
echo -en "\n choix des catégories à générer (all pour toutes)? "
2017-12-13 03:15:07 +01:00
read -r
2018-03-09 07:12:34 +01:00
if [ "$REPLY" ]; then
REPLY="-c${REPLY,,}"
else
REPLY="all"
fi
2018-02-23 17:07:39 +01:00
REPLY=$( sed 's/-call/all/' <<< "$REPLY" )
2018-03-09 07:12:34 +01:00
exec "$0" "$REPLY"
2017-10-09 20:19:07 +02:00
}
2017-10-27 14:59:30 +02:00
######## début script / initialisation
2017-10-09 20:19:07 +02:00
2017-10-27 14:59:30 +02:00
# tests au démarrage
2017-11-21 22:44:56 +01:00
prg_init
2017-10-09 20:19:07 +02:00
2017-12-06 15:00:33 +01:00
# logo et définition couleurs
2018-03-03 07:40:41 +01:00
[ "$1" != "--rc" ] && f_affichage
2017-12-06 15:00:33 +01:00
2018-01-24 17:29:41 +01:00
# paramètres script
user_agent="Mozilla/5.0 Firefox"
fileDev="/opt/bin/fileDev"
file_output="getInfo_rapport.md"
2018-02-22 01:26:29 +01:00
debug_output="/tmp/$script.log"
2018-01-24 17:29:41 +01:00
script_install="/opt/bin/$script"
script_logs="/var/log/sdeb_$script.log"
url_script="https://framagit.org/kyodev/kyopages/raw/master/scripts/$script"
url_notice="https://kyodev.frama.io/kyopages/scripts/getInfo/"
pasteDuration=7 # durée de conservation standard du paste en jours
spc5=$'\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0'
ligneRapport="Rapport du $(date '+%d/%m/%Y %H:%M %z')$spc5◇$spc5$0 $*$spc5◇$spc5[$script $version]($url_notice)"
2018-02-09 06:07:03 +01:00
declare -A lspci # sortie figet_lspci
2018-01-24 17:29:41 +01:00
2018-03-09 07:12:34 +01:00
options="$*"
2018-01-24 17:29:41 +01:00
2018-02-23 17:07:39 +01:00
for j in $options; do # première passe options
2017-09-23 12:23:41 +02:00
case $j in
2018-02-23 17:07:39 +01:00
--debug-paste ) # si debug, retour json de pastery.net
2017-10-09 20:19:07 +02:00
optDebug="debugPaste"
2018-02-23 17:07:39 +01:00
;;
--debug ) # enregistrement stderr dans $script.log
2018-02-22 01:26:29 +01:00
debugScript="ok"
2018-02-24 11:59:27 +01:00
echo > "$debug_output"
chmod 666 "$debug_output" &>/dev/null
2018-02-22 01:26:29 +01:00
exec 4>&2 # sauvegarde
exec 2> "$debug_output" # redirection
2018-02-23 17:07:39 +01:00
echo -e "$ligneRapport \n" 1>&2
;;
-t* ) # durée de conservation standard du paste en jours
pasteDuration=$(( $( sed -En 's/-t([0-9]+)/\1/p' <<< "$j" ) ))
;;
2018-03-03 07:40:41 +01:00
-i | --install | -r | --remove | --irc | --rrc ) # root requis si install ou remove script
2018-01-24 17:29:41 +01:00
if [ "$EUID" -ne 0 ]; then
f__info "vous devez être$RED ROOT$BLUE pour cette opération"
2018-03-09 07:12:34 +01:00
f__sudo "exec $0 $*"
2018-01-24 17:29:41 +01:00
exit
fi
;;&
2017-08-30 01:04:45 +02:00
esac
done
2018-02-23 17:07:39 +01:00
options=$( sed -E 's/--debug-paste//g; s/-t[0-9]+//g; s/--debug//g' <<< "$options" | xargs ) # nettoyage options
2017-10-09 20:19:07 +02:00
2017-10-24 21:35:26 +02:00
[ "$options" ] || options="all"
2017-10-09 20:19:07 +02:00
2018-01-24 17:29:41 +01:00
for k in $options; do # traitement options menu catégories
2018-02-23 17:07:39 +01:00
categorie+=$( sed -En 's/-c([a-z]+)/\1/p' <<< "$k" )
options=$( sed -E 's/-c[a-z]+//' <<< "$k" | xargs )
2017-10-09 20:19:07 +02:00
done
[ "$categorie" ] && options+=" -c$categorie"
2018-01-24 17:29:41 +01:00
for j in $options; do # deuxième passe options, actions
2017-09-23 12:23:41 +02:00
case $j in
2018-02-24 11:59:27 +01:00
-t | --test ) # test
2017-12-01 21:50:07 +01:00
ORIGIN='test'
2017-10-19 01:02:41 +02:00
prg_1 "$*"
2017-11-22 20:33:37 +01:00
echo -n "•"
2018-01-28 08:16:30 +01:00
# fi_system fi_cpu fi_mem fi_hw fi_batt fi_gpu fi_net fi_audio fi_touchpad fi_bluez fi_usb fi_disk
# fi_efi fi_locale fi_conf fi_vrms fi_packagers
# fi_reseau fi_nm
2018-03-09 07:12:34 +01:00
# fi_system_analyse fi_journal_xorg fi_journal
2018-03-02 06:06:51 +01:00
fi_system
2018-02-22 01:26:29 +01:00
echo
2018-03-09 07:12:34 +01:00
if [ "$DISPLAY" ]; then f_prnt_md "$file_output"; else pager "$file_output"; fi
2018-02-24 11:59:27 +01:00
;;
-c* | all ) # rapport complet ou par catégorie
2018-03-09 07:12:34 +01:00
[ "$j" == "-c" ] && exec "$0" "menu"
2017-10-19 01:02:41 +02:00
prg_1 "$*"
2018-02-23 17:07:39 +01:00
j=$( sed -E 's/-c//' <<< "$j" )
2017-10-09 20:19:07 +02:00
prg_2 "$j"
2017-09-28 20:47:34 +02:00
prg_3
2018-02-24 11:59:27 +01:00
;;
2018-03-02 06:06:51 +01:00
-dx ) # essai détail, xorgOnly
2017-12-02 18:24:34 +01:00
prg_1 "$*"
fi_gpu "xorgOnly"
2018-03-09 07:12:34 +01:00
if [ "$DISPLAY" ]; then f_prnt_md "$file_output"; else pager "$file_output"; fi
2018-02-24 11:59:27 +01:00
exit ;;
2018-03-02 06:06:51 +01:00
-dp ) # essai util source/apt confOnly
2017-12-03 13:48:03 +01:00
prg_1 "$*"
fi_pkg_apt "confOnly"
2018-03-09 07:12:34 +01:00
if [ "$DISPLAY" ]; then f_prnt_md "$file_output"; else pager "$file_output"; fi
2018-02-24 11:59:27 +01:00
;;
-j ) # analyse, catégorie -ca
2017-10-19 08:57:57 +02:00
prg_1 "$*"
prg_2 "a"
2018-02-24 11:59:27 +01:00
;;
-l ) # afficher le rapport existant
2018-03-09 07:12:34 +01:00
if [ "$DISPLAY" ]; then f_prnt_md "$file_output"; else pager "$file_output"; fi
2018-02-24 11:59:27 +01:00
;;
-p ) # exporte le rapport existant
2017-09-04 13:35:14 +02:00
fipaste
2018-02-24 11:59:27 +01:00
;;
--ip ) # affiche ip public (ipv4&6)
2018-03-09 07:12:34 +01:00
fi_ip_pub
2017-12-14 13:55:05 +01:00
echo
2018-02-24 11:59:27 +01:00
;;
--mac ) # affiche adresses mac
2017-09-04 13:35:14 +02:00
figet_ip
2017-12-14 13:55:05 +01:00
f__info "adresses MAC:\n$STD$BOLD$fg_mac"
2018-02-24 11:59:27 +01:00
;;
2018-03-03 23:48:13 +01:00
--rc ) # gfetch
2018-03-03 07:40:41 +01:00
operation="rc"
file_output="/tmp/getInfo.rc"
echo > "$file_output"
chmod 666 "$file_output" &>/dev/null
fi_system "rc"
f_prnt_md "$file_output"
exit ;;
2018-02-24 11:59:27 +01:00
--serial ) # affiche n° série
2017-11-06 13:25:09 +01:00
fi_serial
2018-02-24 11:59:27 +01:00
;;
--ssid ) # affiche configurations ssid
2017-08-26 23:42:34 +02:00
fi_ssid
2018-02-24 11:59:27 +01:00
;;
-h ) # affichage help
2018-01-24 17:29:41 +01:00
f_help
2018-02-24 11:59:27 +01:00
;;
-i | --install ) # installation script
2017-09-03 10:37:30 +02:00
fscript_install
2018-02-24 11:59:27 +01:00
;;
-r | --remove ) # remove script
2017-09-03 10:37:30 +02:00
fscript_remove
2018-02-24 11:59:27 +01:00
;;
2018-03-03 23:48:13 +01:00
--irc ) # install gfetch only
2018-03-03 07:40:41 +01:00
fscript_install_special
;;
2018-03-03 23:48:13 +01:00
--rrc ) # remove gfetch only
2018-03-03 07:40:41 +01:00
fscript_remove_special
;;
2018-02-24 11:59:27 +01:00
-u | --upgrade ) # upgrade script
2018-03-03 07:40:41 +01:00
operation="upgrade" # log si f__error
2017-09-03 10:37:30 +02:00
fscript_update
2018-02-24 11:59:27 +01:00
exit ;;
-us | --us ) # upgrade spécial (en place)
2018-03-09 07:12:34 +01:00
operation="upgrade" # log quand f__error
script_install=$( dirname "$0" )"/$script"
2017-12-29 12:36:55 +01:00
fscript_update "update en place" # redéfinition répertoire install avec celui du script
2018-02-24 11:59:27 +01:00
exit ;;
-v | --version ) # version du script, en ligne et en place
2017-08-26 23:42:34 +02:00
fscript_get_version
2018-02-24 11:59:27 +01:00
;;
menu | * ) # affichage help
2017-10-19 01:02:41 +02:00
prg_1 "$*"
2017-10-09 20:19:07 +02:00
prg_menu
2018-02-24 11:59:27 +01:00
exit ;;
2017-08-03 02:44:53 +02:00
esac
done
2017-10-24 21:35:26 +02:00
2017-08-17 10:49:12 +02:00
exit 0
2017-08-02 01:16:24 +02:00
2017-12-06 15:00:33 +01:00
### END CONTROL (contrôle chargement)
2017-10-19 01:02:41 +02:00
wget -nv -O getInfo https://frama.link/getinfo
2017-08-02 01:16:24 +02:00
chmod +x getInfo && ./getInfo
2017-09-25 23:38:39 +02:00
2017-10-19 01:02:41 +02:00
wget -nv -O getInfo https://framagit.org/kyodev/kyopages/raw/master/scripts/getInfo