mirror of https://framagit.org/kyodev/kyopages.git
getInfo 2.2.0
This commit is contained in:
parent
6f590d51d6
commit
6b42539f4e
215
scripts/getInfo
215
scripts/getInfo
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
version=2.1.0
|
||||
date="10/10/2017"
|
||||
version=2.2.0
|
||||
date="11/10/2017"
|
||||
projet="simpledeb"
|
||||
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
|
||||
script="getInfo"
|
||||
|
@ -156,11 +156,11 @@ f__requis(){ # 22/09/2017
|
|||
}
|
||||
|
||||
# $1=cmd si $2: nb de tentatives pour s'identifier, sinon 1 tentative par défaut
|
||||
f__sudo(){ # 08/10/2017
|
||||
f__sudo(){ # 11/10/2017
|
||||
local nb=1 sudo isudo
|
||||
# sudo --shell bash équivalent su ?
|
||||
if sudo -v &>/dev/null && [ $EUID -ne 0 ] ; then
|
||||
sudo="sudo --shell $(which bash) "
|
||||
sudo="sudo su --shell $(which bash) --preserve-environment -c "
|
||||
else
|
||||
sudo="su --shell $(which bash) --preserve-environment -c "
|
||||
fi
|
||||
|
@ -259,7 +259,7 @@ f__wget_test(){ # 08/10/2017
|
|||
exit 0
|
||||
}
|
||||
|
||||
f_help(){ # 10/10/2017
|
||||
f_help(){ # 11/10/2017
|
||||
printf "$BLUE"
|
||||
cat << 'EOF'
|
||||
----------------------------------------------------------------------
|
||||
|
@ -280,6 +280,7 @@ cat << 'EOF'
|
|||
root et NetworkManager requis
|
||||
|
||||
--debug-batt : rapport batterie avec affichage BAT?/uevent et rapport markdown
|
||||
--debug-dmi : test valeurs dmi et rapport markdown
|
||||
--debug-paste : le résultat json du paste sera affiché après export
|
||||
|
||||
-i, --install : installation du script dans le système, root requis
|
||||
|
@ -292,7 +293,7 @@ echo -e "$STD\n plus d'infos: $GREEN$urlNotice\n$STD"
|
|||
|
||||
fi_batt(){ # 10/10/2017
|
||||
[ "$batt_nb" ] || figet_battery # appel figet_battery si pas déjà fait par fi_systeme
|
||||
[ "$batt_nb" -gt 0 ] || return 0
|
||||
[[ "$batt_nb" == "-1" || "$batt_nb" -gt 0 ]] || return 0
|
||||
text="## batterie(s) \n\n"
|
||||
text+='```\n'
|
||||
text+="$batt_detail\n"
|
||||
|
@ -307,6 +308,7 @@ fi_batt(){ # 10/10/2017
|
|||
}
|
||||
|
||||
fi_cpu(){ # 04/10/2017
|
||||
#manuellement lscpu (util-linux)
|
||||
local cpu_addr cpu_bogomips cpu_flags text
|
||||
cpu_addr="$(sed -n 's/^address sizes.*: \(.*\)$/\1/p' /proc/cpuinfo | sed -n '1p')"
|
||||
cpu_bogomips="$(sed -n 's/^bogomips.*: \(.*\)$/\1/p' /proc/cpuinfo | sed -n '1p')"
|
||||
|
@ -326,14 +328,20 @@ fi_cpu(){ # 04/10/2017
|
|||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
fi_disk(){ # 05/10/2017
|
||||
fi_disk(){ # 11/10/2017
|
||||
local disk_lsblk disk_df disk_df_i fstab resume idResume idSwap alert_uuidResume text
|
||||
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')"
|
||||
fstab="$(grep -vE '^[[:blank:]]*#|^$' /etc/fstab)"
|
||||
resume="$(grep -Ev '^[[:blank:]]*#|^$' /etc/initramfs-tools/conf.d/resume 2>/dev/null)"
|
||||
idResume="$(grep -Ev '^[[:blank:]]*#|^$' /etc/initramfs-tools/conf.d/resume 2>/dev/null | sed -En 's/.*UUID=([0-9a-Z-]*).*$/\1/p')"
|
||||
fstab="$(grep -Ev '^[[:blank:]]*#|^$' /etc/fstab)"
|
||||
resume="$(grep -Evs '^[[:blank:]]*#|^$' /etc/initramfs-tools/conf.d/resume)"
|
||||
if [ -z "$resume" ]; then
|
||||
alert_resume="pas de fichier _resume_ dans /etc/initramfs-tools/conf.d/ \n"
|
||||
alert_resume+="ce n'est pas forcément une erreur et n'a pas d'incidence si l'hibernation n'est pas utilisée \n"
|
||||
alert_resume+="cela pourrait générer des erreurs en cas d'hibernation et de multiples partitions swap. "
|
||||
alert_resume+="il vaudrait peut-être mieux créer alors ce fichier. \n"
|
||||
fi
|
||||
idResume="$(grep -Evs '^[[:blank:]]*#|^$' /etc/initramfs-tools/conf.d/resume | sed -En 's/.*UUID=([0-9a-Z-]*).*$/\1/p')"
|
||||
idSwap="$(grep -Ev '^[[:blank:]]*#|^$' /etc/fstab | sed -En 's/UUID=([0-9a-Z-]*).*swap.*$/\1/p')"
|
||||
if [ "$idSwap" ] && [ "$idResume" ] && [ "$idSwap" != "$idResume" ]; then
|
||||
alert_uuidResume+="id swap : $idSwap \nid resume: $idResume\n"
|
||||
|
@ -345,9 +353,9 @@ fi_disk(){ # 05/10/2017
|
|||
[ "$part_fix_tot" ] || figet_disk # appel figet_disk si pas déjà fait par fi_systeme
|
||||
text+='```\n'
|
||||
text+="$part_fix_tot \n" # espaces des partitions montées
|
||||
text+="disque(s) fixe(s): $disk_fix \n" # devices fixes
|
||||
text+="disque(s) amovible(s): $disk_hotplug \n\n" # devices hotplug
|
||||
text+="$disk_detail \n" # caractéristiques des disques trouvés
|
||||
text+="$(printf '%-22s: %s' "disque(s) fixe(s)" "$disk_fix") \n" # devices fixes
|
||||
text+="$(printf '%-22s: %s' "disque(s) amovible(s)" "$disk_hotplug") \n\n" # devices hotplug
|
||||
text+="$disk_detail \n" # caractéristiques des disques trouvés
|
||||
text+='```\n\n'
|
||||
text+="**types de disque** \n\n"
|
||||
text+="| ata | usb | mmc | nvme | \n"
|
||||
|
@ -367,16 +375,16 @@ fi_disk(){ # 05/10/2017
|
|||
text+='```\n'
|
||||
text+="$disk_lsblk \n"
|
||||
text+='```\n\n'
|
||||
text+='`'"grep -vE '^[[:blank:]]*#|^$' /etc/fstab"'` (fstab) \n' # fstab
|
||||
text+='`'"grep -Ev '^[[:blank:]]*#|^$' /etc/fstab"'` (fstab) \n' # fstab
|
||||
text+='```\n'
|
||||
text+="$fstab \n"
|
||||
text+='```\n\n'
|
||||
text+='`'"grep -Ev '^[[:blank:]]*#|^$' /etc/initramfs-tools/conf.d/resume"'` (resume) \n' # resume
|
||||
text+='`'"grep -Evs '^[[:blank:]]*#|^$' /etc/initramfs-tools/conf.d/resume"'` (resume) \n' # resume
|
||||
text+='```\n'
|
||||
if [ "$resume" ]; then
|
||||
text+="$resume \n"
|
||||
else
|
||||
text+="pas de fichier resume trouvé dans /etc/initramfs-tools/conf.d/ \n"
|
||||
text+="$alert_resume \n"
|
||||
fi
|
||||
text+='```\n\n'
|
||||
if [ "$alert_uuidResume" ]; then
|
||||
|
@ -474,9 +482,9 @@ fi_graph(){ # 06/10/2017
|
|||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
fi_localisation(){ # 25/09/2017
|
||||
fi_localisation(){ # 11/10/2017
|
||||
local locale timezone keymap keyboard timedatectl alert_Rtc alert_Rtc_info alert_NTP alert_Ntp_info text
|
||||
locale="$(grep -vE '#|^$' /etc/default/locale)"
|
||||
locale="$(grep -Ev '#|^$' /etc/default/locale)"
|
||||
timezone="$(< /etc/timezone)"
|
||||
if [ "$(which timedatectl)" ]; then
|
||||
timedatectl="$(timedatectl status --no-pager)"
|
||||
|
@ -490,10 +498,10 @@ activer le service: timedatectl set-ntp true
|
|||
et/ou installer le démon Ntp: apt install ntp \n"
|
||||
fi
|
||||
keymap="$(setxkbmap -query)"
|
||||
keyboard="$(grep -vE '#|^$' /etc/default/keyboard)"
|
||||
keyboard="$(grep -Ev '#|^$' /etc/default/keyboard)"
|
||||
###
|
||||
text="## localisation \n\n"
|
||||
text+='`'"grep -vE '#|^$' /etc/default/locale"'` \n'
|
||||
text+='`'"grep -Ev '#|^$' /etc/default/locale"'` \n'
|
||||
text+='```\n'
|
||||
text+="$locale \n"
|
||||
text+='```\n\n'
|
||||
|
@ -513,19 +521,19 @@ et/ou installer le démon Ntp: apt install ntp \n"
|
|||
text+='```\n'
|
||||
text+="$keymap \n"
|
||||
text+='```\n\n'
|
||||
text+='`'"grep -vE '#|^$' /etc/default/keyboard"'` \n'
|
||||
text+='`'"grep -Ev '#|^$' /etc/default/keyboard"'` \n'
|
||||
text+='```\n'
|
||||
text+="$keyboard \n"
|
||||
text+='```\n\n'
|
||||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
fi_log_xorg(){ # 10/10/2017
|
||||
fi_log_xorg(){ # 11/10/2017
|
||||
local logXorg text
|
||||
logXorg="$(grep -E '\(WW\)|\(EE\)|\(NI\)|\(\?\?\)' /var/log/Xorg.*.log /home/$user_/.local/share/xorg/Xorg.*.log 2>/dev/null)"
|
||||
logXorg="$(grep -Es '\(WW\)|\(EE\)|\(NI\)|\(\?\?\)' /var/log/Xorg.*.log /home/$user_/.local/share/xorg/Xorg.*.log)"
|
||||
###
|
||||
text="## journaux Xorg \n\n"
|
||||
text+='`'"grep -E '\(WW\)|\(EE\)|\(NI\)|\(\?\?\)' /var/log/Xorg.?.log /home/user/.local/share/xorg/Xorg.?.log"'` (xorg.log) \n'
|
||||
text+='`'"grep -Es '\(WW\)|\(EE\)|\(NI\)|\(\?\?\)' /var/log/Xorg.?.log /home/<user>/.local/share/xorg/Xorg.?.log"'` (xorg.log) \n'
|
||||
text+='```\n'
|
||||
text+="$logXorg \n"
|
||||
text+='```\n\n'
|
||||
|
@ -547,18 +555,18 @@ fi_mem(){ # 05/10/2017
|
|||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
fi_nm(){ # 25/09/2017
|
||||
fi_nm(){ # 11/10/2017
|
||||
[ -x "$(which nmcli)" ] || return 0 # nécessite root sur autre que debian?
|
||||
local nm_etat nm_conf text
|
||||
nm_etat="$(grep -vE '#|^$' /var/lib/NetworkManager/NetworkManager.state)"
|
||||
nm_conf="$(grep -vE '#|^$' /etc/NetworkManager/NetworkManager.conf)"
|
||||
nm_etat="$(grep -Ev '#|^$' /var/lib/NetworkManager/NetworkManager.state)"
|
||||
nm_conf="$(grep -Ev '#|^$' /etc/NetworkManager/NetworkManager.conf)"
|
||||
###
|
||||
text="## Network Manager \n\n"
|
||||
text+='`'"grep -vE '#|^$' /var/lib/NetworkManager/NetworkManager.state"'` \n'
|
||||
text+='`'"grep -Ev '#|^$' /var/lib/NetworkManager/NetworkManager.state"'` \n'
|
||||
text+='```\n'
|
||||
text+="$nm_etat \n"
|
||||
text+='```\n\n'
|
||||
text+='`'"grep -vE '#|^$' /etc/NetworkManager/NetworkManager.conf"'` \n'
|
||||
text+='`'"grep -Ev '#|^$' /etc/NetworkManager/NetworkManager.conf"'` \n'
|
||||
text+='```\n'
|
||||
text+="$nm_conf \n"
|
||||
text+='```\n\n'
|
||||
|
@ -597,7 +605,7 @@ fi_nonFree(){ # 25/09/2017
|
|||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
fi_reseau(){ # 09/10/2017
|
||||
fi_reseau(){ # 11/10/2017
|
||||
local slotNetCards netCards ip_a iwconfig interfaces route resolv text liste_canaux_wifi
|
||||
# netCards="$(lspci -nnk | grep -iEA 5 'network|ethernet')"
|
||||
# netCards="$(lspci -nnv | grep -iEA 15 'network|ethernet')"
|
||||
|
@ -611,14 +619,14 @@ fi_reseau(){ # 09/10/2017
|
|||
# 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)"
|
||||
interfaces="$(grep -Evr '#|^$' /etc/network/interfaces* 2>/dev/null)"
|
||||
interfaces="$(grep -Evrs '#|^$' /etc/network/interfaces*)"
|
||||
interfaces="$(sed -E 's/wpa-psk [[:graph:]]+/wpa-psk <WPA key removed>/; s/:/: /' <<< $interfaces )"
|
||||
resolv="$(grep -vE '#|^$' /etc/resolv.conf)"
|
||||
if [ "$(which iwlist)" ]; then #paquet wireless-tools requis
|
||||
resolv="$(grep -Ev '#|^$' /etc/resolv.conf)"
|
||||
if [ "$(which iwlist)" ]; then #paquet wireless-tools requis
|
||||
iwconfig="$(iwconfig 2>&1 | grep -v 'no wireless extensions' | grep -v '^$')"
|
||||
fi
|
||||
if [ "$(which iwlist)" ]; then # liste canaux wifi; paquet wireless-tools requis
|
||||
liste_canaux_wifi="$(iwlist chan 2>&1 | grep -vE 'no frequency information|^$')"
|
||||
liste_canaux_wifi="$(iwlist chan 2>&1 | grep -Ev 'no frequency information|^$')"
|
||||
fi
|
||||
netmgrpaths=("/usr/sbin/NetworkManager" "/usr/sbin/wicd" "/usr/sbin/connmand") # thanks wireless-info
|
||||
netmgrnames=("NetworkManager" "Wicd" "ConnMan") # thanks wireless-info
|
||||
|
@ -663,7 +671,7 @@ fi_reseau(){ # 09/10/2017
|
|||
text+='```\n'
|
||||
text+="$route \n"
|
||||
text+='```\n\n'
|
||||
text+='`'"grep -Evr '#|^$' /etc/network/interfaces*"'` \n'
|
||||
text+='`'"grep -Evrs '#|^$' /etc/network/interfaces*"'` \n'
|
||||
text+='```\n'
|
||||
text+="$interfaces \n"
|
||||
text+='```\n\n'
|
||||
|
@ -699,7 +707,7 @@ fi_reseau(){ # 09/10/2017
|
|||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
fi_sources(){ # 09/10/2017
|
||||
fi_sources(){ # 11/10/2017
|
||||
if [ -z "(which dpkg)" ]; then
|
||||
f__info "le système n'est pas basé sur dpkg. les informations correspondantes ne peuvent "
|
||||
"donc être ""extraites \n"
|
||||
|
@ -708,7 +716,7 @@ fi_sources(){ # 09/10/2017
|
|||
local sources dateMaj nb_packages apt autoremove paquetToRemove httpredir upgradable nbUpgradable
|
||||
local paquetBiz text
|
||||
printf "."
|
||||
sources="$(grep -rvE '^#|^$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list 2>/dev/null)"
|
||||
sources="$(grep -Evrs '^#|^$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list)"
|
||||
sources="$(sed 's/:deb/: deb/; s/ / /g' <<< $sources)"
|
||||
dateMaj="$(date -r /var/cache/apt/pkgcache.bin '+%d/%m/%Y %H:%M %z')" # /var/lib/dpkg/
|
||||
nb_packages="$(dpkg -l | grep -c '^ii')"
|
||||
|
@ -724,7 +732,7 @@ fi_sources(){ # 09/10/2017
|
|||
paquetBiz="$(dpkg -l | gawk 'FNR>5 && ! /^i/ {print $1, $2, $3}')"
|
||||
###
|
||||
text="## sources list \n\n"
|
||||
text+='`'"grep -rvE '^#|^$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list 2>/dev/null"'` \n'
|
||||
text+='`'"grep -Evrs '^#|^$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list"'` \n'
|
||||
text+='```\n'
|
||||
text+="$sources \n"
|
||||
text+='```\n\n'
|
||||
|
@ -761,12 +769,12 @@ fi_sources(){ # 09/10/2017
|
|||
}
|
||||
|
||||
# affiche configurations ssid
|
||||
fi_ssid(){ # 10/10/2017
|
||||
fi_ssid(){ # 11/10/2017
|
||||
[ "$(which nmcli)" ] || f__error "il manque NetworkManager"
|
||||
local nm_ssid file="/tmp/$$-$RANDOM-fi_ssid" text
|
||||
# nm_ssid="$(grep -vE '#|^$' /etc/NetworkManager/system-connections/*)"
|
||||
# nm_ssid="$(grep -Ev '#|^$' /etc/NetworkManager/system-connections/*)"
|
||||
[ "$EUID" -eq 0 ] || echo
|
||||
f__sudo "grep -vE '#|^$' /etc/NetworkManager/system-connections/* > $file ; \
|
||||
f__sudo "grep -Ev '#|^$' /etc/NetworkManager/system-connections/* > $file ; \
|
||||
chown $user_: $file"
|
||||
if [ "$?" != "0" ]; then
|
||||
f__info "\n la consultation des connections NetworkManager$RED a échoué$BLUE (droits root requis, échec authentification?)" \
|
||||
|
@ -780,7 +788,7 @@ fi_ssid(){ # 10/10/2017
|
|||
###
|
||||
f__info "la$RED clé du réseau wifi étant visible $STD""aucun rapport n'a été créé"
|
||||
text="## configuration(s) ssid networkmanager \n\n"
|
||||
text+="$GREEN""grep -vE '#|^$' /etc/NetworkManager/system-connections/*$STD \n\n"
|
||||
text+="$GREEN""grep -Ev '#|^$' /etc/NetworkManager/system-connections/*$STD \n\n"
|
||||
text+="$nm_ssid \n\n"
|
||||
echo -e "$text"
|
||||
}
|
||||
|
@ -800,7 +808,7 @@ fi_system_analyse(){ # 25/09/2017
|
|||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
fi_systeme(){ # 10/10/2017
|
||||
fi_systeme(){ # 11/10/2017
|
||||
local mbr description uname bootImage xorg shells lastboot uptime pluriel charge text
|
||||
[ -d /sys/firmware/efi ] && mbr="**EFI**" || mbr="**Legacy (mbr)**"
|
||||
[ -x "/usr/bin/lsb_release" ] && description="$(lsb_release -ds)" #dépend de apt install lsb-release, sur debian, en standard, juste : lsb-base
|
||||
|
@ -812,25 +820,26 @@ fi_systeme(){ # 10/10/2017
|
|||
if [ -z "$xorg" ]; then
|
||||
[ "$(ps -ef | grep -c 'wayland')" -gt 1 ] && xorg="wayland" || xorg="indéterminé"
|
||||
fi
|
||||
shells="$(grep -vE '^[[:blank:]]*#|^$' /etc/shells | sed 's/\/bin\///' | tr '\n' ' ')"
|
||||
shells="$(grep -Ev '^[[:blank:]]*#|^$' /etc/shells | sed 's/\/bin\///' | tr '\n' ' ')"
|
||||
# lastboot="$(last -n 1 --time-format iso reboot | gawk 'FNR==1 {sub(/T/," ",$5);print $5}')" # remis à jours en début de mois ?!!
|
||||
lastboot="$(date -r /var/run/utmp '+%d/%m/%Y %H:%M %z')"
|
||||
uptime="$(uptime -p | sed 's/up/depuis/; s/week/semaine/; s/weeks/semaines/; s/days/jours/; s/day/jour/; s/hour[s]*/h/; s/minute[s]*/mn/')"
|
||||
charge="$(uptime | sed -En 's/.*load average: (.*), (.*), (.*)/\1 \2 \3/; s/,/./gp')"
|
||||
cores="$(sort -u /proc/cpuinfo | grep -c '^core id')"
|
||||
thread="$(grep -c "^processor" /proc/cpuinfo)"
|
||||
|
||||
cores="$(sort -u /proc/cpuinfo | grep -c '^core id')"
|
||||
thread="$(grep -c "^processor" /proc/cpuinfo)"
|
||||
###
|
||||
figet_cpu
|
||||
figet_gpu
|
||||
figet_distro
|
||||
figet_wm
|
||||
figet_shell
|
||||
figet_disk
|
||||
figet_battery
|
||||
figet_resolution
|
||||
figet_cpu
|
||||
figet_de
|
||||
figet_dmi
|
||||
figet_disk
|
||||
figet_distro
|
||||
figet_gpu
|
||||
figet_resolution
|
||||
figet_shell
|
||||
figet_wm
|
||||
text="## système \n\n"
|
||||
text+="$fget_dmi \n"
|
||||
text+="| | | \n"
|
||||
text+=" --- | --- \n"
|
||||
text+="CPU | **$fget_cpu** \n"
|
||||
|
@ -854,7 +863,7 @@ thread="$(grep -c "^processor" /proc/cpuinfo)"
|
|||
if [ "$batt_detail" ]; then
|
||||
[ "$batt_nb" -gt "1" ] && pluriel="(s)"
|
||||
text+="$batt_nb batterie$pluriel présente$pluriel: \n"
|
||||
text+="$(sed -nE 's/^BAT(.*)$/ BAT\1/p' <<< $batt_detail) \n"
|
||||
text+="$(sed -En 's/^BAT(.*)$/ BAT\1/p' <<< $batt_detail) \n"
|
||||
fi
|
||||
text+="dernier boot: $lastboot, uptime: $uptime \n"
|
||||
text+="charge système depuis les 1, 5 et 15 dernières minutes: $charge \n"
|
||||
|
@ -880,10 +889,18 @@ fi_usb(){ # 25/09/2017
|
|||
}
|
||||
|
||||
# informations batterie(s), assigne $batt_nb $batt_detail
|
||||
figet_battery(){ # 10/10/2017
|
||||
figet_battery(){ # 11/10/2017
|
||||
local batt_alim batt_unit batt_capa_design batt_capa_full batt_capa_now batt_conso
|
||||
local batt_voltage batt_status batt_sn batt_cycle batt_alarm tempo batt_restant ibat
|
||||
local batt_voltage batt_status batt_sn batt_cycle alert_batterie tempo batt_restant ibat
|
||||
# batt_nb="$(grep 'Battery' /sys/class/power_supply/*/type | grep -c .)"
|
||||
batt_nb="$(ls /sys/class/power_supply/ | grep -c 'BAT')"
|
||||
if [ ! -d /sys/class/power_supply ]; then # anciennes interfaces ou inconnu
|
||||
[ -d /proc/acpi/battery ] && batt_detail="ancien ACPI non géré"
|
||||
[ -f /proc/apm ] && batt_detail="batteries APM non gérées"
|
||||
[ "$batt_detail" ] || batt_detail="répertoire power_supply inaccessible"
|
||||
batt_nb="-1"
|
||||
return 1
|
||||
fi
|
||||
if [ "$batt_nb" -gt "0" ]; then
|
||||
# extraction valeur
|
||||
batt_alim="$(grep . /sys/class/power_supply/AC*/online | sed -n '1p')"
|
||||
|
@ -915,8 +932,8 @@ figet_battery(){ # 10/10/2017
|
|||
batt_status="$(cat $ibat/status 2>/dev/null)"
|
||||
batt_sn="$(cat $ibat/serial_number 2>/dev/null)"
|
||||
batt_cycle="$(cat $ibat/cycle_count 2>/dev/null)"
|
||||
batt_alarm="$(cat $ibat/alarm 2>/dev/null)"
|
||||
[ "$batt_alarm" == "0" ] && unset batt_alarm
|
||||
alert_batterie="$(cat $ibat/alarm 2>/dev/null)"
|
||||
[ "$alert_batterie" == "0" ] && unset alert_batterie
|
||||
# calculs
|
||||
if [ "$batt_capa_design" != "na" ] && [ "$batt_capa_full" ]; then
|
||||
batt_sante="$(gawk '{printf "%.1f", $1/$2*100}' <<< "$batt_capa_full $batt_capa_design")"
|
||||
|
@ -955,7 +972,7 @@ figet_battery(){ # 10/10/2017
|
|||
[ "$batt_capa_design" != "na" ] && batt_detail+="pleine charge théorique: $batt_capa_design $batt_unit => "
|
||||
[ "$batt_sante" ] && batt_detail+="$batt_sante % (indicateur santé)"$'\n'
|
||||
[ "$batt_restant" ] && batt_detail+="$batt_restant"$'\n'
|
||||
[ "$batt_alarm" ] && batt_detail+="alarme batterie: $batt_alarm"$'\n'
|
||||
[ "$alert_batterie" ] && batt_detail+="alarme batterie: $alert_batterie"$'\n'
|
||||
done
|
||||
batt_detail="$(sed 's/\n//' <<< $batt_detail)"
|
||||
fi
|
||||
|
@ -1041,26 +1058,27 @@ figet_de(){ # thanks neofetch, assigne $fget_de #09/10/2017
|
|||
|
||||
# assigne $disk_detail $disk_hotplug $disk_fix $part_fix $part_hotplug $part_fix_tot
|
||||
# $disk_ata $disk_usb $disk_mmc $disk_nvme
|
||||
figet_disk(){ # 09/10/2017
|
||||
figet_disk(){ # 11/10/2017
|
||||
local vendor_model idisk
|
||||
# détails disques et séquences disques fixes et amovibles, $disk_detail, $disk_fix, $disk_hotplug
|
||||
unset disk_hotplug disk_fix part_fix part_hotplug
|
||||
disk_detail="disque: vendeur modèle n° serie révision"$'\n'
|
||||
disk_detail="$(printf '%6s %8s %-24s %-s' "disque" "taille" "vendeur modèle" "n° serie révision")"$'\n'
|
||||
for idisk in $(grep -v 'loop' <<< $(ls /sys/block/)); do
|
||||
vendor_model="$(sed -n '2p' <<< $(lsblk -o VENDOR,MODEL /dev/$idisk) | xargs )"
|
||||
vendor_model="$(lsblk -no VENDOR,MODEL /dev/$idisk | xargs )"
|
||||
if [ -z "$vendor_model" ]; then
|
||||
vendor_model=" na na "
|
||||
vendor_model="$(ls -l /dev/disk/by-id/ | gawk '{print $9,$11}' | sed '/-part/d' | grep $idisk)"
|
||||
vendor_model="$(sed -E 's/.*-(.*)_[0-9]+.*$/\1/;s/_/ /g' <<< $vendor_model)"
|
||||
fi
|
||||
disk_detail+="$idisk: $vendor_model $(sed -n '2p' <<< "$(lsblk -o SERIAL,REV /dev/$idisk)")"$'\n'
|
||||
if [ "$(sed -n '2p' <<< $(lsblk -o HOTPLUG /dev/$idisk) | xargs)" == "1" ]; then
|
||||
disk_detail+="$(printf '%6s %8s ' $idisk $(lsblk -no SIZE -d /dev/$idisk))"
|
||||
disk_detail+="$(printf '%-24s %-s' "$vendor_model" "$(lsblk -no SERIAL,REV /dev/$idisk | xargs)")"$'\n'
|
||||
if [ "$(sed -n '2p' <<< $(lsblk -no HOTPLUG /dev/$idisk) | xargs)" == "1" ]; then
|
||||
disk_hotplug+="$idisk "
|
||||
else
|
||||
disk_fix+="$idisk " # "sda sdb sdc"
|
||||
fi
|
||||
done
|
||||
disk_detail=${disk_detail::-1}
|
||||
disk_detail=${disk_detail::-1} # suppression dernier \n
|
||||
# séquences partitions fixes, $part_fix, $(printf '/dev/%s ' $part_fix), "sda1 sda2 sda3"
|
||||
part_fix="$(lsblk -o KNAME,MOUNTPOINT $(printf '/dev/%s ' $disk_fix) 2>/dev/null | grep '/')"
|
||||
part_fix="$(gawk '{print $1}' <<< $part_fix | tr '\n' ' ')"
|
||||
|
@ -1109,6 +1127,60 @@ figet_distro(){ # thanks neofetch, assigne $fget_distro # 09/10/2017
|
|||
fget_distro="$distro"
|
||||
}
|
||||
|
||||
# informations DMI, assigne $fget_dmi
|
||||
figet_dmi(){ # 11/10/2017
|
||||
local product board bios tempo idmi indic1 indic2
|
||||
unset indic1 indic2
|
||||
for idmi in sys_vendor product_name product_version chassis_type; do
|
||||
tempo=$(cat /sys/class/dmi/id/$idmi 2>/dev/null)
|
||||
tempo=$(sed 's/x.xx*//' <<< $tempo | xargs)
|
||||
if [ "$idmi" == "chassis_type" ]; then
|
||||
[ "$tempo" == "10" ] && tempo="(Notebook)" || tempo="($tempo)"
|
||||
fi
|
||||
[[ "$idmi" == "sys_vendor" || "$idmi" == "product_name" ]] && indic1+="$tempo "
|
||||
product+="$tempo "
|
||||
done
|
||||
for idmi in board_vendor board_name board_version; do
|
||||
tempo=$(cat /sys/class/dmi/id/$idmi 2>/dev/null)
|
||||
tempo=$(sed 's/x.xx*//' <<< $tempo | xargs)
|
||||
[[ "$idmi" == "board_vendor" || "$idmi" == "board_name" ]] && indic2+="$tempo "
|
||||
board+="$tempo "
|
||||
done
|
||||
for idmi in bios_vendor bios_version bios_date; do
|
||||
tempo=$(cat /sys/class/dmi/id/$idmi 2>/dev/null)
|
||||
tempo=$(sed 's/x.xx*//' <<< $tempo | xargs)
|
||||
bios+="$tempo "
|
||||
done
|
||||
fget_dmi=$(printf '%7s: %s' "produit" "$product")$'\n'
|
||||
[ "$indic1" != "$indic2" ] && fget_dmi+=$(printf '%7s: %s' "board" "$board")$'\n'
|
||||
fget_dmi+=$(printf '%7s: %s' "bios" "$bios")$'\n'
|
||||
return 0
|
||||
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
|
||||
}
|
||||
|
||||
figet_dmi_test(){ # 11/10/2017
|
||||
# for i in $(ls /sys/class/dmi/id/); do printf "$i: "; cat /sys/class/dmi/id/$i; done
|
||||
local idmi text
|
||||
text="## dmi test \n\n"
|
||||
text+='```\n'
|
||||
for idmi in $(ls /sys/class/dmi/id/); do
|
||||
[[ "$idmi" == "modalias" || "$idmi" == "uevent" ]] && continue
|
||||
[ -d "/sys/class/dmi/id/$idmi" ] && continue
|
||||
if [ -r "/sys/class/dmi/id/$idmi" ]; then
|
||||
text+="$idmi: $(cat /sys/class/dmi/id/$idmi) \n"
|
||||
else
|
||||
text+="$idmi: - \n"
|
||||
fi
|
||||
done
|
||||
text+='```\n\n'
|
||||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
figet_gpu(){ # thanks neofetch, assigne $fget_gpu # 09/10/2017
|
||||
local gpu="$(lspci -mm | gawk -F '\\"|\\" \\"' '/"Display|"3D|"VGA/ {print $3 " " $4}')"
|
||||
case "$gpu" in
|
||||
|
@ -1613,6 +1685,9 @@ function display_menu {
|
|||
reply="$(sed 's/-call/all/' <<< $reply)"
|
||||
exec $0 "$reply"
|
||||
}
|
||||
prg_alert_crit(){ # 11/10/2017
|
||||
[ -f /proc/cpuinfo ] || f__error "/proc/cpuinfo non trouvé" "/proc ne doit pas être monté"
|
||||
}
|
||||
|
||||
# initialisation
|
||||
PATH='/usr/sbin:/usr/bin:/sbin:/bin'; TERM=xterm ; IFS=$' \t\n'
|
||||
|
@ -1630,7 +1705,8 @@ if [ "$retourFUser" -eq 2 ]; then
|
|||
fi
|
||||
|
||||
[ "$(grep -o 'version 4' <<< $(bash --version) | sed 's/version //')" -ge "4" ] || f__error "bash version 4"
|
||||
f__requis "gawk wget ip>iproute2" # requis pour fonctionnement programme
|
||||
f__requis "gawk wget ip>iproute2 lspci>pciutils" # requis pour fonctionnement programme
|
||||
prg_alert_crit
|
||||
|
||||
options=$@
|
||||
# traitement option
|
||||
|
@ -1700,6 +1776,11 @@ for j in $options; do
|
|||
fi_batt
|
||||
prg_3
|
||||
exit ;; # rapport batterie avec affichage /sys/class/power_supply/BAT?/uevent
|
||||
--debug-dmi )
|
||||
prg_1
|
||||
figet_dmi_test
|
||||
prg_3
|
||||
exit ;; # rapport batterie avec affichage /sys/class/power_supply/BAT?/uevent
|
||||
--dmesg )
|
||||
prg_1
|
||||
fi_log_xorg
|
||||
|
|
|
@ -4,12 +4,18 @@
|
|||
## todo
|
||||
|
||||
* placer ln dans /usr/local/bin au lieu de /usr/bin ?
|
||||
* hasher les cmds pour gain temps exécution?
|
||||
* option erreur pour f__info?
|
||||
* revoir figet_ip, gateway
|
||||
* éviter 169.254.10.12/16 ( enp3s0 ) (ethernet) si non branché
|
||||
---
|
||||
|
||||
|
||||
|
||||
## 2.2.0 11/10/2017
|
||||
|
||||
* figet_disk, fi_disk: révision, présentation, espace disk dans détails, alert resume
|
||||
* figet_battery: erreur anciennes batteries APM ou interface ACPI
|
||||
* nouveau: figet_dmi, figet_dmi_test
|
||||
* fix f__sudo : fonctionnement avec sudo
|
||||
|
||||
## 2.1.0 10/10/2017
|
||||
|
||||
|
|
Loading…
Reference in New Issue