2017-07-30 17:08:05 +02:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
2017-11-03 11:28:45 +01:00
|
|
|
|
version=2.22.2
|
|
|
|
|
date="03/11/2017"
|
2017-08-02 01:16:24 +02:00
|
|
|
|
projet="simpledeb"
|
2017-08-26 09:05:54 +02:00
|
|
|
|
contact="IRC freenode ##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-10-25 23:45:00 +02:00
|
|
|
|
# contributeurs: kyodev, saiqui, naguam, agentcobra
|
2017-07-30 17:08:05 +02:00
|
|
|
|
#####
|
|
|
|
|
|
2017-09-22 14:55:55 +02:00
|
|
|
|
# assigne $affichage_text
|
2017-10-28 19:59:06 +02:00
|
|
|
|
f__affichage(){ # 29/10/2017
|
2017-09-19 08:15:55 +02:00
|
|
|
|
f__color
|
|
|
|
|
affichage_text=" _ ___ __
|
2017-07-30 17:08:05 +02:00
|
|
|
|
__ _ ___| |_|_ _|_ __ / _| ___
|
|
|
|
|
/ _' |/ _ \ __|| || '_ \| |_ / _ \
|
|
|
|
|
| (_| | __/ |_ | || | | | _| (_) |
|
|
|
|
|
\__, |\___|\__|___|_| |_|_| \___/
|
2017-10-09 20:19:07 +02:00
|
|
|
|
|___/ "
|
2017-09-22 14:55:55 +02:00
|
|
|
|
clear
|
2017-10-28 19:59:06 +02:00
|
|
|
|
echo -e "$BLUE$affichage_text\n$YELLOW version $version - $date$STD\n"
|
2017-07-30 17:08:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-03 02:44:53 +02:00
|
|
|
|
# detect system architecture, assign $architecture : 32bits, i686 | 64bits, amd64, return 1 on unknown architecture
|
|
|
|
|
# remarque, debian: dpkg --print-architecture affiche i386
|
2017-09-22 14:55:55 +02:00
|
|
|
|
f__architecture(){ # 08/2017 spécifique
|
2017-08-03 02:44:53 +02:00
|
|
|
|
case "$(uname -m)" in
|
|
|
|
|
amd64 | x86_64 )
|
|
|
|
|
architecture="64bits, amd64";;
|
|
|
|
|
i?86 | x86 )
|
|
|
|
|
architecture="32bits, i686";;
|
|
|
|
|
* )
|
|
|
|
|
case "$(getconf LONG_BIT)" in
|
|
|
|
|
64 )
|
|
|
|
|
architecture="64bits, amd64";;
|
|
|
|
|
32 )
|
|
|
|
|
architecture="32bits, i686";;
|
|
|
|
|
*)
|
|
|
|
|
return 1
|
|
|
|
|
esac ;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-22 11:14:21 +02:00
|
|
|
|
# $1=commande à tester, return localisation cmd si existe, return 1 si absent avec aucun message (ala debian)
|
|
|
|
|
# pour un test concis genre [ "$(f__cmd_exist $cmd)" ] && echo "$cmd existe"
|
|
|
|
|
# utilisation `type -p` pour le test, pour une bonne portabilité
|
|
|
|
|
f__cmd_exist(){ # 22/10/2017
|
|
|
|
|
# command -v
|
|
|
|
|
if type -p "$1" &>/dev/null ; then
|
|
|
|
|
echo $(type -p $1)
|
|
|
|
|
else
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-09 20:19:07 +02:00
|
|
|
|
f__color(){ # 08/10/2017
|
|
|
|
|
YELLOW=$(tput setaf 3) # question
|
|
|
|
|
GREEN=$(tput setaf 2) # ok
|
|
|
|
|
BLUE=$(tput setaf 4) # info
|
|
|
|
|
RED=$(tput setaf 1) # alerte
|
|
|
|
|
STD=$(tput sgr0) # retour normal
|
|
|
|
|
MAGENTA=$(tput setaf 5)
|
|
|
|
|
CYAN=$(tput setaf 6)
|
|
|
|
|
BOLD=$(tput bold)
|
|
|
|
|
ITAL=$(tput sitm)
|
|
|
|
|
SOUL=$(tput smul)
|
2017-09-19 08:15:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-09 20:19:07 +02:00
|
|
|
|
# $1=oui|non&[-tx] réponse par défaut & -tx=timeout, $2=message question, return 0 pour oui, 1 pour non
|
|
|
|
|
f__dialog_oui_non(){ # 08/10/2017
|
|
|
|
|
local reply param
|
|
|
|
|
[[ "$1" =~ -t[0-9]{1,2} ]] && param="$(sed -En 's/.*(-t[0-9]{1,2}).*/\1/p' <<< $1)"
|
|
|
|
|
printf "$BLUE$2$STD"
|
|
|
|
|
[[ "$1" =~ oui ]] && printf " [O/n] " || printf " [o/N] "
|
|
|
|
|
if [ "$param" ]; then
|
|
|
|
|
read -t2 reply
|
|
|
|
|
else
|
|
|
|
|
read reply
|
|
|
|
|
fi
|
|
|
|
|
if [ -z "$reply" ]; then
|
|
|
|
|
[[ "$1" =~ oui ]] && reply="oui" || reply="non"
|
|
|
|
|
fi
|
|
|
|
|
echo
|
|
|
|
|
if [[ ${reply,,} =~ ^ou?i?$ ]]; then return 0; else return 1; fi
|
2017-09-15 08:54:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-26 09:05:54 +02:00
|
|
|
|
# affichage $1 en rouge, $1++ optionnels en bleu, sortie script sur erreur, log $1 si $opType=upgrade
|
2017-10-16 07:10:04 +02:00
|
|
|
|
f__error(){ # 15/10/2017
|
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-08-03 02:44:53 +02:00
|
|
|
|
if [ "$opType" == "upgrade" ]; then f__log "$script $version: $1"; fi
|
2017-07-30 17:08:05 +02:00
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-09 20:19:07 +02:00
|
|
|
|
# conversion human, source ko, $1=nombre à convertir, affiche ko ou Mo ou Go, ! dépendance gawk
|
|
|
|
|
f__unit_human(){ # 09/10/2017
|
|
|
|
|
printf "$( gawk ' {
|
2017-10-05 06:37:22 +02: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}
|
2017-10-04 23:26:27 +02:00
|
|
|
|
}' <<< $1 )"
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-09 20:19:07 +02:00
|
|
|
|
# affichage des paramètres en bleu, si $1=raw pas de ligne vide à la fin, si $1=log alors uniquement $2 logué
|
2017-10-16 07:10:04 +02:00
|
|
|
|
f__info(){ # 15/10/2017
|
|
|
|
|
local depart=1 i
|
2017-08-26 09:05:54 +02:00
|
|
|
|
if [ "$1" == "raw" ] || [ "$1" == "log" ]; then depart=2; fi
|
2017-08-21 19:07:08 +02:00
|
|
|
|
[ "$1" == "log" ] && f__log "$(sed -E 's/\\t//;s/\\n// ' <<< $2 | xargs )"
|
2017-10-09 20:19:07 +02:00
|
|
|
|
for (( i=$depart ; i<=$# ; i++ )); do
|
|
|
|
|
echo -e " $BLUE${!i}$STD"
|
|
|
|
|
done
|
|
|
|
|
[ "$1" == raw ] || echo
|
2017-07-30 17:08:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-22 01:49:27 +02:00
|
|
|
|
# log spécifique, fichier log limité à 10000octets, $1 message à loguer
|
2017-10-27 14:59:30 +02:00
|
|
|
|
f__log(){ # 27/10/2017
|
2017-08-22 01:49:27 +02:00
|
|
|
|
if [ -w "$fileLogs" ]; then
|
|
|
|
|
if [ "$(stat -c %s $fileLogs)" -ge "10000" ]; then
|
|
|
|
|
echo "$(date +%Y%m%d\ %H%M%S) $1" &>/dev/null > "$fileLogs"
|
|
|
|
|
else
|
|
|
|
|
echo "$(date +%Y%m%d\ %H%M%S) $1" &>/dev/null >> "$fileLogs"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2017-07-30 17:08:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-17 10:49:12 +02:00
|
|
|
|
# test dépendances/paquets, $1 liste commande[>paquet] (ex: killall>psmisc)
|
2017-08-18 20:15:13 +02:00
|
|
|
|
# si manque, SORTIE & info commandes manquantes, si debian, SORTIE & proposition paquet à installer
|
2017-08-17 10:49:12 +02:00
|
|
|
|
# si $2=debOnly et si paquets manquants: return 1 et $debOnlyPackages ( $1=liste paquets )
|
|
|
|
|
# si $2=debOnly et si paquets présent: return 0 et $debOnlyPresents ( $1=liste paquets )
|
|
|
|
|
# attention priorité $debOnlyPackages sur $debOnlyPresents
|
2017-10-22 11:14:21 +02:00
|
|
|
|
f__requis(){ # 22/10/2017
|
2017-10-17 18:33:12 +02:00
|
|
|
|
local dependsMissing packagesMissing command package ireq compteur pluriel
|
2017-08-30 22:46:26 +02:00
|
|
|
|
unset debOnlyPackages debOnlyPresents
|
2017-10-17 18:33:12 +02:00
|
|
|
|
for ireq in $1; do
|
|
|
|
|
command="$(cut -d '>' -f 1 <<< $ireq)"
|
|
|
|
|
package="$(cut -d '>' -f 2 <<< $ireq)"
|
2017-08-30 22:46:26 +02:00
|
|
|
|
if [ "$2" == "debOnly" ]; then
|
2017-10-22 11:14:21 +02:00
|
|
|
|
if [ "$(f__cmd_exist dpkg)" ]; then # package only et debian
|
2017-08-30 22:46:26 +02:00
|
|
|
|
LC_ALL=C dpkg --get-selections | grep -qE "^$package[[:space:]]+install" \
|
|
|
|
|
&& debOnlyPresents+="$package " || debOnlyPackages+="$package "
|
2017-10-17 18:33:12 +02:00
|
|
|
|
else
|
|
|
|
|
f__error "dpkg n'est pas disponible sur ce système"
|
|
|
|
|
fi
|
2017-10-22 11:14:21 +02:00
|
|
|
|
elif [ -z "$(f__cmd_exist $command)" ]; then
|
2017-08-30 22:46:26 +02:00
|
|
|
|
dependsMissing+="$command "
|
|
|
|
|
packagesMissing+="$package "
|
2017-08-17 10:49:12 +02:00
|
|
|
|
fi
|
2017-08-30 22:46:26 +02:00
|
|
|
|
done
|
|
|
|
|
[ "$debOnlyPackages" ] && debOnlyPackages="$(xargs <<< $debOnlyPackages)" # trim début & fin
|
|
|
|
|
[ "$debOnlyPresents" ] && debOnlyPresents="$(xargs <<< $debOnlyPresents)" # trim début & fin
|
|
|
|
|
[ "$debOnlyPackages" ] && return 1
|
|
|
|
|
[ "$debOnlyPresents" ] && return 0
|
|
|
|
|
if [ "$dependsMissing" ]; then
|
2017-10-17 18:33:12 +02:00
|
|
|
|
compteur="$(wc -w <<< $dependsMissing)"
|
|
|
|
|
[ "$compteur" -gt "1" ] && pluriel="s" || unset pluriel
|
|
|
|
|
if [ -e /etc/debian_version ]; then
|
|
|
|
|
f__error "$compteur paquet$pluriel manquant$pluriel: $STD$BOLD$dependsMissing" \
|
|
|
|
|
"\n vous devriez exécuter:$GREEN apt install $packagesMissing"
|
|
|
|
|
else
|
|
|
|
|
f__error "$compteur commande$pluriel manquante$pluriel: $STD$BOLD$dependsMissing";
|
|
|
|
|
fi
|
2017-08-30 22:46:26 +02:00
|
|
|
|
fi
|
|
|
|
|
}
|
2017-07-30 17:08:05 +02:00
|
|
|
|
|
2017-10-17 18:33:12 +02:00
|
|
|
|
# $1=rep à scanner [$2=profondeur max|4 défaut] [$3=profondeur encours|0 défaut]
|
|
|
|
|
# affichage stdout si $fileOutput non définis, /usr/bin/strings (binutils) requis
|
|
|
|
|
f__scandir(){ # 17/10/2017
|
2017-10-16 07:10:04 +02:00
|
|
|
|
[ -d "$1" ] || f__error "erreur sur le répertoire à scanner"
|
|
|
|
|
f__requis "strings>binutils" # requis pour fonctionnement programme
|
|
|
|
|
local repToScan irep rc text prof prof_max tempo
|
|
|
|
|
[ "${1: -1}" == "/" ] && repToScan="$1" || repToScan="$1/" # ajout / final si besoin
|
|
|
|
|
[ "$2" ] && prof_max="$2" || prof_max=4 # profondeur max par défaut si besoin
|
|
|
|
|
[ "$3" ] && prof=$3 || prof=0 # initialisation compteur profondeur en cours si nécessaire (début)
|
|
|
|
|
text="répertoire: $repToScan \n"
|
|
|
|
|
for irep in $(ls $repToScan); do # contenu du répertoire
|
|
|
|
|
prof=$(( $prof+1 )) # niveau++
|
|
|
|
|
if [ -d "$repToScan$irep" ]; then # si c'est un répertoire
|
|
|
|
|
# si compteur niveau <= max, scandir, sinon suivant dans la boucle
|
|
|
|
|
[ "$prof" -le "$prof_max" ] && f__scandir "$repToScan$irep/" "$prof_max" "$prof" || continue
|
|
|
|
|
else # si c'est pas un répertoire
|
|
|
|
|
if [ ! -r "$repToScan$irep" ]; then # si fichier non lisible (read)
|
|
|
|
|
text+="$repToScan$irep : inaccessible en lecture \n"
|
|
|
|
|
continue # suivant dans la boucle
|
|
|
|
|
fi
|
|
|
|
|
# traitements fichier
|
|
|
|
|
[[ "$irep" == "uevent" || "$irep" == "modalias" ]] && rc=" \n" || unset rc
|
|
|
|
|
tempo="$(strings -aw -n1 $repToScan$irep)" # au moins 1 caractère, inclus white space, all tout le fichier
|
|
|
|
|
[ "$tempo" ] && text+="$irep: $rc$tempo \n" || text+="$irep: <vide> \n"
|
2017-10-13 21:58:51 +02:00
|
|
|
|
fi
|
2017-10-16 07:10:04 +02:00
|
|
|
|
prof=$(( prof-1 )) # niveau--
|
2017-10-13 21:58:51 +02:00
|
|
|
|
done
|
2017-10-16 07:10:04 +02:00
|
|
|
|
[ "$fileOutput" ] && echo -e "$text" >> "$fileOutput" # sauvegarde dans fichier si $fileOutput défini
|
|
|
|
|
[ "$fileOutput" ] || echo -e "$text" # affichage si $fileOutput non défini
|
2017-10-13 21:58:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-19 08:57:57 +02:00
|
|
|
|
# $1=cmd si $2: nb de tentatives pour s'identifier, sinon 2 tentatives par défaut
|
2017-10-22 11:14:21 +02:00
|
|
|
|
f__sudo(){ # 22/10/2017
|
2017-10-19 08:57:57 +02:00
|
|
|
|
local nb=2 sudo isudo
|
2017-10-09 20:19:07 +02:00
|
|
|
|
# sudo --shell bash équivalent su ?
|
|
|
|
|
if sudo -v &>/dev/null && [ $EUID -ne 0 ] ; then
|
2017-10-22 11:14:21 +02:00
|
|
|
|
sudo="sudo su --shell $(f__cmd_exist bash) --preserve-environment -c "
|
2017-10-09 20:19:07 +02:00
|
|
|
|
else
|
2017-10-22 11:14:21 +02:00
|
|
|
|
sudo="su --shell $(f__cmd_exist bash) --preserve-environment -c "
|
2017-10-09 20:19:07 +02:00
|
|
|
|
fi
|
|
|
|
|
[ "$2" ] && nb="$2"
|
|
|
|
|
for (( isudo=1 ; isudo<="$nb" ; isudo++ )); do
|
|
|
|
|
$sudo " $1"
|
|
|
|
|
[ "$?" == 0 ] && break
|
|
|
|
|
[ "$isudo" == "$nb" ] && return 1
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-21 19:07:08 +02:00
|
|
|
|
# user ayant initié la session graphique, assigne $user_
|
|
|
|
|
# return 1 sur échec identification user, return 2 sur absence home/
|
2017-08-17 10:49:12 +02:00
|
|
|
|
# gestion variable environnement user avec: USER_INSTALL=user script
|
2017-10-09 20:19:07 +02:00
|
|
|
|
f__user(){ # 09/10/2017
|
|
|
|
|
local user_id test root_login
|
|
|
|
|
root_login="$(grep ':0:' /etc/passwd | cut -d':' -f1)" || root_login="root"
|
2017-08-21 19:07:08 +02:00
|
|
|
|
if [ "$USER_INSTALL" ]; then # user_ via variable environnement, moyen d'injecter root
|
|
|
|
|
user_="$USER_INSTALL";
|
|
|
|
|
return 0
|
2017-10-09 20:19:07 +02:00
|
|
|
|
elif [[ "$TERM" =~ linux ]]; then #debian 9 recovery ou nomodeset TERM=linux
|
2017-10-02 15:34:29 +02:00
|
|
|
|
if [ "$USER" ]; then
|
|
|
|
|
user_="$USER"
|
|
|
|
|
elif [ "$EUID" -eq 0 ]; then
|
2017-10-09 20:19:07 +02:00
|
|
|
|
user_="$root_login"
|
2017-10-02 15:34:29 +02:00
|
|
|
|
return 0
|
|
|
|
|
fi
|
2017-08-17 10:49:12 +02:00
|
|
|
|
fi
|
2017-08-21 19:07:08 +02:00
|
|
|
|
if [ "$SUDO_UID" ]; then
|
|
|
|
|
user_id="$SUDO_UID";
|
|
|
|
|
elif grep -qEo '[0-9]+' <<< "$XDG_RUNTIME_DIR" ; then
|
|
|
|
|
user_id="$(grep -Eo '[0-9]+' <<< $XDG_RUNTIME_DIR | cut -d'/' -f4)"
|
|
|
|
|
elif grep -qEo '[0-9]+' <<< "$XAUTHORITY" ; then
|
|
|
|
|
user_id="$(grep -Eo '[0-9]+' <<< $XAUTHORITY | cut -d'/' -f4)"
|
2017-08-17 10:49:12 +02:00
|
|
|
|
fi
|
2017-08-21 19:07:08 +02:00
|
|
|
|
[ "$user_id" ] && user_="$(grep $user_id /etc/passwd | cut -d ":" -f 1 )"
|
|
|
|
|
if [ "$user_" ] && [ "$user_" != "$root_login" ]; then
|
|
|
|
|
return 0
|
|
|
|
|
else
|
|
|
|
|
if [ "$SUDO_USER" ] && [ "$SUDO_USER" != "$root_login" ]; then
|
|
|
|
|
user_="$SUDO_USER";
|
|
|
|
|
elif grep -qv 'root' <<< "$(who)"; then
|
2017-10-09 20:19:07 +02:00
|
|
|
|
user_="$(grep -v 'root' <<< $(who) | head -n1 | cut -d ' ' -f1)"; # grep -v 'root' <<< $(who) | gawk 'FNR==1{print $1}'
|
2017-08-21 19:07:08 +02:00
|
|
|
|
elif grep -q 'hourly.*get[A-Z].*\.anacrontab.*\.config/anacron/spool' /etc/crontab; then
|
2017-10-09 20:19:07 +02:00
|
|
|
|
user_="$(grep 'hourly.*get[A-Z].*\.anacrontab.*\.config/anacron/spool' /etc/crontab | head -n1 | cut -d' ' -f2)"; # grep 'hourly.*get[A-Z].*\.anacrontab.*\.config/anacron/spool' /etc/crontab | gawk 'FNR==1{print $2}
|
2017-08-21 19:07:08 +02:00
|
|
|
|
fi
|
2017-08-03 02:44:53 +02:00
|
|
|
|
fi
|
2017-08-21 19:07:08 +02:00
|
|
|
|
if [ -z "$user_" ]; then return 1; fi
|
|
|
|
|
if [ ! -d "/home/$user_" ]; then return 2; fi
|
|
|
|
|
return 0
|
2017-08-02 05:30:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 12:12:03 +01:00
|
|
|
|
# $1='-l' comptage ligne dans variable $2, affiche quantité
|
|
|
|
|
# $1='-w' comptage mots dans variable $2, affiche quantité
|
2017-10-31 06:52:36 +01:00
|
|
|
|
# f__wcv -l $var ; f__wcv -w $var "mot"
|
|
|
|
|
f__wcv(){ # 30/10/2017
|
|
|
|
|
[[ "$1" =~ -l|-w ]] || display="erreur f__wcv \$1 ($1) incorrect \n"
|
|
|
|
|
[ "$1" == "-l" ] && echo "$2" | grep -cEv '^[[:space:]]*$' # (wc -l compterait 1 pour une variable vide)
|
|
|
|
|
[ "$1" == "-w" ] && echo "$2" | grep -o "$3" | grep -c .
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-25 23:38:39 +02:00
|
|
|
|
# test wget, $1 url à tester, sortie du script si $1 seul (même si url testée ok)
|
2017-08-28 10:09:47 +02:00
|
|
|
|
# si $2=print affiche url testée & entêtes http & location (si présente) et sortie normale fonction
|
2017-09-25 23:38:39 +02:00
|
|
|
|
# si $2=loc affiche seulement location et sortie normale fonction
|
|
|
|
|
# si $2=test return 0 si ok, return 1 si ko
|
2017-10-17 18:33:12 +02:00
|
|
|
|
f__wget_test(){ # 17/10/2017
|
2017-08-30 22:46:26 +02:00
|
|
|
|
local file_test_wget retourWget retourHttp location
|
2017-09-28 20:47:34 +02:00
|
|
|
|
file_test_wget="/tmp/testWget-$$-$RANDOM"
|
2017-10-17 18:33:12 +02:00
|
|
|
|
wget -Sq --timeout=10 --user-agent="$user_agent" --spider --save-headers "$1" &>"$file_test_wget"
|
2017-09-29 20:27:53 +02:00
|
|
|
|
retourWget="$?"
|
|
|
|
|
[ "$2" == "test" ] && rm "$file_test_wget"
|
|
|
|
|
[ "$2" == "test" ] && [ "$retourWget" == "0" ] && return 0 || return 1
|
2017-08-26 09:05:54 +02:00
|
|
|
|
[ "$retourWget" == 1 ] && retourWget="code erreur générique"
|
|
|
|
|
[ "$retourWget" == 2 ] && retourWget="parse erreur (ligne de commande?)"
|
|
|
|
|
[ "$retourWget" == 3 ] && retourWget="erreur Entrée/sortie fichier"
|
|
|
|
|
[ "$retourWget" == 4 ] && retourWget="défaut réseau"
|
|
|
|
|
[ "$retourWget" == 5 ] && retourWget="défaut vérification SSL"
|
|
|
|
|
[ "$retourWget" == 6 ] && retourWget="défaut authentification"
|
|
|
|
|
[ "$retourWget" == 7 ] && retourWget="erreur de protocole"
|
|
|
|
|
[ "$retourWget" == 8 ] && retourWget="réponse serveur en erreur"
|
2017-08-30 22:46:26 +02:00
|
|
|
|
retourHttp="$(grep -i 'HTTP/' "$file_test_wget" | tr -d '\n' | xargs)"
|
|
|
|
|
location="$(grep -i 'location' $file_test_wget | xargs)"
|
2017-09-09 20:26:43 +02:00
|
|
|
|
if [ "$2" == "print" ]; then
|
|
|
|
|
if [ "$retourWget" ]; then
|
2017-10-09 20:19:07 +02:00
|
|
|
|
echo "erreur wget: $RED$retourWget"
|
|
|
|
|
echo -e "$BLUE $1$STD\t$RED $retourHttp"
|
2017-09-09 20:26:43 +02:00
|
|
|
|
else
|
2017-10-09 20:19:07 +02:00
|
|
|
|
echo -e "$BLUE $1$STD\t$GREEN $retourHttp"
|
2017-09-09 20:26:43 +02:00
|
|
|
|
fi
|
|
|
|
|
fi
|
2017-09-25 23:38:39 +02:00
|
|
|
|
if [ "$2" == "print" ] || [ "$2" == "loc" ]; then
|
|
|
|
|
[ "$location" ] && echo "$YELLOW $location" || echo "$YELLOW no location"
|
2017-10-09 20:19:07 +02:00
|
|
|
|
echo "$STD"
|
2017-09-25 23:38:39 +02:00
|
|
|
|
return 0
|
2017-08-28 10:09:47 +02:00
|
|
|
|
fi
|
|
|
|
|
if [ "$retourWget" ]; then
|
|
|
|
|
rm "$file_test_wget"
|
2017-10-16 07:10:04 +02:00
|
|
|
|
f__error "erreur wget, $retourWget" "$1" "$YELLOW$retourHttp"
|
2017-08-28 10:09:47 +02:00
|
|
|
|
fi
|
2017-09-25 23:38:39 +02:00
|
|
|
|
if [ "$(grep -c '200' <<< $retourHttp)" -ne 0 ]; then
|
2017-10-09 20:19:07 +02:00
|
|
|
|
echo -e "$GREEN\ntout est ok, réessayer\n$STD"
|
2017-09-25 23:38:39 +02:00
|
|
|
|
fi
|
2017-08-26 09:05:54 +02:00
|
|
|
|
rm "$file_test_wget"
|
2017-08-28 10:09:47 +02:00
|
|
|
|
exit 0
|
2017-08-07 21:58:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-30 10:50:22 +01:00
|
|
|
|
# f_display: $1 variable à afficher, $2=var|cmd|sans (type titre) [$3 titre] [$4 commentaire en gras si cmd]
|
2017-10-22 11:14:21 +02:00
|
|
|
|
# f_display "variable" "type" "titrage" "titrage_commentaire"
|
2017-10-30 10:50:22 +01:00
|
|
|
|
# $2: cmd->`titre`, var->**titre**, sans: pas de titre
|
2017-10-30 07:41:12 +01:00
|
|
|
|
f_display(){ # 30/10/2017
|
2017-10-30 10:50:22 +01:00
|
|
|
|
[ "$text" ] && echo -en "$text" >> "$fileOutput" # flush, avant fonction, de text parent
|
2017-10-21 11:07:11 +02:00
|
|
|
|
unset text
|
2017-10-25 10:03:56 +02:00
|
|
|
|
local display=""
|
2017-10-30 10:50:22 +01:00
|
|
|
|
[[ "$2" =~ sans|var|cmd ]] || display="erreur script \$2 ($1 $2 $3) \n"
|
|
|
|
|
[ "$2" == "var" ] && display="**$3** \n"
|
2017-10-25 10:03:56 +02:00
|
|
|
|
[ "$2" == "cmd" ] && display="\`$3\` \n"
|
2017-10-26 07:05:22 +02:00
|
|
|
|
#echo $(sed -En 's/[^/]*(\/.*)$/\1/p' <<< "$3")
|
2017-10-26 05:23:33 +02:00
|
|
|
|
[[ "$2" == "cmd" && "$4" ]] && display="\`$3\` **$4** \n"
|
2017-10-25 10:03:56 +02:00
|
|
|
|
display+='``` \n'
|
|
|
|
|
display+="${!1} \n"
|
|
|
|
|
display+='``` \n'
|
2017-10-26 00:40:16 +02:00
|
|
|
|
echo -en "$display \n" >> "$fileOutput" # flush fonction
|
2017-10-21 11:07:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-26 07:05:22 +02:00
|
|
|
|
# $1 fichier testé
|
|
|
|
|
f_display_file(){ # 26/10/2017
|
|
|
|
|
echo -e "* fichier **$1** non trouvé ou absent \n" >> "$fileOutput"
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-21 11:07:11 +02:00
|
|
|
|
# $1 répertoire à scanner, $2 profondeur
|
|
|
|
|
f_display_scandir(){ # 21/10/2017
|
|
|
|
|
[ "$text" ] && echo -e "$text" >> "$fileOutput" # flush avant fonction
|
|
|
|
|
unset text
|
|
|
|
|
local text
|
|
|
|
|
text="\`$1 $2\` \n"
|
|
|
|
|
text+='``` \n'
|
|
|
|
|
echo -e "$text" >> "$fileOutput" # flush avant scandir
|
|
|
|
|
unset text
|
|
|
|
|
if [ -d "$1" ]; then
|
|
|
|
|
f__scandir $1 $2
|
|
|
|
|
else
|
|
|
|
|
text="$1 inexistant \n"
|
|
|
|
|
fi
|
|
|
|
|
text+='``` \n'
|
|
|
|
|
echo -e "$text" >> "$fileOutput" # flush fonction
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-28 08:38:36 +02:00
|
|
|
|
f_help(){ # 28/10/2017
|
2017-08-30 01:04:45 +02:00
|
|
|
|
printf "$BLUE"
|
|
|
|
|
cat << 'EOF'
|
2017-10-11 02:06:15 +02:00
|
|
|
|
./getInfo : exécution normale, rapport markdown de la configuration
|
2017-08-30 01:04:45 +02:00
|
|
|
|
getInfo : exécution normale si script installé dans le système
|
|
|
|
|
|
|
|
|
|
options:
|
2017-10-11 02:06:15 +02:00
|
|
|
|
-c : (catégorie) menu sélection catégorie d'analyse
|
2017-10-19 08:57:57 +02:00
|
|
|
|
-cs : catégorie système -cs : catégorie configuration
|
|
|
|
|
-cr : catégorie réseau -ca : catégorie analyse
|
2017-10-09 20:19:07 +02:00
|
|
|
|
-h : (help) affichage aide
|
2017-10-19 08:57:57 +02:00
|
|
|
|
-j : (journaux) analyse démarrage système, log Xorg, kernel et système, catégorie -ca
|
2017-10-09 20:19:07 +02:00
|
|
|
|
-l : (list) afficher le rapport markdown existant
|
2017-10-11 02:06:15 +02:00
|
|
|
|
-p : (paste) exporte le rapport markdown existant, durée standard du paste 7 jours
|
2017-10-27 15:30:24 +02:00
|
|
|
|
-tn : durée du paste de n jour(s)
|
|
|
|
|
-us : upgrade spécial du script (pas de mise à jour auto, maj du script en place)
|
2017-10-30 07:41:12 +01:00
|
|
|
|
|
2017-10-19 08:57:57 +02:00
|
|
|
|
--ip : affiche ip publique (ipv4/ipv6), infos confidentielles, pas de rapport markdown
|
2017-10-11 02:06:15 +02:00
|
|
|
|
--mac : affiche les adresses Mac, infos confidentielles, pas de rapport markdown
|
|
|
|
|
--ssid : affiche configurations ssid, infos confidentielles, pas de rapport markdown,
|
|
|
|
|
root et NetworkManager requis
|
|
|
|
|
|
|
|
|
|
-i, --install : installation du script dans le système, root requis
|
|
|
|
|
-r, --remove : suppression du script dans le système, root requis
|
2017-10-28 08:38:36 +02:00
|
|
|
|
-u, --upgrade : upgrade script installé si maj possible
|
2017-08-30 01:04:45 +02:00
|
|
|
|
-v, --version : version du script, en ligne et en cours d'exécution
|
|
|
|
|
EOF
|
2017-10-11 02:08:00 +02:00
|
|
|
|
echo -e "$STD\n plus d'infos: $GREEN$urlNotice\n$STD"
|
2017-08-30 01:04:45 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-25 10:03:56 +02:00
|
|
|
|
fi_batt(){ # 25/10/2017
|
2017-10-22 11:14:21 +02:00
|
|
|
|
local pluriel
|
2017-10-27 14:59:30 +02:00
|
|
|
|
[ "$fg_nb_batt" ] || figet_batt # appel figet_battery si pas déjà fait par fi_systeme
|
|
|
|
|
[[ "$fg_nb_batt" == "-1" || "$fg_nb_batt" -gt 0 ]] || return 0 # pas de batterie
|
2017-10-25 05:21:16 +02:00
|
|
|
|
###
|
2017-10-27 14:59:30 +02:00
|
|
|
|
[ "$fg_nb_batt" -gt 1 ] && pluriel="s" || unset pluriel
|
2017-10-22 11:14:21 +02:00
|
|
|
|
text="## batterie$pluriel \n\n"
|
2017-10-27 14:59:30 +02:00
|
|
|
|
f_display "fg_batt" "sans"
|
2017-10-25 10:03:56 +02:00
|
|
|
|
printf "$text\n" >> "$fileOutput"
|
|
|
|
|
unset text
|
2017-09-28 20:47:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-01 12:55:53 +01:00
|
|
|
|
fi_cpu(){ # 01/11/2017
|
2017-10-22 06:45:56 +02:00
|
|
|
|
#manuellement: lscpu (util-linux)
|
2017-10-22 11:14:21 +02:00
|
|
|
|
local cpu_flags text pluriel
|
2017-09-29 20:27:53 +02:00
|
|
|
|
cpu_flags="$(sed -n 's/^flags.*: \(.*\)$/\1/p;' /proc/cpuinfo | sed -n '1p')"
|
2017-10-31 09:10:14 +01:00
|
|
|
|
[ "$fg_cpu" ] || figet_cpu
|
2017-08-26 09:05:54 +02:00
|
|
|
|
###
|
2017-10-31 09:10:14 +01:00
|
|
|
|
[ ${fg_cpu:0:1} -gt 1 ] && pluriel="s" || unset pluriel
|
2017-10-22 11:14:21 +02:00
|
|
|
|
text="## processeur$pluriel \n\n"
|
2017-10-31 09:10:14 +01:00
|
|
|
|
f_display "fg_cpu" "sans"
|
2017-11-02 08:40:41 +01:00
|
|
|
|
[ "$fg_uarch" ] && f_display "fg_uarch" "var" "codename processeur"
|
2017-10-22 06:45:56 +02:00
|
|
|
|
f_display "cpu_flags" "var" "flags cpu:"
|
2017-10-25 10:03:56 +02:00
|
|
|
|
printf "$text\n" >> "$fileOutput"
|
|
|
|
|
unset text
|
2017-10-04 10:29:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-01 07:45:18 +01:00
|
|
|
|
fi_disk(){ # 31/10/2017
|
2017-10-17 18:33:12 +02:00
|
|
|
|
local disk_lsblk disk_df disk_df_i fstab resume idResume idSwap alert_uuidResume text pluriel
|
2017-10-22 11:14:21 +02:00
|
|
|
|
local dd_temp dd_temp_alert dd_temp idisk tempodd
|
2017-10-09 20:19:07 +02:00
|
|
|
|
disk_lsblk="$(lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID)"
|
|
|
|
|
disk_df="$(df -h --output=source,target,fstype,size,used,avail,pcent --exclude=tmpfs --exclude=devtmpfs | grep -Ev 'devpts|none|proc|sys|tmpfs|udev')"
|
|
|
|
|
disk_df_i="$(df -i --exclude=tmpfs --exclude=devtmpfs | grep -Ev 'devpts|none|proc|sys|tmpfs|udev')"
|
2017-10-31 06:52:36 +01:00
|
|
|
|
fstab="$(grep -Ev '^[[:blank:]]*#|^[[:space:]]*$' /etc/fstab)"
|
|
|
|
|
resume="$(grep -Evs '^[[:blank:]]*#|^[[:space:]]*$' /etc/initramfs-tools/conf.d/resume)"
|
2017-10-12 08:45:16 +02:00
|
|
|
|
if [ -z "$resume" ]; then
|
2017-10-21 11:07:11 +02:00
|
|
|
|
# alert resume absent
|
2017-10-28 19:59:06 +02:00
|
|
|
|
resume="Pas de fichier _resume_ dans /etc/initramfs-tools/conf.d/ \n"
|
2017-10-28 23:42:15 +02:00
|
|
|
|
resume+="Ce n'est pas (forcément) une erreur. \n"
|
|
|
|
|
resume+="La plus grosse partition swap est choisie dans ce cas. \n"
|
2017-10-30 10:50:22 +01:00
|
|
|
|
resume+="À investiguer si erreur au boot ou boot très long. "
|
2017-10-12 08:45:16 +02:00
|
|
|
|
fi
|
|
|
|
|
idResume="$(grep -Evs '^[[:blank:]]*#|^$' /etc/initramfs-tools/conf.d/resume | sed -En 's/.*UUID=([0-9a-Z-]*).*$/\1/p')"
|
2017-10-02 15:34:29 +02:00
|
|
|
|
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-09-27 20:40:28 +02:00
|
|
|
|
alert_uuidResume+="id swap : $idSwap \nid resume: $idResume\n"
|
2017-10-02 15:34:29 +02:00
|
|
|
|
alert_uuidResume+="**vérifier la config resume**, l'UUID ne correspond pas à celui du swap. \n"
|
|
|
|
|
alert_uuidResume+="vous pouvez utiliser _RESUME=auto_ ou _RESUME=/dev/sdx_, voir supprimer ce fichier"
|
2017-09-16 14:25:36 +02:00
|
|
|
|
fi
|
2017-10-29 07:39:51 +01:00
|
|
|
|
[ "$fg_nb_disk" ] || figet_disk # appel figet_disk si pas déjà fait par fi_systeme
|
2017-10-22 11:14:21 +02:00
|
|
|
|
if [ "$(f__cmd_exist hddtemp)" ]; then
|
2017-10-17 18:33:12 +02:00
|
|
|
|
unset dd_temp dd_temp_alert
|
2017-10-29 07:39:51 +01:00
|
|
|
|
for idisk in $fg_disk_fixe; do
|
2017-10-17 23:36:01 +02:00
|
|
|
|
[ -r "/dev/$idisk" ] || continue
|
2017-10-17 23:16:43 +02:00
|
|
|
|
tempodd="$(LC_ALL=C hddtemp /dev/$idisk | cut -d ':' -f3 | sed 's/[^0-9]*//g; /not available/d')"
|
2017-10-26 00:40:16 +02:00
|
|
|
|
dd_temp+="$idisk: $tempodd °C"$'\n'
|
|
|
|
|
[ "$tempodd" -ge 50 ] && dd_temp_alert+="/!\ $idisk: température > 50°C) "$'\n'
|
2017-10-17 18:33:12 +02:00
|
|
|
|
done
|
2017-11-01 07:45:18 +01:00
|
|
|
|
[ "$dd_temp" ] && dd_temp=${dd_temp::-1} # suppression dernier $'\n'
|
|
|
|
|
[ "$dd_temp_alert" ] && dd_temp_alert=${dd_temp_alert::-1} # suppression dernier $'\n'
|
2017-10-17 18:33:12 +02:00
|
|
|
|
fi
|
2017-08-26 09:05:54 +02:00
|
|
|
|
###
|
2017-10-29 07:39:51 +01:00
|
|
|
|
[ "$fg_nb_disk" -gt 1 ] && pluriel="s" || unset pluriel
|
2017-10-22 11:14:21 +02:00
|
|
|
|
text="## disque$pluriel \n\n"
|
2017-10-17 22:02:16 +02:00
|
|
|
|
text+='``` \n'
|
2017-10-19 09:45:17 +02:00
|
|
|
|
# espace des partitions fixes montées
|
2017-10-29 07:39:51 +01:00
|
|
|
|
text+="$fg_disk_part_fix_tot \n\n"
|
2017-10-19 09:45:17 +02:00
|
|
|
|
# disques fixes et amovibles
|
2017-10-29 07:39:51 +01:00
|
|
|
|
[ "$(wc -w <<< $fg_disk_fixe)" -gt 1 ] && pluriel="s" || unset pluriel
|
|
|
|
|
text+="$(printf '%-17s: %s' "disque$pluriel fixe$pluriel" "$fg_disk_fixe") \n"
|
|
|
|
|
[ "$(wc -w <<< $fg_disk_amov)" -gt 1 ] && pluriel="s" || unset pluriel
|
|
|
|
|
text+="$(printf '%-17s: %s' "disque$pluriel amovible$pluriel" "$fg_disk_amov") \n\n"
|
2017-10-20 03:10:56 +02:00
|
|
|
|
# partitions fixes montées / swap / non montées
|
2017-10-29 07:39:51 +01:00
|
|
|
|
[ "$(wc -w <<< $fg_disk_part_fixe_m)" -gt 1 ] && pluriel="s" || unset pluriel
|
|
|
|
|
text+="$(printf '%-24s: %s' "partition$pluriel fixe$pluriel montée$pluriel" "$fg_disk_part_fixe_m") \n"
|
|
|
|
|
[ "$(wc -w <<< $fg_disk_part_swap)" -gt 1 ] && pluriel="s" || unset pluriel
|
|
|
|
|
text+="$(printf '%-24s: %s' "partition$pluriel swap$pluriel" "$fg_disk_part_swap") \n"
|
|
|
|
|
[ "$(wc -w <<< $fg_disk_part_fixe_nm)" -gt 1 ] && pluriel="s" || unset pluriel
|
|
|
|
|
text+="$(printf '%-28s: %s' "partition$pluriel fixe$pluriel non montée$pluriel" "$fg_disk_part_fixe_nm") \n\n"
|
2017-10-19 09:45:17 +02:00
|
|
|
|
# partitions amovibles montées / non montées
|
2017-10-29 07:39:51 +01:00
|
|
|
|
[ "$(wc -w <<< $fg_disk_part_amov_m)" -gt 1 ] && pluriel="s" || unset pluriel
|
|
|
|
|
text+="$(printf '%-32s: %s' "partition$pluriel amovible$pluriel montée$pluriel" "$fg_disk_part_amov_m") \n"
|
|
|
|
|
[ "$(wc -w <<< $fg_disk_part_amov_nm)" -gt 1 ] && pluriel="s" || unset pluriel
|
|
|
|
|
text+="$(printf '%-32s: %s' "partition$pluriel amovible$pluriel non montée$pluriel" "$fg_disk_part_amov_nm") \n\n"
|
2017-10-31 06:52:36 +01:00
|
|
|
|
# détails des disques par type
|
2017-10-29 07:39:51 +01:00
|
|
|
|
text+="$fg_disk_table \n"
|
2017-10-17 22:02:16 +02:00
|
|
|
|
text+='``` \n\n'
|
|
|
|
|
text+="**types de disque** \n\n"
|
2017-10-25 10:03:56 +02:00
|
|
|
|
text+="| sata | usb | mmc | nvme | \n"
|
2017-10-17 22:02:16 +02:00
|
|
|
|
text+="| :---: | :---: | :---: | :---: | \n"
|
2017-10-29 07:39:51 +01:00
|
|
|
|
text+="| $fg_disk_ata | $fg_disk_usb | $fg_disk_mmc | $fg_disk_nvme | \n\n"
|
2017-10-17 22:02:16 +02:00
|
|
|
|
# éventuellement hddtemp
|
2017-10-21 11:32:30 +02:00
|
|
|
|
[ "$dd_temp" ] && f_display "dd_temp" "cmd" "hddtemp /dev/sd?" "(température disques)"
|
2017-10-17 22:02:16 +02:00
|
|
|
|
if [ "$dd_temp_alert" ]; then
|
|
|
|
|
text+="$dd_temp_alert \n"
|
2017-10-21 11:07:11 +02:00
|
|
|
|
text+="$dd_temp_alert_text \n\n"
|
2017-10-17 22:02:16 +02:00
|
|
|
|
fi
|
2017-09-27 20:40:28 +02:00
|
|
|
|
# df, espaces des partitions montées seules
|
2017-10-21 11:07:11 +02:00
|
|
|
|
f_display "disk_df" "cmd" \
|
|
|
|
|
"df -h --output=source,target,fstype,size,used,avail,pcent --exclude=tmpfs --exclude=devtmpfs" \
|
|
|
|
|
"(utilisation disques)"
|
2017-10-31 06:52:36 +01:00
|
|
|
|
# df -i, inoeuds
|
2017-10-21 11:07:11 +02:00
|
|
|
|
f_display "disk_df_i" "cmd" "df -i --exclude=tmpfs --exclude=devtmpfs" "(utilisation inoeuds)"
|
|
|
|
|
# lsblk
|
2017-10-31 06:52:36 +01:00
|
|
|
|
[ "$disk_lsblk" ] && f_display "disk_lsblk" "cmd" "lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID" "(disques)"
|
2017-10-21 11:07:11 +02:00
|
|
|
|
# fstab
|
2017-10-31 06:52:36 +01:00
|
|
|
|
f_display "fstab" "cmd" "grep -Ev '^[[:blank:]]*#|^[[:space:]]*$' /etc/fstab" "(fstab)"
|
2017-10-21 11:07:11 +02:00
|
|
|
|
# resume
|
2017-10-31 06:52:36 +01:00
|
|
|
|
f_display "resume" "cmd" "grep -Evs '^[[:blank:]]*#|^[[:space:]]*$' /etc/initramfs-tools/conf.d/resume" "(resume)"
|
2017-09-27 20:40:28 +02:00
|
|
|
|
if [ "$alert_uuidResume" ]; then
|
2017-10-17 22:02:16 +02:00
|
|
|
|
text+="$alert_uuidResume \n\n"
|
2017-09-27 20:40:28 +02:00
|
|
|
|
fi
|
2017-10-25 10:03:56 +02:00
|
|
|
|
printf "$text\n" >> "$fileOutput"
|
|
|
|
|
unset text
|
2017-08-02 05:30:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 06:52:36 +01:00
|
|
|
|
fi_dmesg(){ # 30/10/2017
|
2017-10-19 08:57:57 +02:00
|
|
|
|
local dmesg_err dmesg_warn dmesg_crit file text nb_lignes=25
|
2017-10-09 20:19:07 +02:00
|
|
|
|
file="/tmp/$$-$RANDOM-dmesg"
|
|
|
|
|
[ "$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 ; \
|
|
|
|
|
dmesg -Hk --nopager -l warn > $file-err ; \
|
|
|
|
|
dmesg -Hk --nopager -l warn > $file-warn ; \
|
2017-10-09 20:19:07 +02:00
|
|
|
|
chown $user_: $file-*"
|
|
|
|
|
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-10-19 08:57:57 +02:00
|
|
|
|
"ou juste la partie journaux avec $GREEN./getInfo -j$BLUE ou$GREEN getInfo -j$BLUE (script installé)"
|
2017-10-31 06:52:36 +01:00
|
|
|
|
text+="* les commandes \`dmesg\` ont échoué, relancer avec les droits root \n\n"
|
2017-10-09 20:19:07 +02:00
|
|
|
|
echo -e "$text" >> "$fileOutput"
|
|
|
|
|
return 0
|
2017-08-26 09:05:54 +02:00
|
|
|
|
fi
|
2017-10-19 08:57:57 +02: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-10-11 02:06:15 +02:00
|
|
|
|
rm "$file-"*
|
2017-08-26 09:05:54 +02:00
|
|
|
|
###
|
2017-10-19 08:57:57 +02:00
|
|
|
|
text="## dmesg kernel (emergency, alerte, erreur, warning ou critique) \n\n"
|
2017-10-22 11:14:21 +02:00
|
|
|
|
f_display "dmesg_emerg" "cmd" "dmesg -l emerg" "(emergency, $nb_lignes premières lignes)"
|
|
|
|
|
f_display "dmesg_alert" "cmd" "dmesg -l alert" "(alerte, $nb_lignes premières lignes)"
|
|
|
|
|
f_display "dmesg_crit" "cmd" "dmesg -l crit" "(critique, $nb_lignes premières lignes)"
|
|
|
|
|
f_display "dmesg_err" "cmd" "dmesg -l err" "(erreur, $nb_lignes premières lignes)"
|
|
|
|
|
f_display "dmesg_warn" "cmd" "dmesg -l warn" "(warning, $nb_lignes premières lignes)"
|
2017-10-20 00:50:21 +02:00
|
|
|
|
text+="**les $nb_lignes premières lignes commencent à la date la plus ancienne encore dans les logs kernel** \n\n"
|
2017-10-25 10:03:56 +02:00
|
|
|
|
printf "$text\n" >> "$fileOutput"
|
|
|
|
|
unset text
|
2017-08-03 02:44:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-01 07:45:18 +01:00
|
|
|
|
fi_graph(){ # 31/10/2017
|
|
|
|
|
local slots cmd alert_hybrid alert_3D providers preferred current openGl resolutions text
|
|
|
|
|
local ig modules glx_dev glx_temp cards="fg_gpu"
|
2017-10-27 06:32:50 +02:00
|
|
|
|
# cardsManuel="$(lspci -nnk | grep -EiA 3 'vga|display|3d')" # -nn: textual and numeric ID's, k kernel
|
2017-10-28 22:20:50 +02:00
|
|
|
|
# cardsManuel="$(lspci -nnv | grep -iEA11 'vga|display|3d)" # v=verbose
|
2017-10-27 14:59:30 +02:00
|
|
|
|
# cardsManuel="lspci -nnv -s $( lspci | grep -Ei 'vga|display|3d' | cut -d" " -f1 )" si plusieurs devices possibles??
|
2017-11-01 07:45:18 +01:00
|
|
|
|
|
|
|
|
|
[ "$fg_nb_gpu" ] || figet_gpu # peut retourner "n/a"/-1
|
2017-10-30 07:41:12 +01:00
|
|
|
|
# slots pci video
|
2017-10-27 06:32:50 +02:00
|
|
|
|
slots="$(lspci | grep -Ei 'vga|display|3d' | cut -d" " -f1)"
|
2017-11-01 07:45:18 +01:00
|
|
|
|
# lspci
|
|
|
|
|
if [ "$fg_nb_gpu" -eq 0 ]; then
|
|
|
|
|
cards="pas de carte graphique"$'\n'
|
|
|
|
|
elif [ "$fg_nb_gpu" -gt 1 ]; then
|
2017-10-30 07:41:12 +01:00
|
|
|
|
if [ $(f__cmd_exist optirun) ]; then
|
2017-10-30 10:50:22 +01:00
|
|
|
|
for ig in $slots; do
|
|
|
|
|
cards+="$(optirun lspci -nnv -s $ig)"$'\n'
|
|
|
|
|
done
|
|
|
|
|
cmd="optirun lspci -nnv | grep -iEA11 'vga|display|3d'" # commande à afficher dans le rapport
|
2017-10-30 07:41:12 +01:00
|
|
|
|
else
|
2017-10-30 10:50:22 +01:00
|
|
|
|
for ig in $slots; do
|
|
|
|
|
cards+="$(DRI_PRIME=1 lspci -nnv -s $ig)"$'\n'
|
|
|
|
|
done
|
|
|
|
|
cmd="DRI_PRIME=1 lspci -nnv | grep -iEA11 'vga|display|3d'" # commande à afficher dans le rapport
|
2017-10-30 07:41:12 +01:00
|
|
|
|
fi
|
2017-10-30 10:50:22 +01:00
|
|
|
|
else
|
|
|
|
|
for ig in $slots; do
|
|
|
|
|
cards+="$(lspci -nnv -s $ig)"$'\n'
|
|
|
|
|
done
|
|
|
|
|
cmd="lspci -nnv | grep -iEA11 'vga|display|3d'" # commande à afficher dans le rapport
|
2017-10-25 23:45:00 +02:00
|
|
|
|
fi
|
2017-11-01 07:45:18 +01:00
|
|
|
|
[ "$cards" ] && cards=${cards::-1} # suppression dernier $'\n'
|
|
|
|
|
[ "$cards" ] || cards="lspci -nnv non disponible"
|
2017-10-27 06:32:50 +02:00
|
|
|
|
if [ $(grep -c 'Unknown header type 7f' <<< "$cards") -gt 0 ]; then
|
|
|
|
|
alert_hybrid="Une carte graphique est désactivée actuellement, lspci n'est pas complet. \n"
|
|
|
|
|
alert_hybrid+="Voir DRI_PRIME, vga-switcheroo, Bumbledee...? \n"
|
2017-10-26 13:19:56 +02:00
|
|
|
|
fi
|
2017-10-30 07:41:12 +01:00
|
|
|
|
# openGl / glxinfo
|
2017-10-26 13:19:56 +02:00
|
|
|
|
if [ $(f__cmd_exist glxinfo) ]; then
|
2017-10-30 07:41:12 +01:00
|
|
|
|
# devices
|
|
|
|
|
glx_dev="$(glxinfo | grep 'Device: ' | xargs)"
|
2017-10-31 12:12:03 +01:00
|
|
|
|
if [ "$fg_nb_gpu" -gt 1 ]; then
|
2017-10-30 07:41:12 +01:00
|
|
|
|
glx_temp="$(DRI_PRIME=1 glxinfo | grep 'Device: ' | xargs)"
|
|
|
|
|
[ $(f__cmd_exist optirun) ] && glx_temp="$(optirun glxinfo | grep 'Device: ' | xargs)"
|
|
|
|
|
[ "$glx_dev" != "$glx_temp" ] && glx_dev="$glx_dev"$'\n'"$glx_temp"
|
|
|
|
|
fi
|
2017-10-30 10:50:22 +01:00
|
|
|
|
openGl=$( glxinfo | grep -i 'direct rendering' ) # variable recyclée plus tard
|
2017-10-26 13:19:56 +02:00
|
|
|
|
alert_3D=$(grep -i 'no' <<< $openGl )
|
2017-10-30 07:41:12 +01:00
|
|
|
|
[ "$alert_3D" ] && alert_3D="l'accélération 3D n'est pas active \n\n"
|
|
|
|
|
glx_dev+="\n${openGl^}"
|
|
|
|
|
# openGL
|
|
|
|
|
openGl="$( glxinfo | grep 'OpenGL vendor' )"$'\n'
|
2017-10-27 14:59:30 +02:00
|
|
|
|
openGl+="$( glxinfo | grep 'OpenGL renderer' )"$'\n'
|
|
|
|
|
openGl+="$( glxinfo | grep 'OpenGL version' )"$'\n'
|
|
|
|
|
openGl+="$( glxinfo | grep 'OpenGL shading language version' )"$'\n'
|
|
|
|
|
openGl+="$( glxinfo | grep 'OpenGL extensions' )"$'\n'
|
|
|
|
|
openGl="$( sed 's/ string//g' <<< "$openGl" )"
|
2017-10-26 13:19:56 +02:00
|
|
|
|
fi
|
2017-10-27 06:32:50 +02:00
|
|
|
|
# xrandr: résolutions & providers & preferred & current
|
2017-10-27 14:59:30 +02:00
|
|
|
|
[ $(f__cmd_exist xrandr) ] && resolutions="$( xrandr --query | grep -A11 'Screen [0-9]' )"
|
|
|
|
|
[ $(f__cmd_exist xrandr) ] && providers="$( xrandr --listproviders )"
|
|
|
|
|
[ $(f__cmd_exist xrandr) ] && current="$( xrandr --verbose | grep -A2 '*current' )"
|
|
|
|
|
[ $(f__cmd_exist xrandr) ] && preferred="$( xrandr --verbose | grep -A2 '+preferred' )"
|
2017-10-26 01:21:24 +02:00
|
|
|
|
# modules
|
2017-10-27 14:59:30 +02:00
|
|
|
|
modules="$(lsmod | grep -Ei 'amdgpu|ati|i915|nouveau|nvidia|radeon|video|gma')"
|
2017-10-26 01:21:24 +02:00
|
|
|
|
# fonctions externes
|
2017-10-30 10:50:22 +01:00
|
|
|
|
[ "$fg_resolution" ] || figet_screen
|
2017-10-25 23:45:00 +02:00
|
|
|
|
###
|
2017-10-30 10:50:22 +01:00
|
|
|
|
[ "$fg_gpu" ] && text="## graphisme \n\n" || text="## graphisme (incomplet) \n\n"
|
2017-10-25 05:21:16 +02:00
|
|
|
|
# cartes graphiques
|
2017-10-30 07:41:12 +01:00
|
|
|
|
[ "$fg_gpu" ] && text+="$(sed -E 's/(.*)/> \* \*\*\1\*\*/' <<< $fg_gpu) \n\n"
|
2017-10-26 01:55:35 +02:00
|
|
|
|
# nb écran & résolution(s) active(s)
|
2017-10-30 10:50:22 +01:00
|
|
|
|
text+="nombre d'écrans: **$fg_nb_screen** \n"
|
|
|
|
|
text+="résolution: **$fg_resolution** \n\n"
|
2017-10-25 05:21:16 +02:00
|
|
|
|
# lspci
|
2017-10-30 07:41:12 +01:00
|
|
|
|
[ "$cards" ] && f_display "cards" "cmd" "$cmd"
|
2017-10-27 06:32:50 +02:00
|
|
|
|
[ "$alert_hybrid" ] && text+="$alert_hybrid \n\n"
|
2017-10-25 05:21:16 +02:00
|
|
|
|
# openGl
|
2017-10-31 06:52:36 +01:00
|
|
|
|
[ "$glx_dev" ] && f_display "glx_dev" "sans"
|
2017-10-30 07:41:12 +01:00
|
|
|
|
[ "$openGl" ] && f_display "openGl" "cmd" "glxinfo"
|
2017-10-26 13:19:56 +02:00
|
|
|
|
[ "$alert_3D" ] && text+="**$alert_3D** \n"
|
2017-10-27 06:32:50 +02:00
|
|
|
|
# liste providers, preferred, current,
|
|
|
|
|
[ "$current" ] && f_display "current" "cmd" "xrandr --verbose | grep -A2 '*current'"
|
|
|
|
|
[ "$preferred" ] && f_display "preferred" "cmd" "xrandr --verbose | grep -A2 '+preferred'"
|
|
|
|
|
[ "$providers" ] && f_display "providers" "cmd" "xrandr --listproviders"
|
2017-10-26 01:55:35 +02:00
|
|
|
|
# résolutions possibles, pas d'affichage si mode (ssh) ou xrandr pas accessible
|
2017-10-23 03:52:48 +02:00
|
|
|
|
if [ "$resolutions" ]; then
|
2017-10-26 05:23:33 +02:00
|
|
|
|
f_display "resolutions" "cmd" "xrandr --query | grep -A11 'Screen [0-9]'" "(10 premières résolutions possibles)"
|
2017-08-03 02:44:53 +02:00
|
|
|
|
fi
|
2017-10-25 05:21:16 +02:00
|
|
|
|
# modules vidéo
|
2017-10-22 06:45:56 +02:00
|
|
|
|
text+="### modules video \n\n"
|
2017-10-23 03:52:48 +02:00
|
|
|
|
if [ "$modules" ]; then
|
2017-10-25 23:45:00 +02:00
|
|
|
|
f_display "modules" "var" "modules recherchés: amdgpu, ati, i915, nouveau, nvidia, radeon, video, gma"
|
2017-10-23 03:52:48 +02:00
|
|
|
|
else
|
|
|
|
|
text+="Modules non reconnus. Il serait bien de communiquer le retour de \`lsmod\` pour mettre "
|
|
|
|
|
text+="à jour le script. Merci de contacter $projet: \n$contact "
|
|
|
|
|
fi
|
2017-10-25 10:03:56 +02:00
|
|
|
|
printf "$text\n" >> "$fileOutput"
|
|
|
|
|
unset text
|
2017-08-03 02:44:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-25 10:03:56 +02:00
|
|
|
|
fi_hw(){ # 25/10/2017
|
2017-10-12 21:49:57 +02:00
|
|
|
|
figet_hw
|
2017-10-23 03:52:48 +02:00
|
|
|
|
###
|
2017-10-25 05:21:16 +02:00
|
|
|
|
text="## hardware monitor ACPI \n\n"
|
2017-10-31 09:10:14 +01:00
|
|
|
|
if [ "$fg_hw" ]; then
|
|
|
|
|
f_display "fg_hw" "sans"
|
2017-10-25 05:21:16 +02:00
|
|
|
|
else
|
|
|
|
|
text+="**pas d'informations détectées** \n\n"
|
2017-10-23 03:52:48 +02:00
|
|
|
|
fi
|
2017-10-25 10:03:56 +02:00
|
|
|
|
printf "$text\n" >> "$fileOutput"
|
|
|
|
|
unset text
|
2017-10-12 21:49:57 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 06:52:36 +01:00
|
|
|
|
fi_journal(){ # 30/10/2017
|
2017-10-29 07:39:51 +01:00
|
|
|
|
local jctl_boot jctl_alert_k jctl_crit_k jctl_err_k jctl_warn_k jctl_warn_nok jctl_size file text nb_lignes=25
|
2017-10-22 11:14:21 +02:00
|
|
|
|
[ "$(f__cmd_exist journalctl)" ] || fi_dmesg # pas systemd, appel dmesg
|
2017-10-19 08:57:57 +02:00
|
|
|
|
file="/tmp/$$-$RANDOM-journalctl"
|
|
|
|
|
[ "$EUID" -eq 0 ] || echo
|
2017-10-25 05:21:16 +02:00
|
|
|
|
f__sudo "LC_ALL=C journalctl --no-hostname --boot 0 | sed -E -n '/^-- Logs begin.*$/p' > $file-boot ; \
|
|
|
|
|
LC_ALL=C journalctl --no-hostname --boot 0 -k -p 1 > $file-alert ; \
|
2017-10-19 08:57:57 +02:00
|
|
|
|
LC_ALL=C journalctl --no-hostname --boot 0 -k -p 2..2 > $file-crit ; \
|
|
|
|
|
LC_ALL=C journalctl --no-hostname --boot 0 -p 3..3 > $file-err ; \
|
|
|
|
|
LC_ALL=C journalctl --no-hostname --boot 0 -p 4..4 > $file-warn ; \
|
2017-10-29 07:39:51 +01:00
|
|
|
|
LC_ALL=C journalctl --disk-usage > $file-size ; \
|
2017-10-19 08:57:57 +02:00
|
|
|
|
chown $user_: $file-*"
|
|
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
|
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" \
|
|
|
|
|
"ou juste la partie journaux avec $GREEN./getInfo -j$BLUE ou$GREEN getInfo -j$BLUE (script installé)"
|
2017-10-31 06:52:36 +01:00
|
|
|
|
text+="* les commandes \`journalctl\` ont échoué, relancer avec les droits root \n\n"
|
2017-10-19 08:57:57 +02:00
|
|
|
|
echo -e "$text" >> "$fileOutput"
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
2017-10-25 05:21:16 +02:00
|
|
|
|
jctl_boot=$(cat $file-boot)
|
|
|
|
|
jctl_boot=$(gawk -F '--|,' '{ sub(/^ /,"",$2);print $2}' <<< $(cat $file-boot))
|
2017-10-19 08:57:57 +02:00
|
|
|
|
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)
|
|
|
|
|
jctl_warn_k=$(sed '/kernel:/!d' $file-warn | sed -n 1,"$nb_lignes"p)
|
2017-10-29 07:39:51 +01:00
|
|
|
|
jctl_size=$(grep -Eo '[0-9]*\.[0-9]*[[:alpha:]]{1,2}' $file-size | sed 's/M/ Mo/' )
|
2017-10-20 03:10:56 +02:00
|
|
|
|
[ "$jctl_alert_k" ] || jctl_alert_k=" <vide>"
|
|
|
|
|
[ "$jctl_crit_k" ] || jctl_crit_k=" <vide>"
|
|
|
|
|
[ "$jctl_err_k" ] || jctl_err_k=" <vide>"
|
|
|
|
|
[ "$jctl_warn_k" ] || jctl_warn_k=" <vide>"
|
2017-10-25 05:21:16 +02: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>/' $file-warn | sed -n 1,"$nb_lignes"p)
|
2017-10-19 08:57:57 +02:00
|
|
|
|
rm "$file-"*
|
|
|
|
|
###
|
|
|
|
|
# kernel
|
|
|
|
|
text="## journalctl kernel (emergency, alert, erreur, warning ou critique) \n\n"
|
2017-10-25 05:21:16 +02:00
|
|
|
|
text+="**$jctl_boot** \n\n"
|
2017-10-21 11:07:11 +02:00
|
|
|
|
f_display "jctl_alert_k" "cmd" "journalctl --no-hostname --boot 0 -k -p 1" \
|
2017-10-22 11:14:21 +02:00
|
|
|
|
"(kernel emergency 0 & alerte 1, $nb_lignes premières lignes)"
|
2017-10-21 11:07:11 +02:00
|
|
|
|
f_display "jctl_crit_k" "cmd" "journalctl --no-hostname --boot 0 -k -p 2..2" \
|
2017-10-22 11:14:21 +02:00
|
|
|
|
"(kernel critique, $nb_lignes premières lignes)"
|
2017-10-21 11:07:11 +02:00
|
|
|
|
f_display "jctl_err_k" "cmd" "journalctl --no-hostname --boot 0 -k -p 3..3" \
|
2017-10-22 11:14:21 +02:00
|
|
|
|
"(kernel erreur, $nb_lignes premières lignes)"
|
2017-10-21 11:07:11 +02:00
|
|
|
|
f_display "jctl_warn_k" "cmd" "journalctl --no-hostname --boot 0 -k -p 4..4" \
|
2017-10-22 11:14:21 +02:00
|
|
|
|
"(kernel warning, $nb_lignes premières lignes)"
|
2017-10-19 08:57:57 +02:00
|
|
|
|
# non kernel
|
|
|
|
|
text+="## journalctl hors kernel (emergency, alert, erreur, warning ou critique) \n\n"
|
2017-10-25 05:21:16 +02:00
|
|
|
|
text+="**$jctl_boot** \n\n"
|
|
|
|
|
f_display "jctl_alert_nok" "cmd" "journalctl --no-hostname --boot 0 -p 1 | grep -v kernel" \
|
2017-10-23 03:52:48 +02:00
|
|
|
|
"(hors kernel, emergency 0 & alerte 1, $nb_lignes premières lignes)"
|
2017-10-25 05:21:16 +02:00
|
|
|
|
f_display "jctl_crit_nok" "cmd" "journalctl --no-hostname --boot 0 -p 2..2 | grep -v kernel" \
|
2017-10-23 03:52:48 +02:00
|
|
|
|
"(hors kernel, critique, $nb_lignes premières lignes)"
|
2017-10-25 05:21:16 +02:00
|
|
|
|
f_display "jctl_err_nok" "cmd" "journalctl --no-hostname --boot 0 -p 3..3 | grep -v kernel" \
|
2017-10-23 03:52:48 +02:00
|
|
|
|
"(hors kernel, erreur, $nb_lignes premières lignes)"
|
2017-10-25 05:21:16 +02:00
|
|
|
|
f_display "jctl_warn_nok" "cmd" "journalctl --no-hostname --boot 0 -p 4..4 | grep -v kernel" \
|
2017-10-23 03:52:48 +02:00
|
|
|
|
"(hors kernel, warning, $nb_lignes premières lignes)"
|
2017-10-20 00:50:21 +02:00
|
|
|
|
text+="**les $nb_lignes premières lignes commencent à la date du dernier boot** \n\n"
|
2017-10-29 07:39:51 +01:00
|
|
|
|
f_display "jctl_size" "cmd" "journalctl --disk-usage " "taille des journaux"
|
2017-10-25 10:03:56 +02:00
|
|
|
|
printf "$text\n" >> "$fileOutput"
|
|
|
|
|
unset text
|
2017-10-19 08:57:57 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 06:52:36 +01:00
|
|
|
|
fi_locale(){ # 30/10/2017
|
2017-10-25 12:24:21 +02:00
|
|
|
|
local locale localectl timezone timedatectl
|
|
|
|
|
local xKeyboardMap keyboard alert_Rtc alert_Rtc_info alert_NTP alert_Ntp_info text
|
|
|
|
|
# locale
|
2017-10-31 06:52:36 +01:00
|
|
|
|
locale="$(grep -Esv '#|^[[:space:]]*$' /etc/default/locale* /etc/locale.conf)"
|
2017-10-25 23:45:00 +02:00
|
|
|
|
[ "$(f__cmd_exist localectl)" ] && localectl=$(localectl --no-pager status)
|
2017-10-25 12:24:21 +02:00
|
|
|
|
# timezone
|
2017-10-26 07:05:22 +02:00
|
|
|
|
timezone="$(grep -Hs . /etc/timezone)"
|
2017-10-25 12:24:21 +02:00
|
|
|
|
if [ "$(f__cmd_exist timedatectl)" ]; then
|
2017-09-16 14:25:36 +02:00
|
|
|
|
timedatectl="$(timedatectl status --no-pager)"
|
|
|
|
|
grep -q 'RTC in local TZ: yes' <<< "$timedatectl" && alert_Rtc="Attention RTC in local TZ"
|
|
|
|
|
alert_Rtc_info="**L’horloge système doit être en UTC** pour que les applications de date et heure fonctionnent
|
|
|
|
|
correctement avec le fuseau horaire configuré sur le système. Les modifications d’heure
|
2017-10-02 00:34:34 +02:00
|
|
|
|
d’été/hiver peuvent être incohérentes quand l’horloge matérielle est en heure locale. \n"
|
2017-09-16 14:25:36 +02:00
|
|
|
|
grep -q 'Network time on: no' <<< "$timedatectl" && alert_NTP="Attention NTP"
|
|
|
|
|
alert_Ntp_info="Le système ne synchronise pas l'heure sur un serveur NTP. Si ce n'est pas voulu:
|
|
|
|
|
activer le service: timedatectl set-ntp true
|
2017-10-02 00:34:34 +02:00
|
|
|
|
et/ou installer le démon Ntp: apt install ntp \n"
|
2017-09-16 14:25:36 +02:00
|
|
|
|
fi
|
2017-10-25 12:24:21 +02:00
|
|
|
|
# keyboard layout
|
2017-10-31 06:52:36 +01:00
|
|
|
|
keyboard="$(grep -EHsv '#|^[[:space:]]*$' /etc/default/keyboard*)"
|
2017-10-23 03:52:48 +02:00
|
|
|
|
[ "$(f__cmd_exist setxkbmap)" ] && xKeyboardMap="$(setxkbmap -query)"
|
2017-08-26 09:05:54 +02:00
|
|
|
|
###
|
2017-10-23 03:52:48 +02:00
|
|
|
|
text="## localisation \n\n"
|
2017-10-25 12:24:21 +02:00
|
|
|
|
# locale
|
2017-10-31 06:52:36 +01:00
|
|
|
|
[ "$locale" ] && f_display "locale" "cmd" "grep -Esv '#|^[[:space:]]*$' /etc/default/locale* /etc/locale.conf"
|
2017-10-25 23:45:00 +02:00
|
|
|
|
[ "$localectl" ] && f_display "localectl" "cmd" "localectl --no-pager status"
|
2017-10-25 12:24:21 +02:00
|
|
|
|
# timezone
|
2017-10-26 07:05:22 +02:00
|
|
|
|
[ "$timezone" ] && f_display "timezone" "cmd" "grep -Hs . /etc/timezone*"
|
|
|
|
|
[ "$timezone" ] || f_display_file "/etc/timezone*"
|
2017-10-23 03:52:48 +02:00
|
|
|
|
[ "$timedatectl" ] && f_display "timedatectl" "cmd" "timedatectl status --no-pager"
|
|
|
|
|
[ "$alert_Rtc" ] && text+="$alert_Rtc_info \n"
|
|
|
|
|
[ "$alert_Ntp" ] && text+="$alert_Ntp_info \n"
|
2017-10-25 12:24:21 +02:00
|
|
|
|
# keyboard layout
|
2017-10-31 06:52:36 +01:00
|
|
|
|
[ "$keyboard" ] && f_display "keyboard" "cmd" "grep -EHv '#|^[[:space:]]*$' /etc/default/keyboard*"
|
2017-10-26 07:05:22 +02:00
|
|
|
|
[ "$keyboard" ] || f_display_file "/etc/default/keyboard"
|
2017-10-25 23:45:00 +02:00
|
|
|
|
[ "$xKeyboardMap" ] && f_display "xKeyboardMap" "cmd" "setxkbmap -query"
|
2017-10-25 10:03:56 +02:00
|
|
|
|
printf "$text\n" >> "$fileOutput"
|
|
|
|
|
unset text
|
2017-10-23 03:52:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 06:52:36 +01:00
|
|
|
|
fi_log_xorg(){ # 30/10/2017
|
2017-10-23 03:52:48 +02:00
|
|
|
|
[ "$ENV_SSH" ] && return 0
|
2017-10-20 00:50:21 +02:00
|
|
|
|
local logXorg xfile extract text nb_lignes=50
|
|
|
|
|
# Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice,
|
|
|
|
|
# (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown (WW) warning, (EE) erreur
|
|
|
|
|
# voir options appliquées par config file: cat /var/log/Xorg.0.log | grep -E '\(\*\*\)'
|
|
|
|
|
# voir options par défaut: cat /var/log/Xorg.0.log | grep -E '\(==\)'
|
|
|
|
|
for xfile in /var/log/Xorg.0.log /home/$user_/.local/share/xorg/Xorg.0.log ; do
|
|
|
|
|
if [ -e "$xfile" ]; then
|
|
|
|
|
extract="$(grep -Es '\(WW\)|\(EE\)|\(\?\?\)' $xfile | sed '/(WW) warning, (EE) error,/d')"
|
|
|
|
|
extract="$(sed -n 1,"$nb_lignes"p <<< $extract)"
|
|
|
|
|
if [ "$extract" ]; then
|
2017-10-25 05:21:16 +02:00
|
|
|
|
logXorg+="$xfile (WW) **warning**, (EE) **erreur**, (??) inconnu, $nb_lignes premières lignes \n\n"
|
2017-10-20 00:50:21 +02:00
|
|
|
|
logXorg+="$(grep -E '\(EE\)' <<< $extract) \n"
|
2017-10-31 06:52:36 +01:00
|
|
|
|
logXorg+="$(grep -E '\(WW\)' <<< $extract) "$'\n'$'\n'
|
2017-10-20 00:50:21 +02:00
|
|
|
|
else
|
2017-10-31 06:52:36 +01:00
|
|
|
|
logXorg+="$xfile : <vide> "$'\n'$'\n'
|
2017-10-20 00:50:21 +02:00
|
|
|
|
fi
|
|
|
|
|
else
|
2017-10-31 06:52:36 +01:00
|
|
|
|
logXorg+="$xfile : <inexistant> "$'\n'$'\n'
|
2017-10-20 00:50:21 +02:00
|
|
|
|
fi
|
|
|
|
|
done
|
2017-10-21 11:07:11 +02:00
|
|
|
|
logXorg="${logXorg::-2}"
|
|
|
|
|
###
|
|
|
|
|
text="## journaux Xorg \n\n"
|
|
|
|
|
f_display "logXorg" "cmd" \
|
|
|
|
|
"grep -Es '\(WW\)|\(EE\)|\(\?\?\)' /var/log/Xorg.?.log /home/<user>/.local/share/xorg/Xorg.?.log" \
|
|
|
|
|
"(Xorg.log)"
|
2017-10-25 10:03:56 +02:00
|
|
|
|
printf "$text\n" >> "$fileOutput"
|
|
|
|
|
unset text
|
2017-10-09 20:19:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-25 10:03:56 +02:00
|
|
|
|
fi_mem(){ # 25/10/2017
|
2017-10-25 05:21:16 +02:00
|
|
|
|
local swappiness text var_temp
|
2017-10-22 07:07:07 +02:00
|
|
|
|
swappiness="$(cat /proc/sys/vm/swappiness 2>/dev/null)"
|
|
|
|
|
figet_mem "mem" #options possibles mem swap total notitle nocoltitle
|
2017-10-31 09:10:14 +01:00
|
|
|
|
var_temp="$fg_mem \n\n"
|
2017-10-22 07:07:07 +02:00
|
|
|
|
figet_mem "swap" "notitle"
|
2017-10-31 09:10:14 +01:00
|
|
|
|
var_temp+="$fg_mem \n\n"
|
2017-10-25 05:21:16 +02:00
|
|
|
|
var_temp+="swappiness: $swappiness"
|
2017-10-04 23:26:27 +02:00
|
|
|
|
###
|
2017-10-22 07:07:07 +02:00
|
|
|
|
text="## mémoire \n\n"
|
2017-10-25 05:21:16 +02:00
|
|
|
|
f_display "var_temp" "sans"
|
2017-10-25 10:03:56 +02:00
|
|
|
|
printf "$text\n" >> "$fileOutput"
|
|
|
|
|
unset text
|
2017-10-04 23:26:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-28 15:06:37 +02:00
|
|
|
|
fi_nm(){ # 29/10/2017
|
2017-10-25 05:21:16 +02:00
|
|
|
|
[ "$(f__cmd_exist nmcli)" ] || return 0
|
2017-10-27 14:59:30 +02:00
|
|
|
|
local nm_etat nm_conf nm_wifis nm_connected text
|
2017-10-31 06:52:36 +01:00
|
|
|
|
nm_etat=$(grep -Esv '#|^[[:space:]]*$' /var/lib/NetworkManager/NetworkManager.state)
|
|
|
|
|
nm_conf=$(grep -Esv '#|^[[:space:]]*$' /etc/NetworkManager/NetworkManager.conf)
|
2017-10-27 14:59:30 +02:00
|
|
|
|
nm_wifis=$(nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list | head -n15)
|
|
|
|
|
nm_connected=$(LC_ALL=C nmcli -f SSID,ACTIVE,IN-USE device wifi list | gawk '/yes[[:space:]]+\*/ {print $1}')
|
2017-08-26 09:05:54 +02:00
|
|
|
|
###
|
2017-10-23 03:52:48 +02:00
|
|
|
|
text="## NetworkManager \n\n"
|
2017-10-31 06:52:36 +01:00
|
|
|
|
[ "$nm_etat" ] && f_display "nm_etat" "cmd" "grep -Ev '#|^[[:space:]]*$' /var/lib/NetworkManager/NetworkManager.state"
|
2017-10-26 07:05:22 +02:00
|
|
|
|
[ "$nm_etat" ] || f_display_file "/var/lib/NetworkManager/NetworkManager.state"
|
2017-10-31 06:52:36 +01:00
|
|
|
|
[ "$nm_conf" ] && f_display "nm_conf" "cmd" "grep -Ev '#|^[[:space:]]*$' /etc/NetworkManager/NetworkManager.conf"
|
2017-10-26 07:05:22 +02:00
|
|
|
|
[ "$nm_conf" ] || f_display_file "/etc/NetworkManager/NetworkManager.conf"
|
2017-10-27 14:59:30 +02:00
|
|
|
|
if [ "$nm_wifis" ]; then
|
|
|
|
|
text+="## wifis à proximité \n\n"
|
|
|
|
|
f_display "nm_wifis" "cmd" "nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list | head -n15"
|
|
|
|
|
fi
|
2017-10-25 10:03:56 +02:00
|
|
|
|
printf "$text\n" >> "$fileOutput"
|
|
|
|
|
unset text
|
2017-08-26 09:05:54 +02:00
|
|
|
|
}
|
2017-08-06 02:43:48 +02:00
|
|
|
|
|
2017-11-01 07:45:18 +01:00
|
|
|
|
fi_reseau(){ # 31/10/2017
|
2017-10-27 14:59:30 +02:00
|
|
|
|
local slots cards ip_a iwconfig interfaces route resolv canal_wifi ifx alert_wlx text pluriel
|
|
|
|
|
# cardsManuel="$(lspci -nnk | grep -EiA 5 'network|ethernet')"
|
|
|
|
|
# cardsManuel="$(lspci -nnv | grep -EiA 15 'network|ethernet')"
|
|
|
|
|
# cardsManuel="lspci -nnv -s $( lspci | grep -Ei 'network|ethernet' | cut -d" " -f1 )" si devices plusieurs slots???
|
2017-10-26 05:23:33 +02:00
|
|
|
|
#lspci
|
2017-10-27 14:59:30 +02:00
|
|
|
|
slots="$(lspci | grep -Ei 'network|ethernet' | cut -d" " -f1)"
|
|
|
|
|
for ifx in $slots; do
|
|
|
|
|
cards+=$(lspci -s $ifx -nnv)$'\n'
|
2017-09-22 14:55:55 +02:00
|
|
|
|
done
|
2017-11-01 07:45:18 +01:00
|
|
|
|
[ "$cards" ] && cards=${cards::-1} # suppression dernier $'\n'
|
2017-10-31 06:52:36 +01:00
|
|
|
|
[ $(f__wcv -l "$cards") -eq 0 ] && cards="lspci incompatible"
|
2017-10-26 05:23:33 +02:00
|
|
|
|
# ip a & route
|
2017-10-09 20:19:07 +02:00
|
|
|
|
ip_a="$(ip a | sed '/link\/ether/d; /valid_lft/d')" # filtre sur adr MAC & bail
|
|
|
|
|
# ip_a="$(sed '/inet6.*scope global/d; /inet6.*scope link/d' <<< $ip_a)" # filtre sur inet6 scope global & scope link (fe80::)
|
|
|
|
|
ip_a="$(sed '/inet6.*/d' <<< $ip_a)" # filtre sur inet6)
|
|
|
|
|
route="$(ip route show)"
|
2017-10-26 05:23:33 +02:00
|
|
|
|
# interfaces & resolv
|
2017-10-31 06:52:36 +01:00
|
|
|
|
interfaces="$(grep -EHrsv '#|^[[:space:]]*$' /etc/network/interfaces*)"
|
2017-10-01 06:09:57 +02:00
|
|
|
|
interfaces="$(sed -E 's/wpa-psk [[:graph:]]+/wpa-psk <WPA key removed>/; s/:/: /' <<< $interfaces )"
|
2017-10-31 06:52:36 +01:00
|
|
|
|
resolv="$(grep -Esv '#|^[[:space:]]*$' /etc/resolv.conf)"
|
2017-10-26 05:23:33 +02:00
|
|
|
|
# iwconfig
|
2017-10-27 14:59:30 +02:00
|
|
|
|
if [ $(f__cmd_exist iwconfig) ]; then #paquet wireless-tools requis
|
2017-10-31 06:52:36 +01:00
|
|
|
|
iwconfig="$(iwconfig 2>&1 | grep -v 'no wireless extensions' | grep -v '^[[:space:]]*$')"
|
2017-10-09 20:19:07 +02:00
|
|
|
|
fi
|
2017-10-26 19:31:32 +02:00
|
|
|
|
# iwlist
|
2017-10-27 14:59:30 +02:00
|
|
|
|
if [ $(f__cmd_exist iwlist) ]; then # canal wifi utilisé; /sbin, paquet wireless-tools requis
|
2017-10-26 19:31:32 +02:00
|
|
|
|
canal_wifi="$(iwlist chan 2>&1 | grep 'Current Frequency' | grep -Eio 'channel [0-9]+')"
|
2017-10-09 20:19:07 +02:00
|
|
|
|
fi
|
2017-10-26 05:23:33 +02:00
|
|
|
|
# network manager
|
2017-10-22 11:14:21 +02:00
|
|
|
|
netmgrpaths=("/usr/sbin/NetworkManager" "/usr/sbin/wicd" "/usr/sbin/connmand")
|
|
|
|
|
netmgrnames=("NetworkManager" "Wicd" "ConnMan")
|
|
|
|
|
for ifx in "${!netmgrpaths[@]}"; do
|
2017-10-27 14:59:30 +02:00
|
|
|
|
[ -f "${netmgrpaths[$ifx]}" ] && netmgrinst+=${netmgrnames[$ifx]}
|
2017-10-22 11:14:21 +02:00
|
|
|
|
if [ "$(ps -ef | grep -c ${netmgrpaths[$ifx]})" -ge 2 ]; then
|
|
|
|
|
netmgrrun+="$(ps -ef | grep -o "${netmgrpaths[$ifx]}.*$" | head -n 1)"
|
2017-10-01 06:09:57 +02:00
|
|
|
|
fi
|
2017-08-26 09:05:54 +02:00
|
|
|
|
done
|
2017-10-09 20:19:07 +02:00
|
|
|
|
figet_ip
|
2017-10-27 14:59:30 +02:00
|
|
|
|
if grep -q 'wlx' <<< "$fg_ifn"; then
|
|
|
|
|
alert_wlx="**Attention:** une interface wifi est en erreur: $(grep -o 'wlx' <<< $fg_ifn) \n"
|
|
|
|
|
alert_wlx+="l'interface n'est pas reconnue et est donc mal nommée \n"
|
|
|
|
|
alert_wlx+="au pire, changer le renommage: "
|
|
|
|
|
alert_wlx+="https://kyodev.frama.io/kyopages/trucs/interfaces-nommage-classique/ \n\n"
|
|
|
|
|
fi
|
2017-10-22 11:14:21 +02:00
|
|
|
|
figet_mod_net
|
2017-10-26 19:31:32 +02:00
|
|
|
|
###
|
2017-10-22 11:14:21 +02:00
|
|
|
|
text="## réseau \n\n"
|
2017-10-26 05:23:33 +02:00
|
|
|
|
#lspci
|
2017-10-31 06:52:36 +01:00
|
|
|
|
[ "$cards" ] && f_display "cards" "cmd" "lspci -nnv | grep -EiA 15 'network|ethernet"
|
2017-10-26 05:23:33 +02:00
|
|
|
|
# ip locales avec type
|
2017-10-27 14:59:30 +02:00
|
|
|
|
f_display "fg_ip_tp" "var" "IP locale(s):"
|
|
|
|
|
[ "$alert_wlx" ] && text+="alert_wlx \n\n"
|
2017-10-31 06:52:36 +01:00
|
|
|
|
text+="* les adresses Mac peut être affichées avec "'`./getInfo --mac` ou `getInfo --mac`'" (script installé) \n"
|
|
|
|
|
text+="* l'IP publique peut être connue avec: "'`./getInfo --ip` ou `getInfo --ip` (script installé) \n\n'
|
2017-10-27 14:59:30 +02:00
|
|
|
|
# gateways
|
|
|
|
|
f_display "fg_gws" "var" "Passerelle(s):"
|
2017-10-26 05:23:33 +02:00
|
|
|
|
# interface prioritaire
|
2017-10-27 14:59:30 +02:00
|
|
|
|
[ $(wc -w <<< $fg_ifn) -gt 1 ] && f_display "fg_ifn_prior" "var" "interface prioritaire"
|
2017-10-26 05:23:33 +02:00
|
|
|
|
# ip a & route & interface & resolv
|
2017-10-22 11:14:21 +02:00
|
|
|
|
f_display "ip_a" "cmd" "ip address" "(sans ipV6 et sans adresses MAC)"
|
|
|
|
|
f_display "route" "cmd" "ip route show"
|
2017-10-31 06:52:36 +01:00
|
|
|
|
[ "$interfaces" ] && f_display "interfaces" "cmd" "grep -EHrsv '#|^[[:space:]]*$' /etc/network/interfaces*"
|
2017-10-27 14:59:30 +02:00
|
|
|
|
[ "$interfaces" ] || f_display_file "/etc/network/interfaces*"
|
|
|
|
|
[ "$resolv" ] && f_display "resolv" "cmd" "cat /etc/resolv.conf" "(serveurs de noms DNS utilisés)"
|
|
|
|
|
[ "$resolv" ] || f_display_file "/etc/resolv.conf"
|
2017-10-26 05:23:33 +02:00
|
|
|
|
# iwconfig & iwlist
|
2017-10-27 14:59:30 +02:00
|
|
|
|
[ "$iwconfig" ] && f_display "iwconfig" "cmd" "iwconfig" "état carte wifi"
|
2017-10-26 19:31:32 +02:00
|
|
|
|
if [ "$canal_wifi" ]; then
|
2017-10-27 14:59:30 +02:00
|
|
|
|
f_display "canal_wifi" "cmd" "iwlist chan | grep 'Current Frequency' | grep -Eio 'channel [0-9]+'" \
|
|
|
|
|
"canal wifi utilisé"
|
|
|
|
|
text+="* la configuration ssid utilisée peut être connue (si NetworkManager utilisé) avec \n"
|
2017-10-26 19:31:32 +02:00
|
|
|
|
text+="\`./getInfo --ssid\` ou \`getInfo --ssid\` (script installé) \n\n"
|
2017-08-26 09:05:54 +02:00
|
|
|
|
fi
|
2017-10-27 14:59:30 +02:00
|
|
|
|
# network manager
|
2017-08-26 09:05:54 +02:00
|
|
|
|
if [ "$netmgrinst" ]; then
|
2017-10-22 11:14:21 +02:00
|
|
|
|
text+="### gestionnaire de réseau \n\n"
|
|
|
|
|
if [ "$netmgrinst" ]; then
|
2017-10-27 14:59:30 +02:00
|
|
|
|
[ $(wc -w <<< $netmgrinst) -gt 1 ] && pluriel="s" || unset pluriel
|
2017-10-22 11:14:21 +02:00
|
|
|
|
text+="installé$pluriel: **$netmgrinst** \n"
|
|
|
|
|
else
|
2017-10-27 14:59:30 +02:00
|
|
|
|
[ $(wc -w <<< $netmgrnames[@]) -gt 1 ] && pluriel="s" || unset pluriel
|
2017-10-22 11:14:21 +02:00
|
|
|
|
text+="non trouvé$pluriel parmi: ${netmgrnames[@]} \n"
|
|
|
|
|
fi
|
2017-08-26 09:05:54 +02:00
|
|
|
|
text+="en fonctionnement: "
|
2017-10-22 11:14:21 +02:00
|
|
|
|
[ "$netmgrrun" ] && text+="**$netmgrrun** \n\n" || text+="aucun \n\n"
|
2017-08-19 03:45:31 +02:00
|
|
|
|
fi
|
2017-10-26 05:23:33 +02:00
|
|
|
|
# modules réseau
|
2017-10-22 11:14:21 +02:00
|
|
|
|
text+="### modules réseau \n\n"
|
2017-10-31 09:10:14 +01:00
|
|
|
|
[ "$fg_mod_net" ] && f_display "fg_mod_net" "var" "liste non garantie complète"
|
|
|
|
|
[ "$fg_mod_net" ] || text+="**Modules chargés non reconnus**"
|
2017-10-25 10:03:56 +02:00
|
|
|
|
printf "$text\n" >> "$fileOutput"
|
|
|
|
|
unset text
|
2017-08-17 17:32:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-01 07:45:18 +01:00
|
|
|
|
fi_sources(){ # 31/10/2017
|
2017-10-22 11:14:21 +02:00
|
|
|
|
[ "$(f__cmd_exist dpkg)" ] || return 0
|
2017-10-12 21:49:57 +02:00
|
|
|
|
local sources dateMaj nb_packages apt text pluriel
|
|
|
|
|
local alert_autoremove alert_nbAutoremove alert_paquetToRemove alert_httpredir alert_httpredir_text
|
|
|
|
|
local alert_upgradable alert_upgradable_text alert_nbUpgradable
|
2017-10-25 05:21:16 +02:00
|
|
|
|
local alert_paquetBiz alert_paquetBiz_text0 alert_paquetBiz_text
|
2017-08-26 09:05:54 +02:00
|
|
|
|
printf "."
|
2017-10-31 06:52:36 +01:00
|
|
|
|
sources="$(grep -Ersv '^#|^[[:space:]]*$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list)"
|
2017-10-02 00:34:34 +02:00
|
|
|
|
sources="$(sed 's/:deb/: deb/; s/ / /g' <<< $sources)"
|
2017-10-02 15:34:29 +02:00
|
|
|
|
dateMaj="$(date -r /var/cache/apt/pkgcache.bin '+%d/%m/%Y %H:%M %z')" # /var/lib/dpkg/
|
2017-09-29 20:27:53 +02:00
|
|
|
|
nb_packages="$(dpkg -l | grep -c '^ii')"
|
2017-08-26 09:05:54 +02:00
|
|
|
|
printf "."
|
2017-08-30 22:46:26 +02:00
|
|
|
|
apt="$(LC_ALL=C apt-get autoremove --simulate)"
|
2017-10-12 21:49:57 +02:00
|
|
|
|
alert_nbAutoremove="$(grep -c 'Remv' <<< $apt)"
|
|
|
|
|
if [ "$alert_nbAutoremove" -ne 0 ]; then
|
|
|
|
|
[ "$alert_nbAutoremove" -gt 1 ] && pluriel="s" || unset pluriel
|
2017-10-22 11:14:21 +02:00
|
|
|
|
alert_autoremove="$alert_nbAutoremove paquet$pluriel installé$pluriel inutile$pluriel, "
|
|
|
|
|
alert_autoremove+="vous pouvez utiliser: \`apt autoremove\`"
|
2017-10-12 21:49:57 +02:00
|
|
|
|
alert_paquetToRemove="$(sed -En 's/Remv (.*)\[[0-9.-]*\]/\1/p' <<< $apt | tr '\n' ' ')"
|
|
|
|
|
fi
|
2017-08-26 09:05:54 +02:00
|
|
|
|
printf "."
|
2017-10-12 21:49:57 +02:00
|
|
|
|
alert_httpredir="$(grep 'httpredir' <<< $sources)"
|
|
|
|
|
if [ "$alert_httpredir" ]; then
|
|
|
|
|
alert_httpredir_text="url **httpredir**, ces urls sont obsolètes, préférer "
|
|
|
|
|
alert_httpredir_text+="http://deb.debian.org/debian/ ou un miroir local"
|
|
|
|
|
fi
|
|
|
|
|
alert_upgradable="$(LC_ALL=C apt list --upgradable 2>/dev/null | sed '1d')"
|
|
|
|
|
if [ "$alert_upgradable" ]; then
|
|
|
|
|
alert_nbUpgradable="$(grep -c '.' <<< "$alert_upgradable")"
|
2017-10-22 11:14:21 +02:00
|
|
|
|
[ "$alert_nbUpgradable" -gt 1 ] && pluriel="s" || unset pluriel
|
|
|
|
|
alert_upgradable_text="$alert_nbUpgradable paquet$pluriel à mettre à jour, "
|
2017-10-12 21:49:57 +02:00
|
|
|
|
alert_upgradable_text+='`apt list --upgradable`:'
|
|
|
|
|
fi
|
2017-08-26 09:05:54 +02:00
|
|
|
|
printf "."
|
2017-11-01 07:45:18 +01:00
|
|
|
|
alert_paquetBiz="$(LC_ALL=C dpkg -l | gawk 'FNR>5 && ! /^i/ {print $1, $2, $3}')"
|
2017-10-12 21:49:57 +02:00
|
|
|
|
if [ "$alert_paquetBiz" ]; then
|
|
|
|
|
[ "$(grep -c '.' <<< "$alert_paquetBiz")" -gt 1 ] && pluriel="s" || unset pluriel
|
2017-10-22 11:14:21 +02:00
|
|
|
|
alert_paquetBiz_text0="$(grep -c '.' <<< \
|
|
|
|
|
"$alert_paquetBiz") paquet$pluriel dans un état non installé"
|
2017-10-13 00:42:26 +02:00
|
|
|
|
[[ ${alert_paquetBiz,,} =~ ^. ]] && alert_paquetBiz_text="* **État souhaité** "$'\n'
|
2017-10-12 21:49:57 +02:00
|
|
|
|
[[ ${alert_paquetBiz,,} =~ ^h ]] && alert_paquetBiz_text+=" * **h**old (à garder) "$'\n'
|
|
|
|
|
[[ ${alert_paquetBiz,,} =~ ^i ]] && alert_paquetBiz_text+=" * **i**nstall (à installer) "$'\n'
|
|
|
|
|
[[ ${alert_paquetBiz,,} =~ ^p ]] && alert_paquetBiz_text+=" * **p**urge (à purger) "$'\n'
|
|
|
|
|
[[ ${alert_paquetBiz,,} =~ ^r ]] && alert_paquetBiz_text+=" * **r**emove (à supprimer) "$'\n'
|
|
|
|
|
[[ ${alert_paquetBiz,,} =~ ^u ]] && alert_paquetBiz_text+=" * **u**nknown (inconnu) "$'\n'
|
2017-10-13 00:42:26 +02:00
|
|
|
|
[[ ${alert_paquetBiz,,} =~ ^.. ]] && alert_paquetBiz_text+="* **État du paquet** "$'\n'
|
2017-10-12 21:49:57 +02:00
|
|
|
|
[[ ${alert_paquetBiz,,} =~ ^.c ]] && alert_paquetBiz_text+=" * **c**onfig-files (fichiers de configuration seuls) "$'\n'
|
|
|
|
|
[[ ${alert_paquetBiz,,} =~ ^.f ]] && alert_paquetBiz_text+=" * hal**F**-configured-configured (semi-configuré) "$'\n'
|
|
|
|
|
[[ ${alert_paquetBiz,,} =~ ^.h ]] && alert_paquetBiz_text+=" * **H**alf-installed (semi-installé) "$'\n'
|
|
|
|
|
[[ ${alert_paquetBiz,,} =~ ^.i ]] && alert_paquetBiz_text+=" * **i**nstalled (installé) "$'\n'
|
|
|
|
|
[[ ${alert_paquetBiz,,} =~ ^.n ]] && alert_paquetBiz_text+=" * **n**ot-installed (non installé) "$'\n'
|
|
|
|
|
[[ ${alert_paquetBiz,,} =~ ^.t ]] && alert_paquetBiz_text+=" * **t**riggers-pending (en instance déclencheurs) "$'\n'
|
|
|
|
|
[[ ${alert_paquetBiz,,} =~ ^.u ]] && alert_paquetBiz_text+=" * **u**npacked (décompressé seulement) "$'\n'
|
|
|
|
|
[[ ${alert_paquetBiz,,} =~ ^.w ]] && alert_paquetBiz_text+=" * triggers-a**w**aiting (attente déclencheurs) "$'\n'
|
|
|
|
|
[[ ${alert_paquetBiz,,} =~ ^..r ]] && alert_paquetBiz_text+="* **Drapeaux d'erreur**\n * (réinstallation requise) "$'\n'
|
2017-11-01 07:45:18 +01:00
|
|
|
|
[ "$alert_paquetBiz_text" ] && alert_paquetBiz_text=${alert_paquetBiz_text::-1} # suppression dernier $'\n'
|
2017-10-12 21:49:57 +02:00
|
|
|
|
fi
|
2017-08-19 03:45:31 +02:00
|
|
|
|
###
|
2017-10-22 11:14:21 +02:00
|
|
|
|
text="## sources liste \n\n"
|
2017-10-31 06:52:36 +01:00
|
|
|
|
f_display "sources" "cmd" "grep -Ersv '^#|^[[:space:]]*$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list"
|
2017-10-02 00:34:34 +02:00
|
|
|
|
text+="nombre de paquets installés: **$nb_packages** \n\n"
|
|
|
|
|
text+="dernière mise à jour apt: **$dateMaj** \n\n"
|
2017-10-22 11:14:21 +02:00
|
|
|
|
[ "$alert_autoremove" ] && f_display "alert_paquetToRemove" "var" "$alert_autoremove"
|
|
|
|
|
[ "$alert_httpredir" ] && f_display "alert_httpredir" "var" "$alert_httpredir_text"
|
|
|
|
|
[ "$alert_upgradable" ] && f_display "alert_upgradable" "var" "$alert_upgradable_text"
|
2017-10-12 21:49:57 +02:00
|
|
|
|
if [ "$alert_paquetBiz" ]; then
|
2017-10-22 11:14:21 +02:00
|
|
|
|
f_display "alert_paquetBiz" "var" "$alert_paquetBiz_text0"
|
2017-10-12 21:49:57 +02:00
|
|
|
|
text+="$alert_paquetBiz_text"' \n\n'
|
2017-08-06 02:43:48 +02:00
|
|
|
|
fi
|
2017-10-25 10:03:56 +02:00
|
|
|
|
printf "$text\n" >> "$fileOutput"
|
|
|
|
|
unset text
|
2017-08-06 02:43:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-27 14:59:30 +02:00
|
|
|
|
fi_ssid(){ # 27/10/2017
|
2017-10-23 03:52:48 +02:00
|
|
|
|
[ "$(f__cmd_exist nmcli)" ] || f__error "NetworkManager requis"
|
2017-10-11 02:06:15 +02:00
|
|
|
|
local nm_ssid file="/tmp/$$-$RANDOM-fi_ssid" text
|
2017-10-31 06:52:36 +01:00
|
|
|
|
# nm_ssid="$(grep -Ev '#|^[[:space:]]*$' /etc/NetworkManager/system-connections/*)"
|
2017-10-11 02:06:15 +02:00
|
|
|
|
[ "$EUID" -eq 0 ] || echo
|
2017-10-31 06:52:36 +01:00
|
|
|
|
f__sudo "grep -Ev '#|^[[:space:]]*$' /etc/NetworkManager/system-connections/* > $file ; \
|
2017-10-11 02:06:15 +02:00
|
|
|
|
chown $user_: $file"
|
|
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
|
f__info "\n la consultation des connections NetworkManager$RED a échoué$BLUE (droits root requis, échec authentification?)" \
|
|
|
|
|
"vous pouvez relancer le script$RED en root:$GREEN./getInfo --ssid$STD ou$GREEN getInfo --ssid$BLUE (script installé)"
|
|
|
|
|
text+="la consultation des connections NetworkManager a échoué, relancer avec les droits root \n"
|
|
|
|
|
echo -e "$text" >> "$fileOutput"
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
nm_ssid="$(< $file)"
|
|
|
|
|
rm "$file"
|
2017-08-19 03:45:31 +02:00
|
|
|
|
###
|
2017-10-27 14:59:30 +02:00
|
|
|
|
f__info "la$RED clé du réseau wifi étant visible$STD, aucun rapport n'a été créé"
|
2017-09-04 13:35:14 +02:00
|
|
|
|
text="## configuration(s) ssid networkmanager \n\n"
|
2017-10-31 06:52:36 +01:00
|
|
|
|
text+="$GREEN""grep -Ev '#|^[[:space:]]*$' /etc/NetworkManager/system-connections/*$STD \n\n"
|
2017-10-02 00:34:34 +02:00
|
|
|
|
text+="$nm_ssid \n\n"
|
2017-10-25 10:03:56 +02:00
|
|
|
|
printf "$text" >> "$fileOutput"
|
|
|
|
|
unset text
|
2017-08-06 02:43:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-25 10:03:56 +02:00
|
|
|
|
fi_system_analyse(){ # 25/10/2017
|
2017-10-22 11:14:21 +02:00
|
|
|
|
[ "$(f__cmd_exist systemd-analyze)" ] || return 0 # pas systemd
|
2017-08-30 22:46:26 +02:00
|
|
|
|
local bootTime bootBlame text
|
|
|
|
|
bootTime="$(systemd-analyze time)"
|
|
|
|
|
bootBlame="$(systemd-analyze blame | head -n 20)"
|
2017-08-19 03:45:31 +02:00
|
|
|
|
###
|
2017-08-30 22:46:26 +02:00
|
|
|
|
text="## analyse boot \n\n"
|
2017-10-02 00:34:34 +02:00
|
|
|
|
text+="$(sed 's/Startup finished in /**durée de boot:** /; s/userspace/espace utilisateur/; s/= \(.*\)$/= **\1**/' <<< $bootTime) \n\n"
|
2017-10-22 11:14:21 +02:00
|
|
|
|
f_display "bootBlame" "cmd" "systemd-analyze blame | head -n 20"
|
2017-10-25 10:03:56 +02:00
|
|
|
|
printf "$text\n" >> "$fileOutput"
|
|
|
|
|
unset text
|
2017-08-06 02:43:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 12:12:03 +01:00
|
|
|
|
fi_systeme(){ # 31/10/2017
|
|
|
|
|
local mbr uname bootImage initDaemon xorg shells lastboot uptime charge pluriel text
|
2017-10-23 09:30:57 +02:00
|
|
|
|
local alim_total alimentation
|
|
|
|
|
[ -d /sys/firmware/efi ] && mbr="EFI" || mbr="Legacy (mbr)"
|
2017-08-30 22:46:26 +02:00
|
|
|
|
uname="$(uname -rmo)"
|
2017-10-09 20:19:07 +02:00
|
|
|
|
bootImage="$(gawk '/BOOT_IMAGE/ {print $1}' /proc/cmdline)"
|
|
|
|
|
bootImage="$(gawk '{print $1}{i=2; while (i <= NF-1) { print " ",$i; i++}}' /proc/cmdline)"
|
|
|
|
|
initDaemon="$(ps -p1 | gawk 'FNR==2 {print $4}')" #? ps -ax | gawk '$1==1' ou ps -p1 | gawk '$1==1'
|
2017-10-23 03:52:48 +02:00
|
|
|
|
[ "$ENV_SSH" ] && xorg="n/a (ssh)" || xorg="$XDG_SESSION_TYPE"
|
2017-08-26 09:05:54 +02:00
|
|
|
|
if [ -z "$xorg" ]; then
|
|
|
|
|
[ "$(ps -ef | grep -c 'wayland')" -gt 1 ] && xorg="wayland" || xorg="indéterminé"
|
|
|
|
|
fi
|
2017-10-31 06:52:36 +01:00
|
|
|
|
shells="$(grep -Ev '^[[:blank:]]*#|^[[:space:]]*$' /etc/shells | sed 's/\/bin\///' | tr '\n' ' ')"
|
2017-10-23 09:58:56 +02:00
|
|
|
|
if [ $(grep -c 'AC' <<< $(ls /sys/class/power_supply/ 2>/dev/null)) -gt 0 ]; then
|
2017-10-23 09:30:57 +02:00
|
|
|
|
alim_total=$(grep -cs . <<< $(ls /sys/class/power_supply/AC*/online))
|
|
|
|
|
alimentation=$( awk -v "alim_total=$alim_total" '
|
|
|
|
|
{ alim_on=sprintf("%d", $1); if (alim_on>1) pllo="s" }
|
|
|
|
|
END { if ( alim_total > 1 ) pllt="s"; printf alim_total " alimentation" pllt
|
|
|
|
|
if ( alim_total != alim_on ) print ", " alim_on " branchée" pllo; else print "" }
|
|
|
|
|
' /sys/class/power_supply/AC*/online )
|
|
|
|
|
fi
|
2017-10-09 20:19:07 +02:00
|
|
|
|
# lastboot="$(last -n 1 --time-format iso reboot | gawk 'FNR==1 {sub(/T/," ",$5);print $5}')" # remis à jours en début de mois ?!!
|
2017-10-02 15:34:29 +02:00
|
|
|
|
lastboot="$(date -r /var/run/utmp '+%d/%m/%Y %H:%M %z')"
|
2017-10-31 09:10:14 +01:00
|
|
|
|
uptime=$(uptime) # uptime tempo pour charge
|
|
|
|
|
charge=${uptime/*average: } # suppression jusqu'à average:
|
|
|
|
|
charge=${charge//, / } # remplacement global ', ' par ' '
|
|
|
|
|
charge=${charge//,/.} # remplacement global , par .
|
|
|
|
|
uptime=${uptime%%,[[:blank:]]*} # uptime -p parfois inexistant (alpine), suppression depuis ,[blancs]* (fin)
|
|
|
|
|
uptime="$( sed 's/up/depuis/; s/week/semaine/; s/weeks/semaines/; s/days/jours/; s/day/jour/;
|
|
|
|
|
s/hour[s]*/h/; s/minute[s]*/mn/' <<< $uptime )"
|
2017-10-13 21:58:51 +02:00
|
|
|
|
figet_batt
|
2017-10-11 02:06:15 +02:00
|
|
|
|
figet_cpu
|
2017-10-12 08:45:16 +02:00
|
|
|
|
figet_de
|
|
|
|
|
figet_dmi
|
2017-10-11 02:06:15 +02:00
|
|
|
|
figet_disk
|
2017-10-29 03:19:47 +01:00
|
|
|
|
figet_distrib
|
2017-11-01 07:45:18 +01:00
|
|
|
|
[ "$fg_nb_gpu" ] || figet_gpu
|
2017-10-26 05:23:33 +02:00
|
|
|
|
figet_screen
|
2017-10-12 08:45:16 +02:00
|
|
|
|
figet_shell
|
|
|
|
|
figet_wm
|
2017-10-30 10:50:22 +01:00
|
|
|
|
###
|
2017-10-14 18:20:26 +02:00
|
|
|
|
f__architecture || f__info "Architecture non supportée" "vous pouvez contacter $projet, $contact " \
|
|
|
|
|
"pour aider à parfaire le script"
|
2017-10-23 09:30:57 +02:00
|
|
|
|
text="## système \n\n"
|
2017-10-31 09:10:14 +01:00
|
|
|
|
text+="> **$fg_dmi** \n\n"
|
2017-10-23 09:30:57 +02:00
|
|
|
|
text+="* CPU \n"
|
2017-10-31 09:10:14 +01:00
|
|
|
|
text+=" * **$(sed -n '1p' <<< $fg_cpu)** \n"
|
2017-10-23 09:30:57 +02:00
|
|
|
|
text+="* GPU \n"
|
2017-10-30 10:50:22 +01:00
|
|
|
|
[ "$fg_gpu" ] && text+="$(sed -E 's/(.*)/ \* \*\*\1\*\*/' <<<$fg_gpu) \n" || text+="* **n/a** \n"
|
2017-10-23 09:30:57 +02:00
|
|
|
|
text+="* boot **$mbr** \n"
|
2017-10-29 03:19:47 +01:00
|
|
|
|
text+="* distribution **$fg_distrib** \n\n"
|
2017-10-22 06:45:56 +02:00
|
|
|
|
text+='``` \n'
|
2017-10-31 12:12:03 +01:00
|
|
|
|
text+="processeur: $fg_cpu_arch \n"
|
2017-11-01 07:45:18 +01:00
|
|
|
|
text+="architecture système: $architecture \n"
|
2017-10-22 06:45:56 +02:00
|
|
|
|
text+="uname: $uname \n"
|
|
|
|
|
text+="$bootImage \n"
|
|
|
|
|
text+="démon d'initialisation: $initDaemon \n"
|
|
|
|
|
text+="serveur d'affichage: $xorg \n"
|
2017-10-30 10:50:22 +01:00
|
|
|
|
text+="nombre d'écrans: $fg_nb_screen \n"
|
|
|
|
|
text+="résolution: $fg_resolution \n"
|
2017-10-31 09:10:14 +01:00
|
|
|
|
text+="desktop (DE): $fg_de \n"
|
|
|
|
|
text+="window manager: $fg_wm \n"
|
|
|
|
|
text+="shell actif: $fg_shell \n"
|
2017-10-22 06:45:56 +02:00
|
|
|
|
text+="shells installés: $shells \n"
|
2017-10-31 09:10:14 +01:00
|
|
|
|
[ "$fg_disk_part_fix_tot" ] && text+="$fg_disk_part_fix_tot \n"
|
2017-10-23 09:30:57 +02:00
|
|
|
|
[ "$alimentation" ] && text+="$alimentation \n"
|
2017-10-27 14:59:30 +02:00
|
|
|
|
if [ "$fg_batt" ]; then
|
|
|
|
|
[ "$fg_nb_batt" -gt "1" ] && pluriel="s" || unset pluriel
|
|
|
|
|
text+="$fg_nb_batt batterie$pluriel présente$pluriel: \n"
|
|
|
|
|
text+="$(sed -En 's/^BAT(.*)$/ BAT\1/p' <<< $fg_batt) \n"
|
2017-09-28 20:47:34 +02:00
|
|
|
|
fi
|
2017-10-22 06:45:56 +02:00
|
|
|
|
text+="dernier boot: $lastboot, uptime: $uptime \n"
|
2017-10-31 09:10:14 +01:00
|
|
|
|
text+="charge système depuis les 1, 5 et 15 dernières minutes: $charge ($fg_nb_threads threads) \n"
|
2017-10-22 06:45:56 +02:00
|
|
|
|
text+='``` \n\n'
|
2017-10-25 10:03:56 +02:00
|
|
|
|
printf "$text\n" >> "$fileOutput"
|
|
|
|
|
unset text
|
2017-08-06 02:43:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-25 10:03:56 +02:00
|
|
|
|
fi_usb(){ # 25/10/2017
|
2017-08-30 22:46:26 +02:00
|
|
|
|
local lsusb lsusb_t text
|
|
|
|
|
lsusb="$(lsusb)"
|
|
|
|
|
lsusb_t="$(lsusb -t)"
|
2017-08-19 03:45:31 +02:00
|
|
|
|
###
|
2017-10-22 11:14:21 +02:00
|
|
|
|
text="## USB \n\n"
|
|
|
|
|
f_display "lsusb" "cmd" "lsusb"
|
|
|
|
|
f_display "lsusb_t" "cmd" "lsusb -t"
|
2017-10-25 10:03:56 +02:00
|
|
|
|
printf "$text\n" >> "$fileOutput"
|
|
|
|
|
unset text
|
2017-08-02 01:16:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-30 10:50:22 +01:00
|
|
|
|
fi_vrms(){ # 30/09/2017
|
|
|
|
|
local vrms text tempo tempo1 tempo2 pluriel
|
|
|
|
|
[ "$(f__cmd_exist vrms)" ] && vrms="$(vrms)"
|
|
|
|
|
###
|
|
|
|
|
# tempo1=$(grep -o '.*non-free packages' <<< "$vrms" | xargs)
|
|
|
|
|
# tempo2=$(grep -o '.*contrib packages' <<< "$vrms" | xargs)
|
|
|
|
|
# tempo=$(( ${tempo1:0:1} + ${tempo2:0:1} ))
|
|
|
|
|
# [[ "$tempo1" && "$tempo" -gt 1 ]] && pluriel="s" || unset pluriel
|
|
|
|
|
if [ "$vrms" ]; then
|
|
|
|
|
text="## paquets$pluriel non-libres$pluriel \n\n"
|
|
|
|
|
f_display "vrms" "cmd" "vrms"
|
|
|
|
|
else
|
|
|
|
|
text+="* les paquets non-free ou contrib ne peuvent être détectés sans l'installation de vrms \n"
|
|
|
|
|
fi
|
|
|
|
|
printf "$text\n" >> "$fileOutput"
|
|
|
|
|
unset text
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-27 14:59:30 +02:00
|
|
|
|
# informations batterie(s), assigne $fg_nb_batt $fg_batt
|
2017-11-01 12:55:53 +01:00
|
|
|
|
figet_batt(){ #v2 01/11/2017
|
2017-10-23 03:52:48 +02:00
|
|
|
|
local batt_detail batt_nb batt_unit batt_capa_design batt_capa_full batt_capa_now batt_conso
|
2017-10-14 17:54:16 +02:00
|
|
|
|
local batt_volt_min batt_volt_now batt_status batt_cycle batt_sn alert_batt_alarm
|
2017-10-15 00:42:44 +02:00
|
|
|
|
local batt_sante batt_restant tempo batRep ibat uevent
|
2017-10-12 08:45:16 +02:00
|
|
|
|
if [ ! -d /sys/class/power_supply ]; then # anciennes interfaces ou inconnu
|
2017-10-27 14:59:30 +02:00
|
|
|
|
[ -d /proc/acpi/battery ] && batt_detail="ancienne interface ACPI non gérée (obsolète)"
|
2017-10-12 21:49:57 +02:00
|
|
|
|
[ -f /proc/apm ] && batt_detail="anciennes batteries APM non gérées (obolète)"
|
2017-10-12 08:45:16 +02:00
|
|
|
|
[ "$batt_detail" ] || batt_detail="répertoire power_supply inaccessible"
|
|
|
|
|
batt_nb="-1"
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
2017-10-27 14:59:30 +02:00
|
|
|
|
[ "$(grep -c 'BAT' <<< $(ls /sys/class/power_supply/ 2>/dev/null))" -gt 0 ] || return 0
|
2017-10-14 17:54:16 +02:00
|
|
|
|
batt_nb="$(grep -i 'Battery' /sys/class/power_supply/*/type | grep -c .)"
|
2017-10-27 14:59:30 +02:00
|
|
|
|
[ "$batt_nb" ] || return
|
2017-10-14 17:54:16 +02:00
|
|
|
|
batRep="/sys/class/power_supply"
|
|
|
|
|
unset batt_detail
|
|
|
|
|
for ibat in $(ls $batRep); do
|
|
|
|
|
grep -qi 'Battery' "$batRep/$ibat/type" || continue # plus loin si non batterie
|
2017-10-27 14:59:30 +02:00
|
|
|
|
[ -e "$batRep/$ibat/uevent" ] || batt_detail="$ibat: **uevent** incorrect"
|
|
|
|
|
[ -e "$batRep/$ibat/uevent" ] || continue
|
|
|
|
|
uevent="$(grep -s . $batRep/$ibat/uevent)"
|
2017-10-14 17:54:16 +02:00
|
|
|
|
# extractions valeur de calcul selon type
|
|
|
|
|
if grep -q 'POWER_SUPPLY_CHARGE_' <<< $uevent ; then
|
|
|
|
|
batt_unit="mAh"
|
|
|
|
|
batt_capa_design="$(gawk -F '=' '/POWER_SUPPLY_CHARGE_FULL_DESIGN=/ {printf "%d", $2/1000}' <<< $uevent)" # mA
|
|
|
|
|
batt_capa_full="$(gawk -F '=' '/POWER_SUPPLY_CHARGE_FULL=/ {printf "%d", $2/1000}' <<< $uevent)" # mA
|
|
|
|
|
batt_capa_now="$(gawk -F '=' '/POWER_SUPPLY_CHARGE_NOW=/ {printf "%d", $2/1000}' <<< $uevent)" # mA
|
|
|
|
|
batt_conso="$(gawk -F '=' '/POWER_SUPPLY_CURRENT_NOW=/ {printf "%d", $2/1000}' <<< $uevent)" # mA
|
|
|
|
|
elif grep -q 'POWER_SUPPLY_ENERGY_' <<< $uevent ; then
|
2017-10-25 10:03:56 +02:00
|
|
|
|
batt_unit="Wh"
|
2017-10-25 10:23:24 +02:00
|
|
|
|
batt_capa_design="$(gawk -F '=' '/POWER_SUPPLY_ENERGY_FULL_DESIGN=/ {printf "%.2f", $2/1000000}' <<< $uevent)" # W
|
|
|
|
|
batt_capa_full="$(gawk -F '=' '/POWER_SUPPLY_ENERGY_FULL=/ {printf "%.2f", $2/1000000}' <<< $uevent)" # W
|
|
|
|
|
batt_capa_now="$(gawk -F '=' '/POWER_SUPPLY_ENERGY_NOW=/ {printf "%.2f", $2/1000000}' <<< $uevent)" # W
|
|
|
|
|
batt_conso="$(gawk -F '=' '/POWER_SUPPLY_POWER_NOW=/ {printf "%.2f", $2/1000000}' <<< $uevent)" # W
|
2017-10-14 17:54:16 +02:00
|
|
|
|
fi
|
|
|
|
|
# extractions simples
|
|
|
|
|
batt_volt_min="$(gawk -F '=' '/POWER_SUPPLY_VOLTAGE_MIN_DESIGN=/ {printf "%.2f", $2/1000000}' <<< $uevent)" # V
|
|
|
|
|
batt_volt_now="$(gawk -F '=' '/POWER_SUPPLY_VOLTAGE_NOW=/ {printf "%.2f", $2/1000000}' <<< $uevent)" # V
|
|
|
|
|
batt_status="$(gawk -F '=' '/POWER_SUPPLY_STATUS=/ {print $2}' <<< $uevent)"
|
|
|
|
|
batt_cycle="$(gawk -F '=' '/POWER_SUPPLY_CYCLE_COUNT=/ {print $2}' <<< $uevent)"
|
2017-10-28 23:42:15 +02:00
|
|
|
|
batt_sn="$(gawk -F '=' '/POWER_SUPPLY_SERIAL_NUMBER=/ {sub(/^ | $|0/,"",$2); print $2}' <<< $uevent)"
|
2017-10-14 17:54:16 +02:00
|
|
|
|
alert_batt_alarm="$(cat $batRep/$ibat/alarm 2>/dev/null)"
|
|
|
|
|
[ "$alert_batt_alarm" == "0" ] && unset alert_batt_alarm || alert_batt_alarm="$ibat: $alert_batt_alarm"
|
|
|
|
|
# calculs
|
2017-10-27 14:59:30 +02:00
|
|
|
|
batt_sante="$(gawk '$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: "
|
2017-10-27 14:59:30 +02:00
|
|
|
|
tempo="$(gawk '$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: "
|
2017-10-27 14:59:30 +02:00
|
|
|
|
tempo="$(gawk '$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
|
|
|
|
|
batt_restant+="$(gawk '$1 != "" {printf "%d h %02d mn \n", $1, $1*60%60}' <<< $tempo) "
|
|
|
|
|
# mise en forme pour sortie, séparateur milliers
|
2017-10-25 10:23:24 +02:00
|
|
|
|
if [ "$batt_unit" == "mAh" ]; then
|
|
|
|
|
batt_capa_design="$(printf "%'d" $batt_capa_design)"
|
|
|
|
|
batt_capa_full="$(printf "%'d" $batt_capa_full)"
|
|
|
|
|
batt_conso="$(printf "%'d" $batt_conso)"
|
|
|
|
|
fi
|
2017-10-26 19:31:32 +02:00
|
|
|
|
# sortie
|
2017-10-14 17:54:16 +02:00
|
|
|
|
batt_detail+="$ibat: $(cat $batRep/$ibat/manufacturer 2>/dev/null) "
|
2017-10-31 09:10:14 +01:00
|
|
|
|
batt_detail+="($(cat $batRep/$ibat/model_name 2>/dev/null)) $(cat $batRep/$ibat/technology 2>/dev/null), "
|
2017-10-17 20:54:05 +02:00
|
|
|
|
batt_detail+="$batt_capa_design$batt_unit - $batt_volt_min""V / $batt_volt_now""V (mini/actuel) "
|
2017-10-27 14:59:30 +02:00
|
|
|
|
[ "$(xargs <<< $batt_sn)" ] && batt_detail+="n° série: $batt_sn"
|
2017-10-26 00:40:16 +02:00
|
|
|
|
[ "$batt_cycle" != "0" ] && batt_detail+="$batt_cycle cycles"$'\n' || batt_detail+=$'\n' #ln 1fin
|
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
|
2017-10-25 10:23:24 +02:00
|
|
|
|
if [ "$batt_unit" == "mAh" ]; then
|
|
|
|
|
batt_restant+="(consommation en cours: $(printf "%'d" $batt_conso)$(sed 's/h//' <<< $batt_unit), "
|
2017-11-01 12:55:53 +01:00
|
|
|
|
[ "$?" -ne 0 ] && debugBatt="todo"
|
2017-10-25 10:23:24 +02:00
|
|
|
|
batt_restant+="charge actuelle: $(printf "%'d" $batt_capa_now)$batt_unit)"
|
2017-11-01 12:55:53 +01:00
|
|
|
|
[ "$?" -ne 0 ] && debugBatt="todo"
|
2017-10-25 10:23:24 +02:00
|
|
|
|
else
|
|
|
|
|
batt_restant+="(consommation en cours: $(printf "%s" $batt_conso)$(sed 's/h//' <<< $batt_unit), "
|
2017-11-01 12:55:53 +01:00
|
|
|
|
[ "$?" -ne 0 ] && debugBatt="todo"
|
2017-10-25 10:23:24 +02:00
|
|
|
|
batt_restant+="charge actuelle: $(printf "%s" $batt_capa_now)$batt_unit)"
|
2017-11-01 12:55:53 +01:00
|
|
|
|
[ "$?" -ne 0 ] && debugBatt="todo"
|
2017-10-25 10:23:24 +02:00
|
|
|
|
fi
|
2017-11-01 12:55:53 +01:00
|
|
|
|
[ "debugBatt" ] && debugBatt="batt_conso:$batt_conso - batt_capa_now:$batt_capa_now"
|
2017-10-14 17:54:16 +02:00
|
|
|
|
fi
|
2017-10-26 00:40:16 +02:00
|
|
|
|
[ "$batt_sante" ] && batt_detail+="$batt_sante% (indicateur)"$'\n' #ln 2fin
|
|
|
|
|
[ "$batt_restant" ] && batt_detail+="$batt_restant"$'\n' #ln 3fin
|
2017-10-14 17:54:16 +02:00
|
|
|
|
# alertes batterie
|
2017-10-26 00:40:16 +02:00
|
|
|
|
[ "$alert_batt_alarm" ] && batt_detail+="**batterie en alarme** $alert_batt_alarm "$'\n' #[ln 4]
|
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-10-26 00:40:16 +02:00
|
|
|
|
batt_detail+="mal gérée ou batterie HS?"$'\n' #[ln 5]
|
2017-10-14 17:54:16 +02:00
|
|
|
|
fi
|
2017-10-15 00:33:34 +02:00
|
|
|
|
if [ "$(awk '{printf "%d", $1}' <<< $batt_sante)" -lt 50 ] && [[ "$batt_status" == "Full" || "$batt_status" == "Unknown" ]]; then
|
2017-10-26 00:40:16 +02:00
|
|
|
|
batt_detail+="batterie très mal chargée (moins de 50%): mauvais état?"$'\n' #[ln 5]
|
2017-10-14 17:54:16 +02:00
|
|
|
|
fi
|
|
|
|
|
done
|
2017-10-27 14:59:30 +02:00
|
|
|
|
fg_nb_batt="$batt_nb"
|
2017-11-01 07:45:18 +01:00
|
|
|
|
[ "$batt_detail" ] && fg_batt=${batt_detail::-1} # suppression dernier $'\n'
|
2017-08-26 09:05:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-02 08:40:41 +01:00
|
|
|
|
# assigne $fg_cpu (3 lignes description cpu), fg_nb_threads, $fg_cpu_arch, $fg_uarch
|
2017-11-03 11:28:45 +01:00
|
|
|
|
figet_cpu(){ #v2 03/11/2017
|
2017-11-02 05:22:23 +01:00
|
|
|
|
local cpuinfo speedNom speedMax speedMin speedCpu cpu1 cpu2 cpu3 var_temp vendor family model
|
2017-11-02 08:40:41 +01:00
|
|
|
|
local defaut_model="modèle non répertorié" defaut_family="famille non répertoriée"
|
2017-11-03 11:28:45 +01:00
|
|
|
|
local defaut_vendor="fabricant non répertorié"
|
2017-10-22 06:45:56 +02:00
|
|
|
|
cpuinfo="$(cat /proc/cpuinfo)"
|
|
|
|
|
# speed
|
|
|
|
|
speedNom=$(gawk -F ':' '/cpu MHz/ {printf "%.2f", $2/1000;exit}' <<< "$cpuinfo")
|
|
|
|
|
speedMax=$(gawk '{printf "%.2f", $1/1000000}' /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq 2>/dev/null)
|
|
|
|
|
speedMin=$(gawk '{printf "%.2f", $1/1000000}' /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq 2>/dev/null)
|
|
|
|
|
speedCpu=""
|
|
|
|
|
[ "$speedMin" ] && speedCpu+="$speedMin/"
|
|
|
|
|
[ "$speedNom" ] && speedCpu+="$speedNom"
|
|
|
|
|
[[ "$speedMax" && "$speedMax" != "$speedNom" ]] && speedCpu+="/$speedMax"
|
|
|
|
|
[ "$speedCpu" ] && speedCpu=$(printf "%sGHz" $speedCpu)
|
|
|
|
|
[ "$speedCpu" ] || speedCpu=$(gawk -F '@' '/model name/ {sub(/^ | $/,"",$2); print $2;exit}' <<< "$cpuinfo")
|
2017-11-02 05:22:23 +01:00
|
|
|
|
# motifs?: Processor Dual-Core Quad-Core Six-Core Eight-Core Core 'with Radeon * Graphics'
|
|
|
|
|
# traitement fg_cpu
|
2017-10-22 06:45:56 +02:00
|
|
|
|
cpu1=$(
|
|
|
|
|
gawk -v "speedCpu=$speedCpu" -F ':|@' '
|
|
|
|
|
/^model name/ { gsub(/^ | *$|\(R\)|\(TM\)|\(r\)|\(tm\)|CPU/,"",$2); gsub(/ /," ",$2); cpu=$2 }
|
|
|
|
|
/^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" }
|
|
|
|
|
/microcode/ { sub(/^ /,"",$2); microCode=$2 }
|
2017-11-03 11:28:45 +01:00
|
|
|
|
END {
|
|
|
|
|
printf nbCpu" x "cpu " (" procCore "core" pllc ", " procThread "thread" pllt;
|
|
|
|
|
print ") {" speedCpu "} microcode:" microCode
|
|
|
|
|
}' <<< "$cpuinfo "
|
2017-10-22 06:45:56 +02:00
|
|
|
|
)
|
|
|
|
|
cpu2=$(
|
|
|
|
|
gawk -F ':' '
|
2017-11-03 11:28:45 +01:00
|
|
|
|
/^vendor_id/{gsub(/ /,"",$2);vendor=$2}
|
|
|
|
|
/^cpu family/{family=$2}
|
2017-10-22 06:45:56 +02:00
|
|
|
|
/^model[^ ]/{model=$2}; /^stepping/{rev=$2}
|
2017-11-03 11:28:45 +01:00
|
|
|
|
END {
|
|
|
|
|
code=sprintf("{0x%.2X|0x%.2X}",family,model);
|
|
|
|
|
print "{fréq. mini/nominale/maxi} " vendor" famille" family", modèle"model,code", révision" rev
|
|
|
|
|
}' <<< "$cpuinfo"
|
2017-10-22 06:45:56 +02:00
|
|
|
|
)
|
|
|
|
|
cpu3=$(
|
|
|
|
|
gawk -F ':' '
|
|
|
|
|
/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
|
|
|
|
)
|
2017-10-31 09:10:14 +01:00
|
|
|
|
fg_cpu=$(echo -e "$cpu1\n$cpu2\n$cpu3")
|
|
|
|
|
fg_nb_threads=$(grep -c '^processor' <<< $cpuinfo)
|
2017-11-02 05:22:23 +01:00
|
|
|
|
# arch processeur
|
2017-10-31 12:12:03 +01:00
|
|
|
|
[ $(grep -cm1 'flags.* lm ' /proc/cpuinfo) -ge 1 ] && fg_cpu_arch="64bits" || fg_cpu_arch="32bits"
|
2017-11-02 05:22:23 +01:00
|
|
|
|
# traitement µarchitecture
|
2017-11-02 08:40:41 +01:00
|
|
|
|
vendor=$(grep -m1 '^vendor_id' /proc/cpuinfo) # vendor cpuinfo
|
|
|
|
|
vendor=${vendor#*: } # extraction valeur vendor
|
2017-11-02 05:22:23 +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
|
|
|
|
|
family=$(printf "%.2X" $var_temp) # conversion hexa family
|
|
|
|
|
var_temp=$(grep -m1 '^model' /proc/cpuinfo) # model cpuinfo
|
|
|
|
|
var_temp=${var_temp#*: } # extraction valeur model
|
|
|
|
|
model=$(printf "%.2X" $var_temp) # conversion hexa model
|
2017-11-03 11:28:45 +01:00
|
|
|
|
{
|
2017-11-02 05:22:23 +01:00
|
|
|
|
case ${vendor,,} in
|
|
|
|
|
*intel*)
|
|
|
|
|
case $family in
|
2017-11-02 08:40:41 +01:00
|
|
|
|
04) fg_uarch="Intel 80486";;
|
|
|
|
|
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-02 08:40:41 +01:00
|
|
|
|
26 | 1C) fg_uarch="Intel Atom Bonnell 45nm";;
|
|
|
|
|
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 ;;
|
|
|
|
|
*) fg_uarch="AMD $defaut_family";;
|
|
|
|
|
esac ;;
|
|
|
|
|
*) 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-10-31 09:10:14 +01:00
|
|
|
|
figet_de(){ # thanks neofetch, assigne $fg_de #30/10/2017
|
|
|
|
|
fg_de="n/a (ssh)"
|
|
|
|
|
[ "$ENV_SSH" ] && return 0 || fg_de="n/a"
|
|
|
|
|
[ "$(f__cmd_exist xprop)" ] || return 0
|
2017-10-31 06:52:36 +01:00
|
|
|
|
local de="n/a"
|
|
|
|
|
de="$XDG_CURRENT_DESKTOP"
|
2017-08-26 09:05:54 +02:00
|
|
|
|
de="${de/'X-'}"
|
|
|
|
|
de="${de/Budgie:GNOME/Budgie}"
|
|
|
|
|
# Fallback to using xprop.
|
2017-10-31 06:52:36 +01:00
|
|
|
|
if [[ -n "$DISPLAY" && "$de" == "n/a" ]]; then
|
2017-10-09 20:19:07 +02:00
|
|
|
|
de="$(xprop -root | gawk '/KDE_SESSION_VERSION|^_MUFFIN|xfce4|xfce5|TDE_FULL_SESSION/')" #ajout TDE_FULL_SESSION, oubli?à tester
|
2017-10-02 15:34:29 +02:00
|
|
|
|
fi
|
2017-08-26 09:05:54 +02:00
|
|
|
|
# Format strings
|
|
|
|
|
case "$de" in
|
2017-10-02 15:34:29 +02:00
|
|
|
|
"KDE_SESSION_VERSION"* )
|
|
|
|
|
de="KDE${de/* = }"
|
|
|
|
|
;;
|
|
|
|
|
*"TDE_FULL_SESSION"* )
|
|
|
|
|
de="Trinity"
|
|
|
|
|
;;
|
|
|
|
|
*"MUFFIN"* | "Cinnamon" )
|
|
|
|
|
de="$(cinnamon --version)"
|
|
|
|
|
de="${de:-Cinnamon}"
|
|
|
|
|
;;
|
2017-10-04 10:29:08 +02:00
|
|
|
|
*"xfce"*)
|
|
|
|
|
de="xfce" # suppression xfce4 ou xfce5 (la version ne sort pas dans xprop ou $XDG_
|
2017-10-02 15:34:29 +02:00
|
|
|
|
;;
|
2017-08-26 09:05:54 +02:00
|
|
|
|
esac
|
2017-10-31 09:10:14 +01:00
|
|
|
|
fg_de="${de,,}" # minuscule
|
|
|
|
|
fg_de="${fg_de^}" # car 1 en majuscule
|
2017-08-26 09:05:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-29 07:39:51 +01:00
|
|
|
|
# $fg_nb_disk : nb disk fixe & amovible, $fg_disk_table : tableau sommaire
|
|
|
|
|
# $fg_disk_fixe : liste devices block fixes, $fg_disk_amov : liste devices block amovibles
|
|
|
|
|
# $fg_disk_part_fix_tot : espace des partitions fixes montées
|
|
|
|
|
# $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
|
2017-11-01 07:45:18 +01:00
|
|
|
|
figet_disk(){ #v2 31/10/2017
|
2017-10-20 03:10:56 +02:00
|
|
|
|
local size type vendor_model serial_rev list_id idisk lsblk
|
2017-10-29 07:39:51 +01:00
|
|
|
|
unset fg_disk_fixe fg_disk_amov
|
|
|
|
|
# $fg_disk_table: tableau sommaire des disques
|
2017-10-28 15:06:37 +02:00
|
|
|
|
# disk taille type vendeur modèle n° série révision
|
|
|
|
|
# sda 149,1G Fixe ATA Hitachi HTS54321 090620FB02015CD5N3XA C40C
|
2017-10-29 07:39:51 +01:00
|
|
|
|
fg_disk_table="$(printf '%-5s %-8s %-6s %-24s %-26s' "disk" "taille" "type" "vendeur modèle" " n° série révision")"$'\n'
|
2017-09-27 20:40:28 +02:00
|
|
|
|
for idisk in $(grep -v 'loop' <<< $(ls /sys/block/)); do
|
2017-10-28 15:06:37 +02:00
|
|
|
|
size="$( lsblk -no SIZE -d /dev/$idisk | xargs )" #149,1G
|
|
|
|
|
type="$( sed -n '2p' <<< $(lsblk -no HOTPLUG /dev/$idisk) | xargs )" # 0 \n 0 \n ...
|
2017-10-19 01:02:41 +02:00
|
|
|
|
[ "$type" == "0" ] && type="Fixe" || type="Amov"
|
2017-10-28 15:06:37 +02:00
|
|
|
|
vendor_model="$( lsblk -no VENDOR,MODEL /dev/$idisk | xargs )" # sda ATA Hitachi HTS54321 \n \n \n ...
|
2017-10-29 07:39:51 +01:00
|
|
|
|
if [ -z "$vendor_model" ]; then
|
2017-10-28 15:06:37 +02:00
|
|
|
|
vendor_model=" na na"
|
2017-10-29 07:39:51 +01:00
|
|
|
|
vendor_model="$(ls -l /dev/disk/by-id/ | gawk ' !/-part/ && !/wwn-/ {print $9,$11}' | xargs )"
|
2017-10-02 00:34:34 +02:00
|
|
|
|
vendor_model="$(sed -E 's/.*-(.*)_[0-9]+.*$/\1/;s/_/ /g' <<< $vendor_model)"
|
|
|
|
|
fi
|
2017-10-28 15:06:37 +02:00
|
|
|
|
serial_rev="$( lsblk -no SERIAL,REV /dev/$idisk | xargs )" # 090620FB02015CD5N3XA C40C \n \n \n ...
|
2017-10-29 07:39:51 +01:00
|
|
|
|
fg_disk_table+="$(printf '%-5s %-8s %-6s %-24s %-26s' "$idisk" "$size" "$type" "$vendor_model" "$serial_rev")"$'\n'
|
2017-10-28 15:06:37 +02:00
|
|
|
|
# liste disques fixes ou amovibles
|
2017-10-18 11:03:03 +02:00
|
|
|
|
if [ "$(lsblk -no HOTPLUG /dev/$idisk | xargs | cut -d' ' -f2)" == "0" ]; then
|
2017-10-29 07:39:51 +01:00
|
|
|
|
fg_disk_fixe+="$idisk " # "sda sdb ..."
|
2017-09-27 20:40:28 +02:00
|
|
|
|
else
|
2017-10-29 07:39:51 +01:00
|
|
|
|
fg_disk_amov+="$idisk "
|
2017-09-27 20:40:28 +02:00
|
|
|
|
fi
|
|
|
|
|
done
|
2017-11-01 07:45:18 +01:00
|
|
|
|
[ "$fg_disk_table" ] && fg_disk_table=${fg_disk_table::-1} # suppression dernier $'\n'
|
2017-10-28 15:06:37 +02:00
|
|
|
|
# nb de disques (fixe+amovible), peut servir d'indicateur fonction déja appelée
|
2017-10-29 07:39:51 +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)
|
2017-10-29 07:39:51 +01:00
|
|
|
|
lsblk="$(lsblk -no KNAME,MOUNTPOINT $(printf '/dev/%s ' $fg_disk_fixe) 2>/dev/null)"
|
|
|
|
|
fg_disk_part_fixe_m="$(echo "$lsblk" | gawk '/\// {print $1}' | tr '\n' ' ')"
|
|
|
|
|
fg_disk_part_fixe_nm="$(echo "$lsblk" | gawk '!/\// && /[0-9]+/ && !/\[SWAP\]/{print $1}' | tr '\n' ' ')"
|
2017-10-19 01:02:41 +02:00
|
|
|
|
# séquences partitions amovibles, montées (m) et non montées (nm)
|
2017-10-29 07:39:51 +01:00
|
|
|
|
lsblk="$(lsblk -no KNAME,MOUNTPOINT $(printf '/dev/%s ' $fg_disk_amov) 2>/dev/null)"
|
|
|
|
|
fg_disk_part_amov_m="$(echo "$lsblk" | gawk '/\// {print $1}' | tr '\n' ' ')"
|
|
|
|
|
fg_disk_part_amov_nm="$(echo "$lsblk" | gawk '!/\// && /[0-9]+/ && !/\[SWAP\]/{print $1}' | tr '\n' ' ')"
|
2017-10-20 03:10:56 +02:00
|
|
|
|
# partitions swap
|
2017-10-29 07:39:51 +01:00
|
|
|
|
fg_disk_part_swap="$(echo "$(lsblk -no KNAME,MOUNTPOINT)" | gawk '/\[SWAP\]/ {print $1}' | tr '\n' ' ')"
|
|
|
|
|
[ "$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-10-29 07:39:51 +01:00
|
|
|
|
fg_disk_part_fix_tot="espace des partitions fixes montées (total, utilisé, dispo): "
|
|
|
|
|
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 | xargs)"
|
|
|
|
|
fg_disk_part_fix_tot="$(sed 's/G/Go/g; s/M/Mo/g; s/K/ko/g' <<< $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"
|
2017-10-19 01:02:41 +02:00
|
|
|
|
# liste des disques par type
|
2017-10-14 17:54:16 +02:00
|
|
|
|
list_id="$(ls -l /dev/disk/by-id/ | gawk '{print $9,$11}')"
|
2017-10-29 07:39:51 +01:00
|
|
|
|
fg_disk_ata="$(sed '/^ata/!d; /part/d' <<< $list_id | awk -F '/' '{print $NF}' | tr '\n' ' ')"
|
|
|
|
|
fg_disk_usb="$(sed -n '/part/d; /^usb/p' <<< $list_id | awk -F '/' '{print $NF}' | tr '\n' ' ')"
|
|
|
|
|
# fg_disk_mmc="$(sed '/^mmc/!d; /part/d; /\/mmcblk/!d; s/^.*\(mmcblk..*\)$/\1/' <<< $list_id | tr '\n' ' ')"
|
|
|
|
|
fg_disk_mmc="$(sed '/^mmc/!d; /part/d' <<< $list_id | awk -F '/' '{print $NF}' | tr '\n' ' ')"
|
|
|
|
|
fg_disk_nvme="$(sed '/^nvme/!d; /part/d' <<< $list_id | awk -F '/' '{print $NF}' | tr '\n' ' ')"
|
|
|
|
|
[ "$fg_disk_ata" ] || fg_disk_ata="-" && fg_disk_ata="$(tr ' ' '\n' <<< "$fg_disk_ata" | sort | tr '\n' ' ')"
|
|
|
|
|
[ "$fg_disk_usb" ] || fg_disk_usb="-" && fg_disk_usb="$(tr ' ' '\n' <<< "$fg_disk_usb" | sort | tr '\n' ' ')"
|
|
|
|
|
[ "$fg_disk_mmc" ] || fg_disk_mmc="-" && fg_disk_mmc="$(tr ' ' '\n' <<< "$fg_disk_mmc" | sort | tr '\n' ' ')"
|
|
|
|
|
[ "$fg_disk_nvme" ] || fg_disk_nvme="-" && fg_disk_nvme="$(tr ' ' '\n' <<< "$fg_disk_nvme" | sort | tr '\n' ' ')"
|
2017-08-26 09:05:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-29 03:19:47 +01:00
|
|
|
|
# assigne $fg_distrib
|
2017-11-01 12:55:53 +01:00
|
|
|
|
figet_distrib(){ # 01/11/2017
|
2017-10-29 03:19:47 +01:00
|
|
|
|
local prefix version
|
|
|
|
|
# priorité /etc/os-release, version officielle systemd
|
|
|
|
|
[ -e "/etc/os-release" ] && source "/etc/os-release" || source "/usr/lib/os-release"
|
|
|
|
|
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
|
|
|
|
|
version=$(cat /etc/*version 2>/dev/null) # fichier *version?
|
|
|
|
|
[[ $version =~ [0-9.]+ ]] || unset version # qui contient des chiffres
|
|
|
|
|
# essai lsb_release, antique méthode
|
|
|
|
|
[ "$fg_distrib" ] && [[ $(grep -is 'chrome-' /proc/version) || -f "/dev/cros_ec" ]] && fg_distrib="$(lsb_release -sd 2>/dev/null)/xhrome-os"
|
|
|
|
|
[ "$fg_distrib" ] && [ $(grep -is 'microsoft' /proc/version) ] && fg_distrib="$(lsb_release -sd 2>/dev/null)/windows"
|
|
|
|
|
[ "$fg_distrib" ] || fg_distrib=$(lsb_release -sd 2>/dev/null)
|
2017-10-29 03:54:14 +01:00
|
|
|
|
# prefix sur nom fichier éventuels *[_-][version|release]
|
2017-10-29 03:19:47 +01:00
|
|
|
|
[ "$prefix" ] || prefix=$(ls /etc/*_version 2>/dev/null | sed -En 's#/etc/(.*)_version#\1#p')
|
|
|
|
|
[ "$prefix" ] || prefix=$(ls /etc/*-version 2>/dev/null | sed -En 's#/etc/(.*)-version#\1#p')
|
|
|
|
|
[ "$prefix" ] || prefix=$(ls /etc/*-release 2>/dev/null | grep -v 'os-release' | sed -En 's#/etc/(.*)-release#\1#p')
|
|
|
|
|
# spécial complément
|
|
|
|
|
[ "$prefix" == "redstar" ] && prefix="Red Star OS"
|
|
|
|
|
[ "$prefix" ] && prefix=${prefix^} # 1er caractère majuscule
|
|
|
|
|
# final
|
|
|
|
|
if [[ "$fg_distrib" && ! "$fg_distrib" =~ $prefix ]]; then # si fg_distrib et ne contient pas prefix
|
2017-10-29 03:54:14 +01:00
|
|
|
|
fg_distrib="$prefix - $fg_distrib $(xargs <<< $version)"
|
2017-10-29 03:19:47 +01:00
|
|
|
|
elif [ -z "$fg_distrib" ] && [ "$prefix" ]; then # si fg_distrib vide et si prefix
|
2017-10-29 03:54:14 +01:00
|
|
|
|
fg_distrib="$prefix $(xargs <<< $version)"
|
2017-08-26 09:05:54 +02:00
|
|
|
|
else
|
2017-11-01 12:55:53 +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-10-29 03:19:47 +01:00
|
|
|
|
[ "$fg_distrib" ] || fg_distrib="${OS^} (indéterminé)"
|
2017-08-06 02:43:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 09:10:14 +01:00
|
|
|
|
# informations DMI, (firmware partie matériel), assigne $fg_dmi
|
|
|
|
|
figet_dmi(){ # 30/10/2017
|
2017-10-24 21:35:26 +02:00
|
|
|
|
# lors révision tester $(grep -s . /sys/class/dmi/id/*)
|
|
|
|
|
# ex: /sys/class/dmi/id/bios_vendor:American Megatrends Inc.
|
2017-10-12 08:45:16 +02:00
|
|
|
|
local product board bios tempo idmi indic1 indic2
|
|
|
|
|
unset indic1 indic2
|
2017-10-28 19:59:06 +02:00
|
|
|
|
# ligne1 Pc/produit
|
2017-10-12 08:45:16 +02:00
|
|
|
|
for idmi in sys_vendor product_name product_version chassis_type; do
|
|
|
|
|
tempo=$(cat /sys/class/dmi/id/$idmi 2>/dev/null)
|
2017-10-24 21:35:26 +02:00
|
|
|
|
tempo=$(sed 's/x.xx*//; s/To be filled by O\.E\.M\.//g' <<< $tempo | xargs)
|
2017-10-12 08:45:16 +02:00
|
|
|
|
if [ "$idmi" == "chassis_type" ]; then
|
|
|
|
|
[ "$tempo" == "10" ] && tempo="(Notebook)" || tempo="($tempo)"
|
|
|
|
|
fi
|
2017-10-28 19:59:06 +02:00
|
|
|
|
# indic1 pour tester égalité avec board
|
2017-10-12 08:45:16 +02:00
|
|
|
|
[[ "$idmi" == "sys_vendor" || "$idmi" == "product_name" ]] && indic1+="$tempo "
|
2017-10-28 19:59:06 +02:00
|
|
|
|
product+="$tempo "
|
2017-10-12 08:45:16 +02:00
|
|
|
|
done
|
2017-10-28 19:59:06 +02:00
|
|
|
|
# ligne2 carte mère
|
2017-10-12 08:45:16 +02:00
|
|
|
|
for idmi in board_vendor board_name board_version; do
|
|
|
|
|
tempo=$(cat /sys/class/dmi/id/$idmi 2>/dev/null)
|
2017-10-24 21:35:26 +02:00
|
|
|
|
tempo=$(sed 's/x.xx*//; s/To be filled by O\.E\.M\.//g' <<< $tempo | xargs)
|
2017-10-28 19:59:06 +02:00
|
|
|
|
# indic2 pour tester égalité avec product
|
2017-10-12 08:45:16 +02:00
|
|
|
|
[[ "$idmi" == "board_vendor" || "$idmi" == "board_name" ]] && indic2+="$tempo "
|
2017-10-28 19:59:06 +02:00
|
|
|
|
board+="$tempo "
|
2017-10-12 08:45:16 +02:00
|
|
|
|
done
|
2017-10-28 19:59:06 +02:00
|
|
|
|
# ligne3 bios
|
2017-10-12 08:45:16 +02:00
|
|
|
|
for idmi in bios_vendor bios_version bios_date; do
|
|
|
|
|
tempo=$(cat /sys/class/dmi/id/$idmi 2>/dev/null)
|
2017-10-24 21:35:26 +02:00
|
|
|
|
tempo=$(sed 's/x.xx*//; s/To be filled by O\.E\.M\.//g' <<< $tempo | xargs)
|
2017-10-28 19:59:06 +02:00
|
|
|
|
bios+="$tempo "
|
2017-10-12 08:45:16 +02:00
|
|
|
|
done
|
2017-10-31 09:10:14 +01:00
|
|
|
|
fg_dmi=$(printf '%7s: %s' "produit" "$product")$'\n'
|
|
|
|
|
[ "$indic1" != "$indic2" ] && fg_dmi+=$(printf '%7s: %s' "board" "$board")$'\n'
|
|
|
|
|
fg_dmi+=$(printf '%7s: %s' "bios" "$bios")
|
2017-10-29 22:02:01 +01:00
|
|
|
|
# chassis, pas utilisé
|
2017-10-13 21:58:51 +02:00
|
|
|
|
# for idmi in chassis_vendor chassis_version chassis_type; do
|
|
|
|
|
# tempo=$(cat /sys/class/dmi/id/$idmi 2>/dev/null)
|
|
|
|
|
# tempo=$(sed 's/x.xx*//' <<< $tempo)
|
|
|
|
|
# [[ "$idmi" == "chassis_type" && "$tempo" == "10" ]] && tempo="Notebook"
|
|
|
|
|
# chassis+="$tempo "
|
|
|
|
|
# done
|
2017-10-12 08:45:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-01 07:45:18 +01:00
|
|
|
|
# assigne $fg_gpu, $fg_nb_gpu peut retourner "n/a"/-1
|
2017-10-31 12:12:03 +01:00
|
|
|
|
figet_gpu(){ # 31/10/2017
|
2017-11-01 07:45:18 +01:00
|
|
|
|
fg_gpu="lspci -mm non disponible" fg_nb_gpu=-1
|
2017-10-30 07:41:12 +01:00
|
|
|
|
local lspci="$(lspci -mm)"
|
2017-11-01 07:45:18 +01:00
|
|
|
|
[ "$?" -gt 0 ] && return 1
|
2017-10-30 10:50:22 +01:00
|
|
|
|
# debug: lspci="$(< tests/lspci)"
|
2017-10-30 07:41:12 +01:00
|
|
|
|
fg_gpu="$(gawk -F' "|" "|" -' ' /"Display|"3D|"VGA/ {
|
|
|
|
|
sub(/ Corporation/,"",$3); sub(/Advanced Micro Devices, Inc. /,"",$3); sub(/ /," ",$3);
|
|
|
|
|
print $3": "$4}' <<< $lspci)"
|
2017-11-01 07:45:18 +01:00
|
|
|
|
fg_nb_gpu=$(f__wcv -l "$fg_gpu")
|
2017-08-26 09:05:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 09:10:14 +01:00
|
|
|
|
# infos température et fan via acpi, assigne $fg_hw
|
2017-11-01 07:45:18 +01:00
|
|
|
|
figet_hw(){ #v2 31/10/2017
|
2017-10-20 18:39:46 +02:00
|
|
|
|
local name labelF inputF labelT inputT critT hystT maxiT fan temp ihw
|
|
|
|
|
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
|
2017-10-20 18:39:46 +02:00
|
|
|
|
unset fan temp
|
2017-10-12 21:49:57 +02:00
|
|
|
|
for ihw in $(ls /sys/class/hwmon/); do
|
2017-10-20 18:39:46 +02:00
|
|
|
|
[ -e /sys/class/hwmon/$ihw/name ] && name="$(cat /sys/class/hwmon/$ihw/name)" || name="indéfini"
|
2017-10-21 06:54:22 +02:00
|
|
|
|
## TEMPÉRATURE
|
2017-10-14 17:54:16 +02:00
|
|
|
|
if grep -Eq 'temp[0-9]+' <<< $(ls /sys/class/hwmon/$ihw/) ; then
|
2017-10-20 18:39:46 +02:00
|
|
|
|
# extraction label
|
2017-10-21 06:54:22 +02:00
|
|
|
|
# labelT=$(printf "%s/" "$(cat /sys/class/hwmon/$ihw/temp*_label 2>/dev/null)" | sed 's/ //g' | tr '\n' ' ')
|
|
|
|
|
labelT=$(printf "%s/" "$(cat /sys/class/hwmon/$ihw/temp*_label 2>/dev/null)" | tr ' ' '.' | tr '\n' ' ')
|
2017-10-20 18:39:46 +02:00
|
|
|
|
# extraction températures
|
|
|
|
|
inputT=$(gawk '$0!="" && $0!=0 {printf "%.1f/", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_input 2>/dev/null))
|
|
|
|
|
critT=$(gawk '$0!="" && $0!=0 {printf "%.1f/", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_crit 2>/dev/null))
|
|
|
|
|
hystT=$(gawk '$0!="" && $0!=0 {printf "%.1f/", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_crit_hyst 2>/dev/null))
|
|
|
|
|
maxiT=$(gawk '$0!="" && $0!=0 {printf "%.1f/", $1/1000}' <<< $(cat /sys/class/hwmon/$ihw/temp*_max 2>/dev/null))
|
|
|
|
|
# suppression doublons
|
|
|
|
|
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' '/')
|
|
|
|
|
# suppression premier /
|
2017-11-01 07:45:18 +01:00
|
|
|
|
critT=${critT#/} #[ ${critT:0:1} == "/" ] && critT=${critT:1}
|
|
|
|
|
hystT=${hystT#/} # suppression / en début de variable
|
|
|
|
|
maxiT=${maxiT#/}
|
2017-10-20 18:39:46 +02:00
|
|
|
|
# suppression dernier caractère (/) fin (nécessaire si multi-valeurs)
|
|
|
|
|
[ "$inputT" ] && inputT=${inputT::-1}
|
2017-10-21 06:54:22 +02:00
|
|
|
|
[ "$labelT" ] && labelT=${labelT::-1}
|
2017-10-20 18:39:46 +02:00
|
|
|
|
[ "$critT" ] && critT=${critT::-1}
|
|
|
|
|
[ "$hystT" ] && hystT=${hystT::-1}
|
|
|
|
|
[ "$maxiT" ] && maxiT=${maxiT::-1}
|
|
|
|
|
# formation affichage
|
2017-10-23 03:52:48 +02:00
|
|
|
|
if [ "$inputT" ]; then
|
|
|
|
|
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
|
2017-10-20 18:39:46 +02:00
|
|
|
|
if grep -Eq 'fan[0-9]+' <<< $(ls /sys/class/hwmon/$ihw/) ; then
|
|
|
|
|
# extraction label
|
|
|
|
|
labelF=$(printf "%s/" $(cat /sys/class/hwmon/$ihw/fan*_label 2>/dev/null))
|
2017-10-23 03:52:48 +02:00
|
|
|
|
# extraction vitesse fan, \047=' pour insérer séparateur de milliers
|
|
|
|
|
inputF=$(gawk '$0!="" && $0!=0 {printf "%\047d/", $1}' <<< $(cat /sys/class/hwmon/$ihw/fan*_input 2>/dev/null))
|
2017-10-20 18:39:46 +02:00
|
|
|
|
# suppression dernier caractère (/) fin (nécessaire si multi-valeurs)
|
|
|
|
|
[ "$labelF" ] && labelF=${labelF::-1}
|
|
|
|
|
[ "$inputF" ] && inputF=${inputF::-1}
|
|
|
|
|
# formation affichage
|
2017-10-23 03:52:48 +02:00
|
|
|
|
if [ "$inputF" ]; then
|
2017-10-26 00:40:16 +02:00
|
|
|
|
fan+="$(printf "%-8s %st/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"
|
|
|
|
|
[ "$fg_hw" ] && fg_hw=${fg_hw::-1}
|
2017-10-12 21:49:57 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-27 14:59:30 +02:00
|
|
|
|
# assigne $fg_ip, $fg_ip_tp, $fg_gws, $fg_gws_tp, $fg_ifn_prior, $fg_ifn, $fg_mac, fg_mac_tp
|
2017-11-01 07:45:18 +01:00
|
|
|
|
figet_ip(){ # 31/10/2017
|
2017-10-02 15:34:29 +02:00
|
|
|
|
local ifn
|
2017-10-22 11:14:21 +02:00
|
|
|
|
[ "$(f__cmd_exist ip)" ] || return 1
|
2017-10-27 14:59:30 +02:00
|
|
|
|
fg_ip="$(sed '/[[:digit:]]:[[:blank:]]lo.*inet/d; /inet6.*scope/d' <<< $(ip -o a) | gawk '{print " ",$4,"(",$2,")"}')"
|
|
|
|
|
fg_ip_tp="$(sed -E 's/(^.*wl.*)/\1 (wifi)/;s/(^.*en.*|^.*eth.*)/\1 (ethernet)/' <<< $fg_ip)"
|
|
|
|
|
fg_gws="$(LC_ALL=C ip -4 route | gawk '/default via/ {print " ",$3,"(",$5,")"}')"
|
|
|
|
|
fg_gws+="$(LC_ALL=C ip -6 route | gawk '/default via/ {print " ",$3,"(",$5,")"}')"
|
|
|
|
|
fg_gws_tp="$(sed -E 's/(^.*wl.*)/\1 (wifi)/;s/(^.*en.*|^.*eth.*)/\1 (ethernet)/' <<< $fg_gws)"
|
|
|
|
|
fg_ifn_prior="$(ip route get 255.255.255.255 | sed -nr 's/.*src ([0-9.]+).*/\1/p')"
|
2017-09-04 13:35:14 +02:00
|
|
|
|
for ifn in $(ls /sys/class/net/) ; do
|
2017-10-27 14:59:30 +02:00
|
|
|
|
[ "$ifn" != "lo" ] && fg_ifn+=" $ifn"$'\n'
|
|
|
|
|
[ "$ifn" != "lo" ] && fg_mac+=" $ifn: $(< /sys/class/net/$ifn/address)"$'\n'
|
2017-09-04 13:35:14 +02:00
|
|
|
|
done
|
2017-10-31 06:52:36 +01:00
|
|
|
|
fg_ifn="$(sed '/^[[:space:]]*$/d' <<< $fg_ifn)" # suppression lignes vides
|
|
|
|
|
fg_mac="$(sed '/^[[:space:]]*$/d' <<< $fg_mac)" # suppression lignes vides
|
2017-10-27 14:59:30 +02:00
|
|
|
|
fg_mac_tp="$(sed -E 's/(^.*wl.*)/\1 (wifi)/;s/(^.*en.*|^.*eth.*)/\1 (ethernet)/' <<< $fg_mac)"
|
2017-11-01 07:45:18 +01:00
|
|
|
|
[ "$fg_ifn" ] && fg_ifn=${fg_ifn::-1} # suppression dernier $'\n'
|
|
|
|
|
[ "$fg_mac" ] && fg_mac=${fg_mac::-1} # suppression dernier $'\n'
|
2017-08-26 09:05:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-27 14:59:30 +02:00
|
|
|
|
# $1=4|6, assigne $fg_public
|
|
|
|
|
figet_ip_pub(){ # 27/10/2017
|
2017-10-02 15:34:29 +02:00
|
|
|
|
local dig_test ip_test iip
|
2017-08-26 09:05:54 +02:00
|
|
|
|
list_ip4(){
|
|
|
|
|
ip_test+=" http://whatismyip.akamai.com"
|
|
|
|
|
ip_test+=" http://ipof.in/txt"
|
|
|
|
|
ip_test+=" http://eth0.me"
|
|
|
|
|
ip_test+=" http://ipecho.net/plain"
|
|
|
|
|
ip_test+=" http://alma.ch/myip.cgi"
|
|
|
|
|
ip_test+=" http://checkip.amazonaws.com"
|
|
|
|
|
ip_test+=" http://eth0.me"
|
|
|
|
|
ip_test+=" http://ipecho.net/plain"
|
|
|
|
|
ip_test+=" api.infoip.io/ip" # http & https
|
|
|
|
|
ip_test+=" api.ipify.org" # http & https
|
|
|
|
|
ip_test+=" ipinfo.io/ip" # http & https
|
|
|
|
|
}
|
|
|
|
|
list_ip6(){
|
|
|
|
|
ip_test+=" http://ipv6.whatismyip.akamai.com"
|
|
|
|
|
ip_test+=" http://bot.whatismyipaddress.com"
|
|
|
|
|
ip_test+=" ip.tyk.nu" # http & https
|
|
|
|
|
ip_test+=" l2.io/ip" # http & https
|
|
|
|
|
ip_test+=" ident.me" # http & https
|
|
|
|
|
ip_test+=" icanhazip.com" # http & https
|
|
|
|
|
ip_test+=" wgetip.com" # http & https
|
|
|
|
|
ip_test+=" https://canhazip.com"
|
|
|
|
|
ip_test+=" https://tnx.nl/ip"
|
|
|
|
|
}
|
|
|
|
|
list_ip4_dig(){
|
|
|
|
|
dig_test+=" whoami.akamai.net/@ns1-1.akamaitech.net"
|
|
|
|
|
dig_test+=" myip.opendns.com/@resolver1.opendns.com"
|
|
|
|
|
dig_test+=" myip.opendns.com/@resolver2.opendns.com"
|
|
|
|
|
dig_test+=" myip.opendns.com/@resolver3.opendns.com"
|
|
|
|
|
dig_test+=" myip.opendns.com/@resolver4.opendns.com"
|
|
|
|
|
}
|
|
|
|
|
list_ip6_dig(){
|
|
|
|
|
dig_test+=" -6/myip.opendns.com/aaaa/@resolver1.ipv6-sandbox.opendns.com"
|
|
|
|
|
dig_test+=" -6/myip.opendns.com/aaaa/@resolver2.ipv6-sandbox.opendns.com"
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-27 14:59:30 +02:00
|
|
|
|
unset fg_public
|
2017-09-03 09:37:47 +02:00
|
|
|
|
if [ "$1" == "4" ]; then
|
|
|
|
|
ping -4 -c1 google.com &>/dev/null || ping -4 -c1 free.fr &>/dev/null || return 1 # test connectivité
|
2017-08-26 09:05:54 +02:00
|
|
|
|
list_ip4_dig
|
|
|
|
|
list_ip4
|
|
|
|
|
ip_telnet=4.ifcfg.me
|
2017-09-03 09:37:47 +02:00
|
|
|
|
elif [ "$1" == "6" ]; then
|
|
|
|
|
ping -6 -c1 google.com &>/dev/null || ping -6 -c1 free.fr &>/dev/null || return 1 # test connectivité
|
2017-08-26 09:05:54 +02:00
|
|
|
|
list_ip6_dig
|
|
|
|
|
list_ip6
|
|
|
|
|
ip_telnet=6.ifcfg.me
|
2017-09-03 09:37:47 +02:00
|
|
|
|
fi
|
2017-08-26 09:05:54 +02:00
|
|
|
|
|
2017-10-27 14:59:30 +02:00
|
|
|
|
if [ "$(f__cmd_exist dig)" ] && [ -z "$fg_public" ]; then
|
2017-10-02 15:34:29 +02:00
|
|
|
|
for iip in $dig_test ; do
|
2017-10-27 14:59:30 +02:00
|
|
|
|
fg_public="$(dig +short $(sed 's;/; ;g' <<< $iip))"
|
|
|
|
|
[ "$fg_public" ] && break
|
2017-08-26 09:05:54 +02:00
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
|
2017-10-27 14:59:30 +02:00
|
|
|
|
if [ "$(f__cmd_exist wget)" ] && [ -z "$fg_public" ]; then
|
2017-10-17 18:33:12 +02:00
|
|
|
|
cmd="wget --quiet --timeout=5 -O - "
|
2017-10-02 15:34:29 +02:00
|
|
|
|
for iip in $ip_test ; do
|
2017-10-27 14:59:30 +02:00
|
|
|
|
fg_public="$($cmd $iip)"
|
|
|
|
|
[ "$fg_public" ] && break
|
2017-08-26 09:05:54 +02:00
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
|
2017-10-27 14:59:30 +02:00
|
|
|
|
if [ "$(f__cmd_exist curl)" ] && [ -z "$fg_public" ]; then
|
2017-08-26 09:05:54 +02:00
|
|
|
|
cmd="curl --silent --location --retry 0 --max-time 5" #--location pour aider redirections
|
2017-10-02 15:34:29 +02:00
|
|
|
|
for iip in $ip_test ; do
|
2017-10-27 14:59:30 +02:00
|
|
|
|
fg_public="$($cmd $iip)"
|
|
|
|
|
[ "$fg_public" ] && break
|
2017-08-26 09:05:54 +02:00
|
|
|
|
done
|
2017-08-06 02:43:48 +02:00
|
|
|
|
fi
|
2017-08-26 09:05:54 +02:00
|
|
|
|
|
2017-10-27 14:59:30 +02:00
|
|
|
|
if [ "$(f__cmd_exist telnet)" ] && [ -z "$fg_public" ]; then
|
|
|
|
|
fg_public="$(telnet $ip_telnet 23 2>/dev/null | grep $1 | cut -d ' ' -f 4)"
|
2017-08-17 10:49:12 +02:00
|
|
|
|
fi
|
2017-08-26 09:05:54 +02:00
|
|
|
|
|
2017-10-27 14:59:30 +02:00
|
|
|
|
if [ "$(f__cmd_exist nc)" ] && [ -z "$fg_public" ] && [ "$1" != "IPv6" ]; then
|
|
|
|
|
fg_public="$(nc $ip_telnet 23 2>/dev/null | grep $1 | cut -d ' ' -f 4)"
|
2017-08-17 10:49:12 +02:00
|
|
|
|
fi
|
2017-08-26 09:05:54 +02:00
|
|
|
|
|
2017-10-27 14:59:30 +02:00
|
|
|
|
if [ -z "$fg_public" ]; then
|
2017-08-26 09:05:54 +02:00
|
|
|
|
f__error "il manque une des commandes suivantes:\n" \
|
|
|
|
|
"dig / wget / curl / telnet / nc \n" \
|
|
|
|
|
"ou les ip de test sont devenues défaillantes\n" \
|
|
|
|
|
"réessayer après avoir installé dig (dnsutils) et wget\n" \
|
2017-10-16 07:10:04 +02:00
|
|
|
|
"si l'erreur persiste, merci de prévenir $projet, $contact"
|
2017-08-06 02:43:48 +02:00
|
|
|
|
fi
|
2017-08-02 01:16:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 09:10:14 +01:00
|
|
|
|
# $1=mem|swap [total|notitle|nocoltitle], assigne $fg_mem ($2=debug all cols + free)
|
2017-11-01 07:45:18 +01:00
|
|
|
|
figet_mem(){ # 31/10/2017
|
2017-10-09 20:19:07 +02:00
|
|
|
|
local freeDebug MemTotal MemFree MemAvailable Buffers Cached SReclaimable Shmem MemUsed
|
|
|
|
|
local SwapTotal SwapFree SwapCached col
|
|
|
|
|
[ "$2" == "debug" ] && freeDebug="$(free -hw | sed '3d')"
|
2017-10-04 23:26:27 +02:00
|
|
|
|
while IFS=':' read a b; do
|
|
|
|
|
[ "$a" == "MemTotal" ] && MemTotal="${b/kB}" #echo "$a $((${b/kB}/1024))" ! partie entière !
|
|
|
|
|
[ "$a" == "MemAvailable" ] && MemAvailable="${b/kB}"
|
2017-10-05 06:37:22 +02:00
|
|
|
|
[ "$a" == "MemFree" ] && MemFree="${b/kB}"
|
2017-10-04 23:26:27 +02:00
|
|
|
|
[ "$a" == "Buffers" ] && Buffers="${b/kB}"
|
|
|
|
|
[ "$a" == "Cached" ] && Cached="${b/kB}"
|
|
|
|
|
[ "$a" == "SReclaimable" ] && SReclaimable="${b/kB}"
|
2017-10-09 20:19:07 +02:00
|
|
|
|
[[ "$a" =~ Shmem$|MemShared$ ]] && Shmem="${b/kB}" # = free shared
|
2017-10-04 23:26:27 +02:00
|
|
|
|
[ "$a" == "SwapTotal" ] && SwapTotal="${b/kB}"
|
|
|
|
|
[ "$a" == "SwapFree" ] && SwapFree="${b/kB}"
|
|
|
|
|
[ "$a" == "SwapCached" ] && SwapCached="${b/kB}"
|
2017-10-09 20:19:07 +02:00
|
|
|
|
done <<< $(< /proc/meminfo)
|
2017-10-04 23:26:27 +02:00
|
|
|
|
MemUsed=$(( $MemTotal-($MemFree+$Buffers+$Cached+$SReclaimable) ))
|
|
|
|
|
SwapUsed=$(( $SwapTotal-$SwapFree ))
|
|
|
|
|
totalTotal=$(( $MemTotal+$SwapTotal ))
|
|
|
|
|
totalUsed=$(( $MemUsed+$SwapUsed ))
|
|
|
|
|
totalAvailable=$(( $MemAvailable+$SwapFree ))
|
2017-10-05 06:37:22 +02:00
|
|
|
|
MemTotal=$( printf '%10s' $(f__unit_human $MemTotal) )
|
|
|
|
|
MemUsed=$( printf '%10s' $(f__unit_human $MemUsed) )
|
|
|
|
|
MemAvailable=$( printf '%10s' $(f__unit_human $MemAvailable) )
|
2017-10-09 20:19:07 +02:00
|
|
|
|
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) )
|
2017-10-05 06:37:22 +02:00
|
|
|
|
SwapTotal=$( printf '%10s' $(f__unit_human $SwapTotal) )
|
|
|
|
|
SwapFree=$( printf '%10s' $(f__unit_human $SwapFree) )
|
|
|
|
|
SwapUsed=$( printf '%10s' $(f__unit_human $SwapUsed) )
|
2017-10-09 20:19:07 +02:00
|
|
|
|
SwapCached=$( printf '%10s' $(f__unit_human $SwapCached) )
|
2017-10-05 06:37:22 +02:00
|
|
|
|
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
|
|
|
|
|
[[ "$*" =~ nocoltitle ]] || col="mém.:"
|
2017-10-31 09:10:14 +01:00
|
|
|
|
fg_mem="$col totale utilisée disponible"$'\n'
|
2017-10-04 23:26:27 +02:00
|
|
|
|
fi
|
|
|
|
|
if [[ "$*" =~ mem ]]; then
|
|
|
|
|
[[ "$*" =~ nocoltitle ]] || col="ram :"
|
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
|
2017-10-09 20:19:07 +02:00
|
|
|
|
if [ "$2" == "debug" ]; then
|
|
|
|
|
local espace=$(printf '% 6s')
|
2017-10-31 09:10:14 +01:00
|
|
|
|
fg_mem="$espace""mém.: totale utilisée libre shared buffers cache disponible"$'\n'
|
|
|
|
|
fg_mem+="$espace""ram :$MemTotal$MemUsed$MemFree$Shmem$Buffers$Cached$MemAvailable"$'\n'
|
2017-11-01 07:45:18 +01:00
|
|
|
|
[ "$fg_mem" ] && fg_mem=${fg_mem::-1} # suppression dernier $'\n'
|
2017-10-31 09:10:14 +01:00
|
|
|
|
echo "$fg_mem"
|
2017-10-09 20:19:07 +02:00
|
|
|
|
echo "$freeDebug"
|
|
|
|
|
fi
|
2017-11-01 07:45:18 +01:00
|
|
|
|
[ "$fg_mem" ] && fg_mem=${fg_mem::-1} # suppression dernier $'\n'
|
2017-08-17 17:32:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 09:10:14 +01:00
|
|
|
|
figet_mod_net(){ # thanks wireless-info, assigne $fg_mod_net # 30/10/2017
|
2017-10-02 00:34:34 +02:00
|
|
|
|
local MODMATCHES LSMODMATCHES
|
|
|
|
|
MODMATCHES="(air|ar5|at7|ath[^3]?|b43|bcma|brcm|carl|ipw|iwl|ndis|r(818|8192[eu]|871|92su)|8(188|189|192|723|812)[acde][esu]|rt[23567]|rtl|ssb|wl|(cfg|mac)80211)"
|
|
|
|
|
LSMODMATCHES="(wmi|(dell|ideapad)[-_]laptop)"
|
2017-10-31 09:10:14 +01:00
|
|
|
|
fg_mod_net="$(lsmod | grep -E "(^|[[:punct:] ])($MODMATCHES|$LSMODMATCHES)[^[:punct:] ]*([[:punct:] ]|$)")"
|
2017-08-17 17:32:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-30 10:50:22 +01:00
|
|
|
|
# assigne $fg_nb_screen, $fg_resolution. return fg_resolution=n/a[ (ssh)] & fg_nb_screen=n/a ou valeurs
|
|
|
|
|
figet_screen(){ #v2 30/10/2017
|
|
|
|
|
fg_nb_screen="n/a"
|
|
|
|
|
fg_resolution="n/a"
|
|
|
|
|
[ "$ENV_SSH" ] && fg_resolution+=" (ssh)"
|
2017-10-27 06:32:50 +02:00
|
|
|
|
[ "$ENV_SSH" ] && return 0
|
2017-10-30 07:41:12 +01:00
|
|
|
|
# xrandr & et xdpyinfo ne retourne pas de nombre écrans correct (multiplex? hybrid?)
|
2017-10-26 05:23:33 +02:00
|
|
|
|
if [ $(f__cmd_exist xrandr) ]; then
|
2017-10-30 10:50:22 +01:00
|
|
|
|
fg_resolution=$( gawk '/[0-9]\*/ {gsub(/\*\+/,"",$2); printf "%s pixels (%dHz), ", $1, $2}' <<< $( xrandr --query ) )
|
2017-10-26 05:23:33 +02:00
|
|
|
|
elif [ $(f__cmd_exist xdpyinfo) ]; then
|
2017-10-30 10:50:22 +01:00
|
|
|
|
fg_resolution=$( gawk '/dimensions/ { print $2, $3 ", " }' <<< $(xdpyinfo) )
|
2017-10-26 01:55:35 +02:00
|
|
|
|
fi
|
2017-10-30 10:50:22 +01:00
|
|
|
|
fg_resolution="${fg_resolution%,*}" # suppression ',*'
|
|
|
|
|
[ "$(xargs <<< $fg_resolution)" ] || fg_resolution="n/a"
|
|
|
|
|
[ "$fg_resolution" != "n/a" ] && fg_nb_screen=$( grep -o 'pixels' <<< $fg_resolution | grep -c . )
|
2017-08-03 13:37:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 09:10:14 +01:00
|
|
|
|
figet_shell(){ # thanks neofetch, assigne $fg_shell # 30/10/2017
|
2017-10-02 15:34:29 +02:00
|
|
|
|
local shell
|
2017-08-26 09:05:54 +02:00
|
|
|
|
shell="${SHELL##*/}"
|
|
|
|
|
case "${SHELL##*/}" in
|
|
|
|
|
"bash")
|
|
|
|
|
shell+=" ${BASH_VERSION/-*}" ;;
|
|
|
|
|
"zsh")
|
|
|
|
|
shell+="$(zsh --version)"
|
|
|
|
|
shell="${shell/ zsh}" ;;
|
|
|
|
|
"mksh" | "ksh")
|
|
|
|
|
shell+="$("$SHELL" -c 'printf "%s" "$KSH_VERSION"')"
|
|
|
|
|
shell="${shell/ * KSH}" ;;
|
|
|
|
|
"tcsh" | "csh")
|
|
|
|
|
shell+="$("$SHELL" --version)"
|
|
|
|
|
shell="${shell/tcsh}"
|
|
|
|
|
shell="${shell/\(*}" ;;
|
|
|
|
|
"fish")
|
|
|
|
|
shell+="$(fish -c 'printf "%s" "$FISH_VERSION"')" ;;
|
|
|
|
|
esac
|
2017-10-31 09:10:14 +01:00
|
|
|
|
fg_shell="$shell"
|
2017-08-26 09:05:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-23 09:30:57 +02:00
|
|
|
|
figet_test_batt(){ # 23/10/2017
|
|
|
|
|
local text var_temp objet
|
2017-10-21 11:07:11 +02:00
|
|
|
|
# matériel
|
|
|
|
|
figet_dmi
|
2017-10-23 09:30:57 +02:00
|
|
|
|
figet_batt
|
|
|
|
|
###
|
2017-10-31 09:10:14 +01:00
|
|
|
|
f_display "fg_dmi" "sans"
|
2017-10-21 11:07:11 +02:00
|
|
|
|
text="--- \n\n"
|
|
|
|
|
text+="## batterie test \n\n"
|
2017-10-21 06:54:22 +02:00
|
|
|
|
# acpi éventuel
|
2017-10-22 11:14:21 +02:00
|
|
|
|
if [ "$(f__cmd_exist acpi)" ]; then
|
2017-10-21 11:07:11 +02:00
|
|
|
|
var_temp=$(acpi -abi)
|
2017-10-23 03:52:48 +02:00
|
|
|
|
[ "$var_temp" ] || var_temp="pas de batterie dans $(f__cmd_exist acpi)"
|
2017-10-21 11:07:11 +02:00
|
|
|
|
f_display "var_temp" "cmd" "acpi -abi"
|
2017-10-21 06:54:22 +02:00
|
|
|
|
fi
|
2017-10-23 09:30:57 +02:00
|
|
|
|
# upower
|
|
|
|
|
if [ "$(f__cmd_exist upower)" ]; then
|
|
|
|
|
objet=$(grep -i 'battery' <<< $(upower -e))
|
|
|
|
|
var_temp=$(upower -i $objet)
|
|
|
|
|
f_display "var_temp" "cmd" "upower -i $objet"
|
|
|
|
|
fi
|
|
|
|
|
# scandir
|
|
|
|
|
[ -d /sys/class/power_supply/BAT* ] && f_display_scandir "/sys/class/power_supply/" 1
|
2017-10-21 06:54:22 +02:00
|
|
|
|
# fonction script
|
2017-10-27 14:59:30 +02:00
|
|
|
|
f_display "fg_batt" "var" "figet_batt"
|
2017-10-21 06:54:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-29 03:19:47 +01:00
|
|
|
|
figet_test_distrib(){ # 29/10/2017
|
|
|
|
|
local etc lsb
|
|
|
|
|
etc=$(grep -Hs . /etc/*release /etc/*version)
|
|
|
|
|
lsb=$(lsb_release -a 2>/dev/null)
|
|
|
|
|
###
|
|
|
|
|
figet_dmi
|
2017-10-31 09:10:14 +01:00
|
|
|
|
f_display "fg_dmi" "var" "distrib test"
|
2017-10-29 03:19:47 +01:00
|
|
|
|
f_display "etc" "cmd" "grep -Hs . /etc/*release /etc/*version"
|
|
|
|
|
f_display "lsb" "cmd" "lsb_release -a"
|
|
|
|
|
figet_distrib
|
|
|
|
|
f_display "fg_distrib" "var" "fg_distrib"
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-21 11:07:11 +02:00
|
|
|
|
figet_test_dmi(){ # 21/10/2017
|
|
|
|
|
local text var_temp
|
|
|
|
|
text+="## dmi test \n\n"
|
2017-10-21 06:54:22 +02:00
|
|
|
|
# /sys/class/dmi/
|
2017-10-21 11:07:11 +02:00
|
|
|
|
var_temp="/sys/class/dmi/"
|
|
|
|
|
f_display_scandir "$var_temp" 1
|
2017-10-21 06:54:22 +02:00
|
|
|
|
# fonction script
|
|
|
|
|
figet_dmi
|
2017-10-31 09:10:14 +01:00
|
|
|
|
f_display "fg_dmi" "var" "figet_dmi"
|
2017-10-21 06:54:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-30 07:41:12 +01:00
|
|
|
|
figet_test_gpu(){ # 30/10/2017
|
|
|
|
|
local lspci="$(lspci -mm)"
|
|
|
|
|
figet_dmi
|
2017-10-31 09:10:14 +01:00
|
|
|
|
f_display "fg_dmi" "var" "gpu test"
|
2017-10-30 07:41:12 +01:00
|
|
|
|
f_display "lspci" "cmd" "lspci -mm"
|
|
|
|
|
figet_gpu
|
|
|
|
|
f_display "fg_gpu" "var" "fg_gpu"
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-22 11:14:21 +02:00
|
|
|
|
figet_test_hw(){ # 22/10/2017
|
2017-10-21 11:07:11 +02:00
|
|
|
|
local text var_temp
|
|
|
|
|
# matériel
|
|
|
|
|
figet_dmi
|
2017-10-31 09:10:14 +01:00
|
|
|
|
f_display "fg_dmi" "sans"
|
2017-10-21 11:07:11 +02:00
|
|
|
|
text="--- \n\n"
|
|
|
|
|
###
|
2017-10-21 06:54:22 +02:00
|
|
|
|
text+="## hwmon test \n\n"
|
|
|
|
|
# sensors et acpi éventuel
|
2017-10-22 11:14:21 +02:00
|
|
|
|
if [ "$(f__cmd_exist sensors)" ]; then
|
2017-10-21 11:07:11 +02:00
|
|
|
|
var_temp=$(sensors -u)
|
|
|
|
|
f_display "var_temp" "cmd" "sensors -u"
|
2017-10-21 06:54:22 +02:00
|
|
|
|
fi
|
2017-10-22 11:14:21 +02:00
|
|
|
|
if [ "$(f__cmd_exist acpi)" ]; then
|
2017-10-21 11:07:11 +02:00
|
|
|
|
var_temp=$(acpi -V | grep -E 'Thermal|Cooling')
|
|
|
|
|
f_display "var_temp" "cmd" "acpi -V"
|
2017-10-21 06:54:22 +02:00
|
|
|
|
fi
|
|
|
|
|
# /sys/class/hwmon/
|
2017-10-21 11:07:11 +02:00
|
|
|
|
var_temp="/sys/class/hwmon/"
|
|
|
|
|
f_display_scandir "$var_temp" 1
|
2017-10-21 06:54:22 +02:00
|
|
|
|
# /sys/class/thermal/thermal_zone0/
|
2017-10-21 11:07:11 +02:00
|
|
|
|
var_temp="/sys/class/thermal/thermal_zone0/"
|
|
|
|
|
f_display_scandir "$var_temp" 0
|
2017-10-21 06:54:22 +02:00
|
|
|
|
# /sys/devices/platform/coretemp.0/hwmon/
|
2017-10-21 11:07:11 +02:00
|
|
|
|
var_temp="/sys/devices/platform/coretemp.0/hwmon/"
|
|
|
|
|
f_display_scandir "$var_temp" 1
|
2017-10-21 06:54:22 +02:00
|
|
|
|
# analyse méthode neofetch
|
|
|
|
|
if [ -f "/sys/class/hwmon/hwmon0/temp1_input" ]; then
|
2017-10-21 11:07:11 +02:00
|
|
|
|
var_temp="$(< "/sys/class/hwmon/hwmon0/temp1_input")"
|
|
|
|
|
var_temp="$((var_temp * 100 / 10000))" # 33000 x 100 / 10 000 = 330
|
|
|
|
|
var_temp="[${var_temp/${var_temp: -1}}.${var_temp: -1}°C]" # formatage 1 point décimal
|
2017-10-21 06:54:22 +02:00
|
|
|
|
else
|
2017-10-21 11:07:11 +02:00
|
|
|
|
var_temp=" non accessible"
|
2017-10-21 06:54:22 +02:00
|
|
|
|
fi
|
2017-10-21 11:07:11 +02:00
|
|
|
|
f_display "var_temp" "var" "hwmon0/temp1_input ala neofetch"
|
|
|
|
|
# fonction script
|
|
|
|
|
figet_hw
|
2017-10-31 09:10:14 +01:00
|
|
|
|
f_display "fg_hw" "var" "figet_hw"
|
2017-10-21 06:54:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 09:10:14 +01:00
|
|
|
|
figet_wm(){ # thanks neofetch, assigne $fg_wm # 30/10/2017
|
|
|
|
|
fg_wm="n/a (ssh)"
|
|
|
|
|
[ "$ENV_SSH" ] && return 0 || fg_wm="n/a"
|
|
|
|
|
[ "$(f__cmd_exist xprop)" ] || return 0
|
2017-10-02 15:34:29 +02:00
|
|
|
|
local id wm
|
2017-08-26 09:05:54 +02:00
|
|
|
|
if [ -n "$DISPLAY" ]; then
|
2017-10-31 09:10:14 +01:00
|
|
|
|
id="$(xprop -root -notype _NET_SUPPORTING_WM_CHECK | cut -d' ' -f5)"
|
|
|
|
|
wm="$(xprop -id "$id" -notype -f _NET_WM_NAME 8t) "
|
2017-08-26 09:05:54 +02:00
|
|
|
|
wm="${wm/*_NET_WM_NAME = }"
|
|
|
|
|
wm="${wm/\"}"
|
|
|
|
|
wm="${wm/\"*}"
|
|
|
|
|
# Fallback for Wayland wms
|
|
|
|
|
[[ "$wm" == "xwlc" ]] && wm="$(ps -e | grep -m 1 -o -F -e "sway" -e "orbment" -e "velox" -e "orbital")"
|
2017-10-04 23:26:27 +02:00
|
|
|
|
else
|
2017-10-31 09:10:14 +01:00
|
|
|
|
wm="indéterminé"
|
2017-08-26 09:05:54 +02:00
|
|
|
|
fi
|
2017-10-31 09:10:14 +01:00
|
|
|
|
fg_wm="$wm"
|
2017-08-06 02:43:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-14 17:54:16 +02:00
|
|
|
|
# aiguillage export paste
|
2017-08-26 09:05:54 +02:00
|
|
|
|
fipaste(){
|
2017-09-27 20:40:28 +02:00
|
|
|
|
f__requis "curl" # requis pour paste
|
2017-08-30 01:04:45 +02:00
|
|
|
|
fipaste_curl_pastery "$fileOutput" "$pasteDuration" "$optDebug"
|
2017-08-26 09:05:54 +02:00
|
|
|
|
# à tester fipaste_curl_markdownshare "$fileOutput"
|
2017-08-06 02:43:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-14 17:54:16 +02:00
|
|
|
|
# $1 fichier à exporter, $2 durée de conservation en jour; $3 debug
|
2017-10-25 10:03:56 +02:00
|
|
|
|
fipaste_curl_pastery(){ # 25/10/2017
|
2017-08-19 03:45:31 +02:00
|
|
|
|
[ -e "$1" ] || f__error "fichier $1 inexistant"
|
2017-10-11 02:06:15 +02:00
|
|
|
|
local curl id pluriel
|
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-08-30 22:46:26 +02: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
|
|
|
|
|
f__info "$RED""Erreur critique export rapport:"
|
2017-10-14 17:54:16 +02:00
|
|
|
|
f__info "$curl"
|
2017-10-14 18:20:26 +02:00
|
|
|
|
f__info "merci contacter $projet, $contact pour aider à parfaire le script"
|
2017-10-14 17:54:16 +02:00
|
|
|
|
else
|
|
|
|
|
id="$(echo $curl | cut -d '"' -f 4)"
|
|
|
|
|
[ "$pasteDuration" -gt 1 ] && pluriel="s" || unset pluriel
|
2017-10-25 10:03:56 +02:00
|
|
|
|
f__info "votre paste:$GREEN https://www.pastery.net/$id/" \
|
2017-10-14 17:54:16 +02:00
|
|
|
|
"(valide pendant $RED$pasteDuration jour$pluriel)"
|
2017-10-19 08:57:57 +02:00
|
|
|
|
echo -e "exporté sur https://www.pastery.net/$id/ \n\n" >> "$fileOutput"
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-28 10:09:47 +02:00
|
|
|
|
# inscription dans tache upgrade en anacron hebdomadaire, via cron horaire, $1=upgrade|install|remove
|
2017-10-17 18:33:12 +02:00
|
|
|
|
fscript_cronAnacron(){ # 17/09/2017
|
2017-08-30 22:46:26 +02:00
|
|
|
|
local dirAnacron dirSpool fileAnacron
|
2017-08-26 09:05:54 +02:00
|
|
|
|
[ "$(type -t fscript_cronAnacron_special)" ] && fscript_cronAnacron_special # test, si fonction spécifique, appel
|
2017-08-30 22:46:26 +02:00
|
|
|
|
dirAnacron="/home/$user_/.config/anacron"
|
|
|
|
|
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
|
|
|
|
|
echo "7 10 $script nice /opt/bin/$script --upgrade 1>/dev/null" > "$fileAnacron" # juste erreurs en syslog
|
|
|
|
|
## anacron journalier pour dev logname
|
2017-08-27 07:05:26 +02:00
|
|
|
|
if [ -e "$fileDev" ]; then
|
|
|
|
|
echo "1 00 $script""Dev nice /opt/bin/$script --upgrade 1>/dev/null" >> "$fileAnacron"
|
2017-08-26 09:05:54 +02:00
|
|
|
|
fi
|
|
|
|
|
# création spool anacron utilisateur
|
|
|
|
|
mkdir -p "$dirSpool"
|
2017-09-06 14:08:03 +02:00
|
|
|
|
chown -R "$user_:" "$dirAnacron" "$dirSpool"
|
|
|
|
|
if [ "$EUID" -eq 0 ]; then
|
2017-08-26 09:05:54 +02:00
|
|
|
|
# crontab pour activation horaire anacron
|
|
|
|
|
echo "@hourly $user_ /usr/sbin/anacron -t $fileAnacron -S $dirSpool" >> /etc/crontab
|
|
|
|
|
fi
|
|
|
|
|
[ "$(grep "$script" /etc/crontab)" ] || echo f__error "inscription crontab" \
|
2017-10-17 18:33:12 +02:00
|
|
|
|
"certains systèmes semblent poser poser problème, merci de rapporter ce bug à $projet, $contact"
|
2017-08-26 09:05:54 +02:00
|
|
|
|
;;
|
|
|
|
|
remove )
|
|
|
|
|
rm "$dirSpool/$script"* &>/dev/null
|
|
|
|
|
rm "$fileAnacron" &>/dev/null
|
|
|
|
|
rmdir "$dirSpool" "$dirAnacron" &>/dev/null
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# version script en ligne, assigne $versionScript, $script_aJour=ok|ko
|
2017-10-27 14:59:30 +02:00
|
|
|
|
fscript_get_version(){ # 27/10/2017
|
2017-08-27 07:36:27 +02:00
|
|
|
|
f__info "raw" "$GREEN""version script en cours: $version"
|
2017-10-27 14:59:30 +02:00
|
|
|
|
versionScript=$(wget -q --timeout=15 -O - "$urlScript" | grep -m1 '^version=' | cut -d'=' -f2)
|
2017-08-26 09:05:54 +02:00
|
|
|
|
if [ "$versionScript" ]; then
|
|
|
|
|
if [ "$version" != "$versionScript" ]; then
|
|
|
|
|
f__info "version script en ligne: $versionScript, mise à jour possible"
|
|
|
|
|
script_aJour="ko"
|
|
|
|
|
else
|
|
|
|
|
f__info "version script en ligne: $versionScript"
|
|
|
|
|
script_aJour="ok"
|
|
|
|
|
fi
|
2017-10-17 18:33:12 +02:00
|
|
|
|
else
|
2017-10-27 14:59:30 +02:00
|
|
|
|
f__info "version script en ligne$RED non accessible"
|
2017-10-17 18:33:12 +02:00
|
|
|
|
fi
|
2017-08-26 09:05:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# installation du script dans le système
|
2017-10-09 20:19:07 +02:00
|
|
|
|
fscript_install(){ # 08/10/2017
|
2017-08-30 01:04:45 +02:00
|
|
|
|
if grep -q 'bin' <<< "$(dirname $0)" ; then
|
2017-10-09 20:19:07 +02:00
|
|
|
|
f__info "$RED""l'installation dans le système doit se faire depuis un script local $GREEN(./$script -i )"
|
|
|
|
|
return 1
|
2017-08-26 09:05:54 +02:00
|
|
|
|
fi
|
2017-09-06 14:08:03 +02:00
|
|
|
|
if [ "$EUID" -ne 0 ]; then
|
2017-10-09 20:19:07 +02:00
|
|
|
|
f__info "vous devez être$RED ROOT$BLUE pour installer ce script dans le système"
|
|
|
|
|
f__sudo "exec $0 -i"
|
|
|
|
|
return $?
|
2017-08-30 01:04:45 +02:00
|
|
|
|
fi
|
|
|
|
|
[ "$(type -t fscript_install_special)" ] && fscript_install_special # test, si fonction spécifique, appel
|
2017-08-26 09:05:54 +02:00
|
|
|
|
f__requis "wget anacron cron"
|
|
|
|
|
# install /opt
|
|
|
|
|
mkdir -p /opt/bin/
|
|
|
|
|
cp -d "$(basename $0)" "/opt/bin/$script"
|
|
|
|
|
ln -s "/opt/bin/$script" "/usr/bin/$script" &>/dev/null
|
2017-10-09 20:19:07 +02:00
|
|
|
|
chmod 775 "/opt/bin/$script" # rwx rwx r-x, proprio user_
|
2017-08-26 09:05:54 +02:00
|
|
|
|
# cron/anacron install
|
|
|
|
|
fscript_cronAnacron "install"
|
|
|
|
|
# création fichier log
|
|
|
|
|
touch "$fileLogs"
|
2017-10-09 20:19:07 +02:00
|
|
|
|
chmod 664 "$fileLogs" # rw- rw- r--, proprio user_
|
2017-09-06 14:08:03 +02:00
|
|
|
|
chown "$user_:" "$fileLogs" "/opt/bin/$script"
|
2017-08-27 07:05:26 +02:00
|
|
|
|
[ -e "$fileDev" ] || rm "$(basename $0)" &>/dev/null ## 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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# suppression du script dans le système
|
2017-10-09 20:19:07 +02:00
|
|
|
|
fscript_remove(){ # 08/10/2017
|
2017-08-30 01:04:45 +02:00
|
|
|
|
if ! grep -q 'bin' <<< "$(dirname $0)" ; then
|
2017-10-09 20:19:07 +02: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
|
|
|
|
|
if [ ! -x "/opt/bin/$script" ];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-09-06 14:08:03 +02:00
|
|
|
|
if [ "$EUID" -ne 0 ]; then
|
2017-10-09 20:19:07 +02:00
|
|
|
|
f__info "vous devez être$RED ROOT$BLUE pour supprimer ce script dans le système"
|
|
|
|
|
f__sudo "exec $0 -r"
|
|
|
|
|
return $?
|
2017-08-30 01:04:45 +02:00
|
|
|
|
fi
|
2017-10-09 20:19:07 +02:00
|
|
|
|
[ "$(type -t fscript_remove_special)" ] && fscript_remove_special # test, si fonction spécifique, appel
|
2017-08-26 09:05:54 +02:00
|
|
|
|
# suppression de /opt
|
2017-09-06 14:08:03 +02:00
|
|
|
|
rm "/opt/bin/$script" &>/dev/null
|
|
|
|
|
unlink "/usr/bin/$script" &>/dev/null
|
2017-08-26 09:05:54 +02:00
|
|
|
|
# cron/anacron remove
|
|
|
|
|
fscript_cronAnacron "remove"
|
|
|
|
|
f__info "log" "$script $version supprimé du système."
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-27 14:59:30 +02:00
|
|
|
|
# mise à jour script si dispo, v2, +update spécifique
|
|
|
|
|
# à tester avant généraliser fileInstall="/opt/bin/$script" ?
|
|
|
|
|
fscript_update(){ # 27/10/2017
|
|
|
|
|
local dirTemp="/tmp/$script-$RANDOM"
|
|
|
|
|
[ $(type -t fscript_update_special) ] && fscript_update_special # test, si fonction spécifique, appel
|
|
|
|
|
if [ -z "$updateSpecial" ] && ! grep -q 'bin' <<< "$(dirname $0)" ; then
|
2017-10-09 20:19:07 +02: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-08-26 09:05:54 +02:00
|
|
|
|
fscript_get_version
|
|
|
|
|
if [ "$script_aJour" == "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
|
|
|
|
|
fi
|
|
|
|
|
mkdir -p "$dirTemp"
|
2017-10-27 14:59:30 +02:00
|
|
|
|
wget -q --tries=2 --timeout=15 -O "$dirTemp/$script" "$urlScript"
|
2017-08-26 09:05:54 +02:00
|
|
|
|
if [ "$?" != "0" ]; then f__wget_test "$urlScript"; fi
|
2017-10-27 14:59:30 +02:00
|
|
|
|
cp -d "$dirTemp/$script" "$fileInstall"
|
2017-09-06 14:08:03 +02:00
|
|
|
|
rm -rf "$dirTemp/"
|
2017-10-27 14:59:30 +02:00
|
|
|
|
chmod 775 "$fileInstall" # rwx rwx r-x, proprio user_
|
|
|
|
|
chown "$user_:" "$fileInstall"
|
|
|
|
|
[ -z "$updateSpecial" ] && fscript_cronAnacron "upgrade"
|
|
|
|
|
f__info "log" "$script mis à jour en version $versionScript $updateSpecial"
|
2017-08-26 09:05:54 +02:00
|
|
|
|
}
|
2017-07-30 17:08:05 +02:00
|
|
|
|
|
2017-08-19 03:45:31 +02:00
|
|
|
|
prg_1(){ # début
|
2017-09-28 20:47:34 +02:00
|
|
|
|
echo > "$fileOutput"
|
2017-10-09 20:19:07 +02:00
|
|
|
|
chown $user_: "$fileOutput" &>/dev/null
|
|
|
|
|
chmod 666 "$fileOutput" &>/dev/null # rw-rw-rw-, si root permet écriture & effacement à tous
|
2017-10-25 23:45:00 +02:00
|
|
|
|
echo -e "> $script sur **$(uname -n)** \n" > "$fileOutput"
|
2017-10-25 10:03:56 +02:00
|
|
|
|
echo -e "$ligneRapport \n\n" >> "$fileOutput"
|
2017-08-06 19:10:10 +02:00
|
|
|
|
}
|
2017-09-28 20:47:34 +02:00
|
|
|
|
prg_2(){ # traitements principaux
|
2017-10-28 20:07:20 +02:00
|
|
|
|
if [ "$EUID" -eq 0 ]; then
|
|
|
|
|
f__info "des erreurs$YELLOW No protocol specified, Can't open display :0$BLUE peut indiquer un défaut de configuration système (Xorg, Wayland?)" \
|
|
|
|
|
"lancer le script en utilisateur pour avoir toutes les informations"
|
|
|
|
|
fi
|
2017-09-22 14:55:55 +02:00
|
|
|
|
printf " ."
|
2017-10-09 20:19:07 +02:00
|
|
|
|
if [[ "$1" == all || "$1" =~ s ]]; then #systeme, matériel -cs
|
2017-10-25 10:03:56 +02:00
|
|
|
|
echo -e "# Système et matériel \n\n" >> "$fileOutput"
|
2017-10-12 21:49:57 +02:00
|
|
|
|
for i in fi_systeme fi_cpu fi_mem fi_hw fi_batt fi_graph fi_disk fi_usb ; do
|
2017-10-09 20:19:07 +02:00
|
|
|
|
$i
|
|
|
|
|
printf "."
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
if [[ "$1" == all || "$1" =~ c ]]; then #configuration #debian, packages -cc
|
2017-10-31 06:52:36 +01:00
|
|
|
|
echo -e "# Configuration \n\n" >> "$fileOutput"
|
2017-10-28 23:42:15 +02:00
|
|
|
|
for i in fi_locale fi_vrms fi_sources ; do
|
2017-10-09 20:19:07 +02:00
|
|
|
|
$i
|
|
|
|
|
printf "."
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
if [[ "$1" == all || "$1" =~ r ]]; then #reseau -cr
|
2017-10-25 10:03:56 +02:00
|
|
|
|
echo -e "# Réseau \n\n" >> "$fileOutput"
|
2017-10-27 14:59:30 +02:00
|
|
|
|
for i in fi_reseau fi_nm ; do
|
2017-10-09 20:19:07 +02:00
|
|
|
|
$i
|
|
|
|
|
printf "."
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
if [[ "$1" == all || "$1" =~ a ]]; then #analyse -ca
|
2017-10-25 10:03:56 +02:00
|
|
|
|
echo -e "# Analyse \n\n" >> "$fileOutput"
|
2017-10-19 08:57:57 +02:00
|
|
|
|
for i in fi_system_analyse fi_log_xorg fi_journal ; do
|
2017-10-09 20:19:07 +02:00
|
|
|
|
$i
|
|
|
|
|
done
|
|
|
|
|
fi
|
2017-08-03 02:44:53 +02:00
|
|
|
|
}
|
2017-08-06 02:43:48 +02:00
|
|
|
|
prg_3(){ # fin de traitements
|
2017-10-19 01:02:41 +02:00
|
|
|
|
echo -e "--- \n" >> "$fileOutput"
|
2017-11-01 12:55:53 +01:00
|
|
|
|
[ "$debugBatt" ] && echo -e "$debugBatt \n" >> "$fileOutput"
|
2017-10-19 01:02:41 +02:00
|
|
|
|
echo -e "$ligneRapport \n" >> "$fileOutput"
|
2017-10-25 10:03:56 +02:00
|
|
|
|
f__dialog_oui_non "non" "\n exporter sur le pastebin par défaut?" && fipaste
|
2017-10-09 20:19:07 +02:00
|
|
|
|
f__info "le rapport est disponible en local, fichier:$YELLOW $fileOutput" \
|
2017-10-11 02:06:15 +02:00
|
|
|
|
"vous pouvez le visualiser ultérieurement avec $GREEN$script -l" \
|
|
|
|
|
"vous pourrez l'exporter ultérieurement avec $BLUE$script -p"
|
2017-10-09 20:19:07 +02:00
|
|
|
|
}
|
2017-10-11 02:06:15 +02:00
|
|
|
|
prg_menu(){ # 10/10/2017
|
2017-10-09 20:19:07 +02:00
|
|
|
|
|
|
|
|
|
function display_menu {
|
|
|
|
|
local centre=50 left=2 larg=60 reply line
|
|
|
|
|
if [ $(( $(tput cols) )) -le 80 ]; then
|
|
|
|
|
centre=$(( $(tput cols)/2+$left ))
|
|
|
|
|
larg=$(( $centre+3*$left ))
|
|
|
|
|
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-07-30 17:08:05 +02:00
|
|
|
|
|
2017-10-09 20:19:07 +02:00
|
|
|
|
printf " $GREEN$script -h$STD : afficher l'aide \n"
|
2017-10-11 02:06:15 +02:00
|
|
|
|
display_menu "$GREEN$script -c$RED""s$STD : catégorie système" \
|
|
|
|
|
"$GREEN$script -c$RED""c$STD : catégorie configuration"
|
|
|
|
|
display_menu "$GREEN$script -c$RED""r$STD : catégorie réseau" \
|
|
|
|
|
"$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" \
|
|
|
|
|
" $GREEN$script -c$RED""sa$STD générera un rapport sur le système & l'analyse"
|
|
|
|
|
printf "\n choix des catégories à générer (all pour toutes)? "
|
|
|
|
|
tput sc
|
|
|
|
|
printf "\n ( ne pas saisir le préfixe $YELLOW-c$STD, all par défaut)"
|
|
|
|
|
tput rc
|
|
|
|
|
read reply
|
|
|
|
|
[ "$reply" ] && reply="-c${reply,,}" || reply="all"
|
|
|
|
|
reply="$(sed 's/-call/all/' <<< $reply)"
|
|
|
|
|
exec $0 "$reply"
|
|
|
|
|
}
|
2017-10-29 03:19:47 +01:00
|
|
|
|
prg_alert_init(){ # 29/10/2017
|
2017-10-24 21:35:26 +02:00
|
|
|
|
bashVersion=($(grep -o 'version 4' <<< $(bash --version)))
|
|
|
|
|
[ ${bashVersion[1]} -ge 4 ] || f__error "bash v4 requis" \
|
|
|
|
|
"version installée: $(sed -n '1p' <<< $(bash --version))"
|
|
|
|
|
|
2017-10-12 08:45:16 +02:00
|
|
|
|
[ -f /proc/cpuinfo ] || f__error "/proc/cpuinfo non trouvé" "/proc ne doit pas être monté"
|
2017-10-24 21:35:26 +02: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"
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
[ "$EUID" -eq 0 ] && user_="root" || f__error "user détecté, mais pas de home: /home/$user_"
|
|
|
|
|
f__info "user root"
|
|
|
|
|
fi
|
2017-10-12 08:45:16 +02:00
|
|
|
|
}
|
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
|
|
|
|
PATH='/usr/sbin:/usr/bin:/sbin:/bin'; TERM=xterm ; IFS=$' \t\n'
|
|
|
|
|
export PATH TERM IFS
|
2017-10-23 03:52:48 +02:00
|
|
|
|
[[ "$SSH_CLIENT" || "$SSH_CLIENT" || "$SSH_CLIENT" ]] && ENV_SSH="ssh"
|
2017-10-09 20:19:07 +02:00
|
|
|
|
|
2017-10-24 21:35:26 +02:00
|
|
|
|
# logo et définition couleurs
|
2017-10-09 20:19:07 +02:00
|
|
|
|
f__affichage
|
|
|
|
|
|
2017-10-27 14:59:30 +02:00
|
|
|
|
# tests au démarrage
|
2017-10-24 21:35:26 +02:00
|
|
|
|
prg_alert_init
|
|
|
|
|
|
|
|
|
|
# requis pour fonctionnement programme
|
|
|
|
|
f__requis "gawk wget ip>iproute2 lspci>pciutils wc>coreutils"
|
2017-10-09 20:19:07 +02:00
|
|
|
|
|
2017-08-30 01:04:45 +02:00
|
|
|
|
options=$@
|
2017-10-24 21:35:26 +02:00
|
|
|
|
# traitement option paramètres
|
2017-09-23 12:23:41 +02:00
|
|
|
|
for j in $options; do
|
|
|
|
|
case $j in
|
2017-09-28 20:47:34 +02:00
|
|
|
|
--debug-paste )
|
2017-10-09 20:19:07 +02:00
|
|
|
|
optDebug="debugPaste"
|
2017-08-30 01:04:45 +02:00
|
|
|
|
;; # si debug, retour json de pastery.net
|
|
|
|
|
-t* )
|
2017-09-28 20:47:34 +02:00
|
|
|
|
pasteDuration="$(sed -En 's/-t([0-9]+)/\1/p' <<< $j)"
|
2017-08-30 01:04:45 +02:00
|
|
|
|
;; # durée de conservation standard du paste en jours
|
|
|
|
|
esac
|
|
|
|
|
done
|
2017-10-11 02:06:15 +02:00
|
|
|
|
options="$(sed -E 's/--debug-paste//g; s/-t[0-9]+//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-27 14:59:30 +02:00
|
|
|
|
# paramètres généraux
|
2017-08-30 01:04:45 +02:00
|
|
|
|
[ "$pasteDuration" ] || pasteDuration=7 # durée de conservation standard du paste en jours
|
2017-10-09 20:19:07 +02:00
|
|
|
|
fileOutput="getInfo_rapport.md"
|
|
|
|
|
fileLogs="/var/log/sdeb_$script.log"
|
|
|
|
|
fileDev="/opt/bin/fileDev"
|
2017-10-27 14:59:30 +02:00
|
|
|
|
fileInstall="/opt/bin/$script"
|
2017-10-11 02:06:15 +02:00
|
|
|
|
urlScript="https://frama.link/getInfo"
|
|
|
|
|
urlNotice="https://frama.link/doc-getInfo"
|
2017-10-24 21:35:26 +02:00
|
|
|
|
# test sur frama.link ok, sinon fallback sur framagit
|
2017-10-09 20:19:07 +02:00
|
|
|
|
if [[ "$options" =~ all|-d|-h|-c ]]; then
|
|
|
|
|
if ! f__wget_test "$urlScript" "test"; then
|
|
|
|
|
urlScript="https://framagit.org/kyodev/kyopages/raw/master/scripts/$script"
|
|
|
|
|
urlNotice="https://kyodev.frama.io/kyopages/scripts/getInfo/"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2017-10-29 22:02:01 +01:00
|
|
|
|
ligneRapport="Rapport du $(date '+%d/%m/%Y %H:%M %z') ● $0 $* ● [$script $version]($urlNotice)"
|
2017-10-09 20:19:07 +02:00
|
|
|
|
|
2017-10-24 21:35:26 +02:00
|
|
|
|
# traitement options menu catégories
|
2017-10-09 20:19:07 +02:00
|
|
|
|
for k in $options; do
|
|
|
|
|
categorie+="$(sed -En 's/-c([a-z]+)/\1/p' <<< $k)"
|
|
|
|
|
options="$(sed -E 's/-c[a-z]+//' <<< $k | xargs)"
|
|
|
|
|
done
|
|
|
|
|
[ "$categorie" ] && options+=" -c$categorie"
|
|
|
|
|
|
|
|
|
|
# actions
|
2017-09-23 12:23:41 +02:00
|
|
|
|
for j in $options; do
|
|
|
|
|
case $j in
|
2017-10-09 20:19:07 +02:00
|
|
|
|
-t | --test )
|
2017-10-19 01:02:41 +02:00
|
|
|
|
prg_1 "$*"
|
2017-11-01 14:31:27 +01:00
|
|
|
|
fi_cpu
|
2017-10-19 01:02:41 +02:00
|
|
|
|
prg_3
|
2017-10-11 02:06:15 +02:00
|
|
|
|
exit ;; # test seulement
|
|
|
|
|
-c* | all )
|
2017-10-09 20:19:07 +02:00
|
|
|
|
[ "$j" == "-c" ] && exec $0 "menu"
|
2017-10-19 01:02:41 +02:00
|
|
|
|
prg_1 "$*"
|
2017-10-09 20:19:07 +02:00
|
|
|
|
j=$(sed -E 's/-c//' <<< $j)
|
|
|
|
|
prg_2 "$j"
|
2017-09-28 20:47:34 +02:00
|
|
|
|
prg_3
|
2017-10-11 02:06:15 +02:00
|
|
|
|
exit ;; # rapport complet ou par catégorie
|
2017-10-19 08:57:57 +02:00
|
|
|
|
-j )
|
|
|
|
|
prg_1 "$*"
|
|
|
|
|
prg_2 "a"
|
|
|
|
|
exit ;; # exporte le rapport existant
|
2017-10-09 20:19:07 +02:00
|
|
|
|
-l )
|
|
|
|
|
[ -e $fileOutput ] && cat $fileOutput || f__info "pas de rapport à afficher" \
|
|
|
|
|
"vous devez lancer une analyse auparavant: $GREEN$script -l" \
|
|
|
|
|
"ou afficher l'aide $GREEN$script -h"
|
|
|
|
|
exit ;; # afficher le rapport existant
|
|
|
|
|
-p )
|
2017-09-04 13:35:14 +02:00
|
|
|
|
fipaste
|
2017-10-09 20:19:07 +02:00
|
|
|
|
exit ;; # exporte le rapport existant
|
|
|
|
|
-h )
|
|
|
|
|
f_help
|
|
|
|
|
exit ;; # affichage help
|
2017-10-14 17:54:16 +02:00
|
|
|
|
--debug-all )
|
2017-10-19 01:02:41 +02:00
|
|
|
|
prg_1 "$*"
|
2017-10-21 06:54:22 +02:00
|
|
|
|
figet_test_batt
|
2017-10-30 07:41:12 +01:00
|
|
|
|
figet_test_distrib
|
2017-10-21 06:54:22 +02:00
|
|
|
|
figet_test_dmi
|
2017-10-30 07:41:12 +01:00
|
|
|
|
figet_test_gpu
|
2017-10-21 06:54:22 +02:00
|
|
|
|
figet_test_hw
|
2017-10-14 17:54:16 +02:00
|
|
|
|
prg_3
|
|
|
|
|
exit ;; # test batterie, dmi, hwmon
|
2017-10-11 02:06:15 +02:00
|
|
|
|
--debug-batt )
|
2017-10-19 01:02:41 +02:00
|
|
|
|
prg_1 "$*"
|
2017-10-21 06:54:22 +02:00
|
|
|
|
figet_test_batt
|
2017-10-09 20:19:07 +02:00
|
|
|
|
prg_3
|
2017-10-14 17:54:16 +02:00
|
|
|
|
exit ;; # test batterie avec scan /sys/class/power_supply/
|
2017-10-29 03:19:47 +01:00
|
|
|
|
--debug-dist )
|
|
|
|
|
prg_1 "$*"
|
|
|
|
|
figet_test_distrib
|
|
|
|
|
prg_3
|
|
|
|
|
exit ;; # test distrib
|
2017-10-12 08:45:16 +02:00
|
|
|
|
--debug-dmi )
|
2017-10-19 01:02:41 +02:00
|
|
|
|
prg_1 "$*"
|
2017-10-21 06:54:22 +02:00
|
|
|
|
figet_test_dmi
|
2017-10-12 08:45:16 +02:00
|
|
|
|
prg_3
|
2017-10-14 17:54:16 +02:00
|
|
|
|
exit ;; # test dmi avec affichage /sys/class/dmi/id/
|
2017-10-30 07:41:12 +01:00
|
|
|
|
--debug-gpu )
|
|
|
|
|
prg_1 "$*"
|
|
|
|
|
figet_test_gpu
|
|
|
|
|
prg_3
|
|
|
|
|
exit ;; # test gpu
|
2017-10-12 21:49:57 +02:00
|
|
|
|
--debug-hw )
|
2017-10-19 01:02:41 +02:00
|
|
|
|
prg_1 "$*"
|
2017-10-21 06:54:22 +02:00
|
|
|
|
figet_test_hw
|
2017-10-12 21:49:57 +02:00
|
|
|
|
prg_3
|
2017-10-14 17:54:16 +02:00
|
|
|
|
exit ;; # test hwmon avec affichage /sys/class/hwmon/
|
2017-08-26 09:05:54 +02:00
|
|
|
|
--ip )
|
2017-10-27 14:59:30 +02:00
|
|
|
|
if figet_ip_pub "4" ; then
|
|
|
|
|
f__info "raw" " ipv4 publique: $GREEN$fg_public"
|
2017-09-03 09:37:47 +02:00
|
|
|
|
else
|
|
|
|
|
f__info "$BLUE pas de connectivité ipv4"
|
|
|
|
|
fi
|
2017-10-27 14:59:30 +02:00
|
|
|
|
if figet_ip_pub "6" ; then
|
|
|
|
|
f__info "raw" " ipv6 publique: $GREEN$fg_public"
|
2017-09-03 09:37:47 +02:00
|
|
|
|
else
|
|
|
|
|
f__info "$BLUE pas de connectivité ipv6"
|
|
|
|
|
fi
|
2017-08-30 01:04:45 +02:00
|
|
|
|
exit ;; # affiche ip public
|
2017-10-09 20:19:07 +02:00
|
|
|
|
--mac )
|
2017-09-04 13:35:14 +02:00
|
|
|
|
figet_ip
|
2017-10-27 14:59:30 +02:00
|
|
|
|
f__info "fg_mac:\n$GREEN$fg_mac_tp"
|
2017-09-04 13:35:14 +02:00
|
|
|
|
exit ;; # affiche adresses mac
|
2017-10-09 20:19:07 +02:00
|
|
|
|
--ssid )
|
2017-08-26 23:42:34 +02:00
|
|
|
|
fi_ssid
|
2017-08-30 01:04:45 +02:00
|
|
|
|
exit ;; # affiche configurations ssid, root requis
|
2017-08-26 23:42:34 +02:00
|
|
|
|
-i | --install )
|
2017-09-03 10:37:30 +02:00
|
|
|
|
fscript_install
|
2017-08-30 01:04:45 +02:00
|
|
|
|
exit ;; # installation du script dans le système
|
2017-08-26 23:42:34 +02:00
|
|
|
|
-r | --remove )
|
2017-09-03 10:37:30 +02:00
|
|
|
|
fscript_remove
|
2017-08-30 01:04:45 +02:00
|
|
|
|
exit ;; # suppression du script dans le système
|
2017-08-26 23:42:34 +02:00
|
|
|
|
-u | --upgrade )
|
2017-10-27 14:59:30 +02:00
|
|
|
|
opType="upgrade" # log si f__error
|
2017-09-03 10:37:30 +02:00
|
|
|
|
fscript_update
|
2017-08-30 01:04:45 +02:00
|
|
|
|
exit ;; # upgrade script si maj possible
|
2017-10-27 14:59:30 +02:00
|
|
|
|
-us )
|
|
|
|
|
opType="upgrade" # log si f__error
|
|
|
|
|
updateSpecial="update spécial actif"
|
|
|
|
|
fileInstall="$(dirname $0)/$script"
|
|
|
|
|
fscript_update
|
|
|
|
|
exit ;; # upgrade spécial
|
2017-08-26 23:42:34 +02:00
|
|
|
|
-v | --version )
|
|
|
|
|
fscript_get_version
|
2017-08-30 01:04:45 +02:00
|
|
|
|
exit ;; # version du script, en ligne et exécuté
|
2017-10-09 20:19:07 +02:00
|
|
|
|
menu | * )
|
2017-10-19 01:02:41 +02:00
|
|
|
|
prg_1 "$*"
|
2017-10-09 20:19:07 +02:00
|
|
|
|
prg_menu
|
2017-08-30 01:04:45 +02:00
|
|
|
|
exit ;; # affichage help
|
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-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
|