mirror of https://framagit.org/kyodev/kyopages.git
getInfo 1.32.0
This commit is contained in:
parent
dfa54adf4a
commit
00c89c7327
203
scripts/getInfo
203
scripts/getInfo
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
version=1.31.0
|
||||
date="01/10/2017"
|
||||
version=1.32.0
|
||||
date="02/10/2017"
|
||||
projet="simpledeb"
|
||||
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
|
||||
script="getInfo"
|
||||
|
@ -137,10 +137,18 @@ f__requis(){ # 22/09/2017
|
|||
# user ayant initié la session graphique, assigne $user_
|
||||
# return 1 sur échec identification user, return 2 sur absence home/
|
||||
# gestion variable environnement user avec: USER_INSTALL=user script
|
||||
f__user(){ # 30/08/2017-4
|
||||
f__user(){ # 02/10/2017-4
|
||||
if [ "$USER_INSTALL" ]; then # user_ via variable environnement, moyen d'injecter root
|
||||
user_="$USER_INSTALL";
|
||||
return 0
|
||||
elif [[ "$TERM" =~ linux ]]; then #debian 9 recovery ou nomodeset TERM=linux
|
||||
if [ "$USER" ]; then
|
||||
user_="$USER"
|
||||
elif [ "$EUID" -eq 0 ]; then
|
||||
user_="root"
|
||||
return 0
|
||||
fi
|
||||
echo "test \$TERM:$TERM"
|
||||
fi
|
||||
local user_id test root_login
|
||||
root_login="$(grep ':0:' /etc/passwd | cut -d':' -f1)" || root_login="root"
|
||||
|
@ -258,7 +266,7 @@ fi_batt(){ # 28/09/2017
|
|||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
fi_cpu(){ # 29/09/2017
|
||||
fi_cpu(){ # 02/10/2017
|
||||
local cpu_addr cpu_bogomips cpu_flags memsys swappiness 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')"
|
||||
|
@ -269,7 +277,7 @@ fi_cpu(){ # 29/09/2017
|
|||
text="## processeur / mémoire \n\n"
|
||||
figet_cpu
|
||||
text+='```\n'
|
||||
text+="CPU: $cpu \n"
|
||||
text+="CPU: $figet_cpu \n"
|
||||
text+="adressage: $cpu_addr \n"
|
||||
text+="bogomips: $cpu_bogomips \n"
|
||||
text+='```\n\n'
|
||||
|
@ -279,23 +287,23 @@ fi_cpu(){ # 29/09/2017
|
|||
text+='```\n\n'
|
||||
figet_memory
|
||||
text+='```\n'
|
||||
text+="mémoire Ram utilisée/totale: $memory \n\n"
|
||||
text+="mémoire Ram utilisée/totale: $figet_memory \n\n"
|
||||
text+="mémoire système: $memsys \n\n"
|
||||
text+="swappiness: $swappiness \n"
|
||||
text+='```\n\n'
|
||||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
fi_disk(){ # 29/09/2017
|
||||
fi_disk(){ # 02/10/2017
|
||||
local fstab resume idResume idSwap alert_uuidResume text
|
||||
fstab="$(grep -vE '#|^$' /etc/fstab)"
|
||||
resume="$(grep -Ev '#|^$' /etc/initramfs-tools/conf.d/resume 2>/dev/null)"
|
||||
idResume="$(grep -Ev '#|^$' /etc/initramfs-tools/conf.d/resume 2>/dev/null | sed -En 's/.*UUID=([0-9a-Z-]*).*$/\1/p')"
|
||||
idSwap="$(grep -Ev '#|^$' /etc/fstab | sed -En 's/^UUID=([0-9a-Z-]*).*swap.*$/\1/p')"
|
||||
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')"
|
||||
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"
|
||||
alert_uuidResume+="_vérifier la config resume_, l'UUID ne correspond pas à celui du swap. "
|
||||
alert_uuidResume+="En cas de multi-boot. vous pouvez utiliser _RESUME=auto_ ou _RESUME=/dev/sdx_ \n\n"
|
||||
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"
|
||||
fi
|
||||
###
|
||||
text="## disque(s) \n\n"
|
||||
|
@ -315,20 +323,20 @@ fi_disk(){ # 29/09/2017
|
|||
text+='```\n'
|
||||
text+="$disk_utilisation \n"
|
||||
text+='```\n\n'
|
||||
text+='`'"grep -vE '#|^$' /etc/fstab"'` (fstab) \n' # fstab
|
||||
text+='```\n'
|
||||
text+="$fstab \n"
|
||||
text+='```\n\n'
|
||||
text+='`'"lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID"'` (disques) \n' # lsblk
|
||||
text+='```\n'
|
||||
text+="$disk_lsblk \n"
|
||||
text+='```\n\n'
|
||||
text+='`'"grep -Ev '#|^$' /etc/initramfs-tools/conf.d/resume"'` (resume) \n' # resume
|
||||
text+='`'"grep -vE '^[[: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+='```\n'
|
||||
if [ "$resume" ]; then
|
||||
text+="$resume \n"
|
||||
else
|
||||
text+="pas de fichier resume trouvé \n"
|
||||
text+="pas de fichier resume trouvé dans /etc/initramfs-tools/conf.d/ \n"
|
||||
fi
|
||||
text+='```\n\n'
|
||||
if [ "$alert_uuidResume" ]; then
|
||||
|
@ -391,9 +399,9 @@ fi_gpu(){ # 01/10/2017
|
|||
text+="| | | \n"
|
||||
text+=" --- | --- \n"
|
||||
figet_gpu
|
||||
text+="GPU | **$gpu** \n\n"
|
||||
figet_resolution
|
||||
text+="**résolution: $resolution** \n\n"
|
||||
text+="GPU | **$figet_gpu** \n\n"
|
||||
[ "$figet_resolution" ] || figet_resolution
|
||||
text+="**résolution: $figet_resolution** \n\n"
|
||||
text+='`'"lspci -nnv | grep -iEA 13 'vga|display|3d'"'` \n'
|
||||
text+='```\n'
|
||||
text+="$graphCards"
|
||||
|
@ -606,12 +614,12 @@ fi_reseau(){ # 01/10/2017
|
|||
text+="### modules réseau \n\n"
|
||||
text+="liste non garantie complète \n"
|
||||
text+='```\n'
|
||||
text+="$mod_net \n"
|
||||
text+="$modules_net \n"
|
||||
text+='```\n\n'
|
||||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
fi_sources(){ # 30/09/2017
|
||||
fi_sources(){ # 02/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"
|
||||
|
@ -622,15 +630,15 @@ fi_sources(){ # 30/09/2017
|
|||
printf "."
|
||||
sources="$(grep -rvE '^#|^$' /etc/apt/sources.list /etc/apt/sources.list.d/*.list 2>/dev/null)"
|
||||
sources="$(sed 's/:deb/: deb/; s/ / /g' <<< $sources)"
|
||||
dateMaj="$(date -r /var/cache/apt/pkgcache.bin)" # /var/lib/dpkg/
|
||||
dateMaj="$(date -r /var/cache/apt/pkgcache.bin '+%d/%m/%Y %H:%M %z')" # /var/lib/dpkg/
|
||||
nb_packages="$(dpkg -l | grep -c '^ii')"
|
||||
printf "."
|
||||
apt="$(LC_ALL=C apt-get autoremove --simulate)"
|
||||
autoremove="$(grep -c 'Remv' <<< $apt)"
|
||||
paquetToRemove="$(grep 'Remv' <<< $apt | sed 's/Remv //; s/\[[0-9.-]*\]//' | tr '\n' ' ')"
|
||||
paquetToRemove="$(sed -En 's/Remv (.*)\[[0-9.-]*\]/\1/p' <<< $apt | tr '\n' ' ')"
|
||||
printf "."
|
||||
httpredir="$(grep 'httpredir' <<< $sources)"
|
||||
upgradable="$(LC_ALL=C apt list --upgradable 2>/dev/null | sed 's/Listing...//' | grep -v '^$')"
|
||||
upgradable="$(LC_ALL=C apt list --upgradable 2>/dev/null | sed '1d')"
|
||||
[ "$upgradable" ] && nbUpgradable="$(grep -c '.' <<< "$upgradable")"
|
||||
printf "."
|
||||
paquetBiz="$(dpkg -l | awk 'FNR>5 && ! /^i/ {print $1, $2, $3}')"
|
||||
|
@ -700,31 +708,33 @@ fi_system_analyse(){ # 25/09/2017
|
|||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
fi_systeme(){ # 30/09/2017
|
||||
fi_systeme(){ # 02/10/2017
|
||||
local mbr description uname bootImage xorg shells lastboot uptime text pluriel
|
||||
[ -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
|
||||
uname="$(uname -rmo)"
|
||||
bootImage="$(sed 's/root=[^ ]*//;s/[ ]\+/, /g' /proc/cmdline)"
|
||||
bootImage="$(awk '/BOOT_IMAGE/ {print $1}' /proc/cmdline)"
|
||||
bootImage="$(awk '{print $1}{i=2; while (i <= NF-1) { print " ",$i; i++}}' /proc/cmdline)"
|
||||
initDaemon="$(ps -p1 | awk 'FNR==2 {print $4}')" #? ps -ax | awk '$1==1' ou ps -p1 | awk '$1==1'
|
||||
xorg="$XDG_SESSION_TYPE"
|
||||
if [ -z "$xorg" ]; then
|
||||
[ "$(ps -ef | grep -c 'wayland')" -gt 1 ] && xorg="wayland" || xorg="indéterminé"
|
||||
fi
|
||||
shells="$(grep -v "^#" /etc/shells | sed 's/\/bin\///' | tr '\n' ' ')"
|
||||
lastboot="$(last -n 1 --time-format iso reboot | awk 'FNR==1 {sub(/T/," ",$5);print $5}')"
|
||||
shells="$(grep -vE '^[[:blank:]]*#|^$' /etc/shells | sed 's/\/bin\///' | tr '\n' ' ')"
|
||||
# lastboot="$(last -n 1 --time-format iso reboot | awk '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/')"
|
||||
###
|
||||
text="## système \n\n"
|
||||
text+="| | | \n"
|
||||
text+=" --- | --- \n"
|
||||
figet_cpu
|
||||
text+="CPU | **$cpu** \n"
|
||||
text+="CPU | **$figet_cpu** \n"
|
||||
figet_gpu
|
||||
text+="GPU | **$gpu** \n"
|
||||
text+="GPU | **$figet_gpu** \n"
|
||||
text+="boot | $mbr \n"
|
||||
figet_distro
|
||||
text+="distribution | **$distro** \n\n"
|
||||
text+="distribution | **$figet_distro** \n\n"
|
||||
f__architecture || f__info "Architecture non supportée" "vous pouvez contacter contacter $projet $contact si vous voulez aider à parfaire le script"
|
||||
text+='```\n'
|
||||
text+="architecture: $architecture \n"
|
||||
|
@ -733,14 +743,14 @@ fi_systeme(){ # 30/09/2017
|
|||
text+="$bootImage \n"
|
||||
text+="démon d'initialisation: $initDaemon \n"
|
||||
figet_resolution
|
||||
text+="résolution: $resolution \n"
|
||||
text+="résolution: $figet_resolution \n"
|
||||
text+="serveur d'affichage: $xorg \n"
|
||||
figet_de
|
||||
text+="desktop (DE): $de \n"
|
||||
text+="desktop (DE): $figet_de \n"
|
||||
figet_wm
|
||||
text+="window manager: $wm \n"
|
||||
text+="window manager: $figet_wm \n"
|
||||
figet_shell
|
||||
text+="shell actif: $shell \n"
|
||||
text+="shell actif: $figet_shell \n"
|
||||
text+="shells installés: $shells \n"
|
||||
figet_disk
|
||||
text+="$part_fix_tot \n"
|
||||
|
@ -773,9 +783,9 @@ fi_usb(){ # 25/09/2017
|
|||
}
|
||||
|
||||
# informations batterie(s), assigne $batt_nb $batt_detail
|
||||
figet_battery(){ # 30/09/2017
|
||||
figet_battery(){ # 02/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 tempo batt_restant
|
||||
local batt_voltage batt_status batt_sn batt_cycle tempo batt_restant ibat
|
||||
batt_nb="$(ls /sys/class/power_supply/ | grep -c 'BAT')"
|
||||
if [ "$batt_nb" -gt "0" ]; then
|
||||
# extraction valeur
|
||||
|
@ -846,14 +856,12 @@ figet_battery(){ # 30/09/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_detail+=$'\n'
|
||||
done
|
||||
unset ibat
|
||||
fi
|
||||
}
|
||||
|
||||
figet_cpu() { # thanks neofetch, assigne $cpu # 30/09/2017
|
||||
local speed_dir temp_dir speedMin speed speedMin speed temp cores
|
||||
figet_cpu() { # thanks neofetch, assigne $figet_cpu # 02/10/2017
|
||||
local cpu speed_dir temp_dir speedMin speed speedMin speed temp cores
|
||||
cpu="$(awk -F ': | @' '/model name|Processor/ {printf $2; exit}' /proc/cpuinfo)"
|
||||
speed_dir="/sys/devices/system/cpu/cpu0/cpufreq"
|
||||
temp_dir="/sys/class/hwmon/hwmon0/temp1_input"
|
||||
|
@ -895,28 +903,45 @@ figet_cpu() { # thanks neofetch, assigne $cpu # 30/09/2017
|
|||
cpu="${cpu//with Radeon * Graphics}"
|
||||
# Add cpu cores to output
|
||||
cpu="${cpu/@/(${cores})phys. (${coresT})logi. @}"
|
||||
figet_cpu="$cpu"
|
||||
}
|
||||
|
||||
figet_de() { # thanks neofetch, assigne $de
|
||||
de="${XDG_CURRENT_DESKTOP/i3}"
|
||||
figet_de() { # thanks neofetch, assigne $figet_de #02/10/2017
|
||||
# local de="${XDG_CURRENT_DESKTOP/i3}" #supprime i3??...
|
||||
local de="$XDG_CURRENT_DESKTOP"
|
||||
de="${de/'X-'}"
|
||||
de="${de/Budgie:GNOME/Budgie}"
|
||||
# Fallback to using xprop.
|
||||
[[ -n "$DISPLAY" && -z "$de" ]] && de="$(xprop -root | awk '/KDE_SESSION_VERSION|^_MUFFIN|xfce4|xfce5/')"
|
||||
if [[ -n "$DISPLAY" && -z "$de" ]]; then
|
||||
de="$(xprop -root | awk '/KDE_SESSION_VERSION|^_MUFFIN|xfce4|xfce5|TDE_FULL_SESSION/')" #ajout TDE_FULL_SESSION, oubli?à tester
|
||||
fi
|
||||
# Format strings
|
||||
case "$de" in
|
||||
"KDE_SESSION_VERSION"*) de="KDE${de/* = }" ;;
|
||||
*"TDE_FULL_SESSION"*) de="Trinity" ;;
|
||||
*"MUFFIN"* | "Cinnamon") de="$(cinnamon --version)"; de="${de:-Cinnamon}" ;;
|
||||
*"xfce4"*) de="XFCE4" ;;
|
||||
*"xfce5"*) de="XFCE5" ;;
|
||||
"KDE_SESSION_VERSION"* )
|
||||
de="KDE${de/* = }"
|
||||
;;
|
||||
*"TDE_FULL_SESSION"* )
|
||||
de="Trinity"
|
||||
;;
|
||||
*"MUFFIN"* | "Cinnamon" )
|
||||
de="$(cinnamon --version)"
|
||||
de="${de:-Cinnamon}"
|
||||
;;
|
||||
*"xfce4"*)
|
||||
de="xfce4"
|
||||
;;
|
||||
*"xfce5"*)
|
||||
de="xfce5"
|
||||
;;
|
||||
esac
|
||||
figet_de="${de,,}"
|
||||
figet_de="${figet_de^}"
|
||||
}
|
||||
|
||||
# assigne $disk_lsblk $disk_utilisation $disk_detail $disk_hotplug $disk_fix $part_fix
|
||||
# $part_hotplug $part_fix_tot $disk_ata $disk_usb $disk_mmc $disk_nvme
|
||||
figet_disk(){ # 30/09/2017
|
||||
local vendor_model
|
||||
figet_disk(){ # 02/10/2017
|
||||
local vendor_model idisk
|
||||
disk_lsblk="$(lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID)"
|
||||
disk_utilisation="$(df -h --output=source,target,fstype,size,used,avail,pcent --exclude=tmpfs --exclude=devtmpfs | grep -Ev 'devpts|none|proc|sys|tmpfs|udev')"
|
||||
# détails disques et séquences disques fixes et amovibles, $disk_detail, $disk_fix, $disk_hotplug
|
||||
|
@ -936,7 +961,7 @@ figet_disk(){ # 30/09/2017
|
|||
disk_fix+="$idisk " # "sda sdb sdc"
|
||||
fi
|
||||
done
|
||||
unset idisk
|
||||
disk_detail=${disk_detail::-1}
|
||||
# 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="$(awk '{print $1}' <<< $part_fix | tr '\n' ' ')"
|
||||
|
@ -965,16 +990,16 @@ figet_disk(){ # 30/09/2017
|
|||
[ "$disk_nvme" ] || disk_nvme="-"
|
||||
}
|
||||
|
||||
figet_distro() { # thanks neofetch, assigne $distro # 23/09/2017
|
||||
figet_distro() { # thanks neofetch, assigne $figet_distro # 02/10/2017
|
||||
local distro file
|
||||
if type -p lsb_release >/dev/null; then distro="$(lsb_release -sd)";
|
||||
elif type -p guix >/dev/null; then distro="GuixSD";
|
||||
elif type -p crux >/dev/null; then distro="$(crux)";
|
||||
else
|
||||
# Source the os-release file
|
||||
for fich in /etc/os-release /usr/lib/os-release /etc/*release /usr/lib/*release; do
|
||||
source "$fich" && break
|
||||
for file in /etc/os-release /usr/lib/os-release /etc/*release /usr/lib/*release; do
|
||||
source "$file" && break
|
||||
done
|
||||
unset fich
|
||||
# Workarounds for distros that go against the os-release standard.
|
||||
[[ -z "${distro// }" ]] && distro="$(awk '/BLAG/ {print $1; exit}' /etc/*ease /usr/lib/*ease)"
|
||||
[[ -z "${distro// }" ]] && distro="$(awk -F '=' '{print $2; exit}' /etc/*ease /usr/lib/*ease)"
|
||||
|
@ -982,10 +1007,11 @@ figet_distro() { # thanks neofetch, assigne $distro # 23/09/2017
|
|||
grep -qi 'Debian' /etc/issue && distro="$(sed 's/"//g' <<< $distro) $(cat /etc/debian_version)"
|
||||
fi
|
||||
[[ -z "$distro" ]] && distro="$os (Unknown)"
|
||||
figet_distro="$distro"
|
||||
}
|
||||
|
||||
figet_gpu() { # thanks neofetch, assigne $gpu
|
||||
gpu="$(lspci -mm | awk -F '\\"|\\" \\"' '/"Display|"3D|"VGA/ {print $3 " " $4}')"
|
||||
figet_gpu() { # thanks neofetch, assigne $figet_gpu # 02/10/2017
|
||||
local gpu="$(lspci -mm | awk -F '\\"|\\" \\"' '/"Display|"3D|"VGA/ {print $3 " " $4}')"
|
||||
case "$gpu" in
|
||||
*"advanced"*)
|
||||
gpu="${gpu//Intel*$'\n'}"
|
||||
|
@ -1005,11 +1031,13 @@ figet_gpu() { # thanks neofetch, assigne $gpu
|
|||
gpu="VirtualBox Graphics Adapter" ;;
|
||||
esac
|
||||
[[ "$gpu" =~ "intel" ]] && gpu="Intel Integrated Graphics"
|
||||
figet_gpu="$gpu"
|
||||
}
|
||||
|
||||
# assigne $ip_local, $gateway, $gateway_type, $gateway_one, $ip_local, $ip_local_type
|
||||
# $ifnames, $ifnames_type, $mac_address, mac_address_type
|
||||
figet_ip() { # 30/09/2017
|
||||
figet_ip() { # 02/10/2017
|
||||
local ifn
|
||||
[ -z "$(which ip)" ] && return 1
|
||||
ip_local="$(sed '/lo.*inet/d; /inet6.*scope global/d' <<< "$(ip -o a)" | awk '{print " ",$4,"(",$2,")"}')"
|
||||
ip_local_type="$(sed -E 's/(^.*wl.*)/\1 (wifi)/;s/(^.*en.*|^.*eth.*)/\1 (ethernet)/' <<< $ip_local)"
|
||||
|
@ -1020,7 +1048,6 @@ figet_ip() { # 30/09/2017
|
|||
[ "$ifn" != "lo" ] && ifnames+=" $ifn"$'\n'
|
||||
[ "$ifn" != "lo" ] && mac_address+=" $ifn: $(cat /sys/class/net/$ifn/address)"$'\n'
|
||||
done
|
||||
unset ifn
|
||||
ifnames="$(sed '/^$/d' <<< $ifnames)" # suppression \n final
|
||||
ifnames_type+="$(sed -E 's/(^.*wl.*)/\1 (wifi)/;s/(^.*en.*|^.*eth.*)/\1 (ethernet)/' <<< $ifnames)"
|
||||
mac_address="$(sed '/^$/d' <<< $mac_address)" # suppression \n final
|
||||
|
@ -1028,8 +1055,8 @@ figet_ip() { # 30/09/2017
|
|||
}
|
||||
|
||||
# $1=4|6, assigne $ip_public
|
||||
figet_ip_public(){ # 23/09/2017
|
||||
|
||||
figet_ip_public(){ # 02/10/2017
|
||||
local dig_test ip_test iip
|
||||
list_ip4(){
|
||||
ip_test+=" http://whatismyip.akamai.com"
|
||||
ip_test+=" http://ipof.in/txt"
|
||||
|
@ -1067,7 +1094,6 @@ figet_ip_public(){ # 23/09/2017
|
|||
}
|
||||
|
||||
unset ip_public
|
||||
local dig_test ip_test
|
||||
if [ "$1" == "4" ]; then
|
||||
ping -4 -c1 google.com &>/dev/null || ping -4 -c1 free.fr &>/dev/null || return 1 # test connectivité
|
||||
list_ip4_dig
|
||||
|
@ -1081,29 +1107,26 @@ figet_ip_public(){ # 23/09/2017
|
|||
fi
|
||||
|
||||
if [ "$(which dig)" ] && [ -z "$ip_public" ]; then
|
||||
for i in $dig_test ; do
|
||||
ip_public="$(dig +short $(sed 's;/; ;g' <<< $i))"
|
||||
for iip in $dig_test ; do
|
||||
ip_public="$(dig +short $(sed 's;/; ;g' <<< $iip))"
|
||||
[ "$ip_public" ] && break
|
||||
done
|
||||
unset i
|
||||
fi
|
||||
|
||||
if [ "$(which wget)" ] && [ -z "$ip_public" ]; then
|
||||
cmd="wget --quiet --tries=1 --timeout=5 -O - "
|
||||
for i in $ip_test ; do
|
||||
ip_public="$($cmd $i)"
|
||||
for iip in $ip_test ; do
|
||||
ip_public="$($cmd $iip)"
|
||||
[ "$ip_public" ] && break
|
||||
done
|
||||
unset i
|
||||
fi
|
||||
|
||||
if [ "$(which curl)" ] && [ -z "$ip_public" ]; then
|
||||
cmd="curl --silent --location --retry 0 --max-time 5" #--location pour aider redirections
|
||||
for i in $ip_test ; do
|
||||
ip_public="$($cmd $i)"
|
||||
for iip in $ip_test ; do
|
||||
ip_public="$($cmd $iip)"
|
||||
[ "$ip_public" ] && break
|
||||
done
|
||||
unset i
|
||||
fi
|
||||
|
||||
if [ "$(which telnet)" ] && [ -z "$ip_public" ]; then
|
||||
|
@ -1123,10 +1146,10 @@ figet_ip_public(){ # 23/09/2017
|
|||
fi
|
||||
}
|
||||
|
||||
figet_memory() { # thanks neofetch, assigne $memory # 30/08/2017
|
||||
figet_memory() { # thanks neofetch, assigne $figet_memory # 02/10/2017
|
||||
# MemUsed = Memtotal + Shmem - MemFree - Buffers - Cached - SReclaimable
|
||||
# Source: https://github.com/KittyKatt/screenFetch/issues/386#issuecomment-249312716
|
||||
local mem_used mem_total
|
||||
local mem_used mem_total a b
|
||||
while IFS=":" read -r a b; do
|
||||
case "$a" in
|
||||
"MemTotal") mem_used="$((mem_used+=${b/kB}))"; mem_total="${b/kB}" ;;
|
||||
|
@ -1137,25 +1160,29 @@ figet_memory() { # thanks neofetch, assigne $memory # 30/08/2017
|
|||
mem_used="$((mem_used / 1024))"
|
||||
mem_total="$((mem_total / 1024))"
|
||||
memory="${mem_used}Mo / ${mem_total}Mo"
|
||||
figet_memory="$memory"
|
||||
}
|
||||
|
||||
figet_mod_net(){ # thanks wireless-info, assigne $mod_net # 01/10/2017
|
||||
figet_mod_net(){ # thanks wireless-info, assigne $modules_net # 01/10/2017
|
||||
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)"
|
||||
mod_net="$(lsmod | grep -E "(^|[[:punct:] ])($MODMATCHES|$LSMODMATCHES)[^[:punct:] ]*([[:punct:] ]|$)")"
|
||||
modules_net="$(lsmod | grep -E "(^|[[:punct:] ])($MODMATCHES|$LSMODMATCHES)[^[:punct:] ]*([[:punct:] ]|$)")"
|
||||
}
|
||||
|
||||
figet_resolution() { # thanks neofetch, assigne $resolution
|
||||
figet_resolution() { # thanks neofetch, assigne $figet_resolution # 02/10/2017
|
||||
local resolution
|
||||
if type -p xrandr >/dev/null; then
|
||||
resolution="$(xrandr --nograb --current | awk 'match($0,/[0-9]*\.[0-9]*\*/) {printf $1 " @ " substr($0,RSTART,RLENGTH) "Hz, "}')"
|
||||
resolution="${resolution//\*}"
|
||||
resolution="${resolution//\.[0-9][0-9]}"
|
||||
elif type -p xdpyinfo >/dev/null; then resolution="$(xdpyinfo | awk '/dimensions:/ {printf $2}')"; fi
|
||||
resolution="${resolution%,*}"
|
||||
figet_resolution="$resolution"
|
||||
}
|
||||
|
||||
figet_shell(){ # thanks neofetch, assigne $shell
|
||||
figet_shell(){ # thanks neofetch, assigne $figet_shell # 02/10/2017
|
||||
local shell
|
||||
shell="${SHELL##*/}"
|
||||
case "${SHELL##*/}" in
|
||||
"bash")
|
||||
|
@ -1173,9 +1200,11 @@ figet_shell(){ # thanks neofetch, assigne $shell
|
|||
"fish")
|
||||
shell+="$(fish -c 'printf "%s" "$FISH_VERSION"')" ;;
|
||||
esac
|
||||
figet_shell="$shell"
|
||||
}
|
||||
|
||||
figet_wm() { # thanks neofetch, assigne $wm
|
||||
figet_wm() { # thanks neofetch, assigne $figet_wm # 02/10/2017
|
||||
local id wm
|
||||
if [ -n "$DISPLAY" ]; then
|
||||
id="$(xprop -root -notype | awk '$1=="_NET_SUPPORTING_WM_CHECK:"{print $5}')"
|
||||
wm="$(xprop -id "$id" -notype -f _NET_WM_NAME 8t)"
|
||||
|
@ -1185,6 +1214,7 @@ figet_wm() { # thanks neofetch, assigne $wm
|
|||
# Fallback for Wayland wms
|
||||
[[ "$wm" == "xwlc" ]] && wm="$(ps -e | grep -m 1 -o -F -e "sway" -e "orbment" -e "velox" -e "orbital")"
|
||||
fi
|
||||
figet_wm="$wm"
|
||||
}
|
||||
|
||||
fipaste(){
|
||||
|
@ -1209,7 +1239,7 @@ fipaste_curl_pastery(){ # $1 fichier à exporter, $2 durée de conservation en j
|
|||
# 100ko max
|
||||
}
|
||||
|
||||
fipaste_curl_markdownshare(){
|
||||
fipaste_curl_markdownshare(){ # à tester/finir
|
||||
[ -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
|
||||
|
@ -1353,8 +1383,9 @@ fileLogs="/var/log/sdeb_$script.log"
|
|||
fileDev="/opt/bin/fileDev"
|
||||
|
||||
f__affichage
|
||||
f__user && retourFUser=0 || retourFUser="$?"
|
||||
[ "$retourFUser" -eq 1 ] && f__error "user indéterminé, pour contourner, lancer le script avec:\n USER_INSTALL=user $0 \n"
|
||||
f__user
|
||||
retourFUser="$?"
|
||||
[ "$retourFUser" -eq 1 ] && f__error "user indéterminé, pour éventuellement contourner, lancer le script avec:\n USER_INSTALL=user $0 \n"
|
||||
if [ "$retourFUser" -eq 2 ]; then
|
||||
[ "$EUID" == 0 ] && user_="root" || f__error "user détecté, mais pas de home: /home/$user_"
|
||||
f__info "user root"
|
||||
|
@ -1368,7 +1399,7 @@ prg_1(){ # début
|
|||
echo > "$fileOutput"
|
||||
chown $user_: "$fileOutput"
|
||||
hote="$(uname -n)"
|
||||
dateRapport="$(date +"%d %b %Y %H:%M %z")"
|
||||
dateRapport="$(date '+%d/%m/%Y %H:%M %z')"
|
||||
echo -e "# $script sur $hote \n" > "$fileOutput"
|
||||
echo -e "Rapport du $dateRapport -- [$script $version]($urlNotice) \n" >> "$fileOutput"
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
* placer ln dans /usr/local/bin au lieu de /usr/bin ?
|
||||
* hasher les cmds pour gain temps exécution?
|
||||
* prévoir exécution en root si terminal
|
||||
* option erreur pour f__info
|
||||
* réorganiser en famille à afficher avec option de choix possible
|
||||
* swap
|
||||
|
@ -15,6 +14,15 @@
|
|||
* f__wget_test
|
||||
* comment f__user getInfo
|
||||
|
||||
## 1.32.0 02/10/2017
|
||||
|
||||
* révision sed s/
|
||||
* fi_systeme: boot image avec options
|
||||
* révision fi_disk
|
||||
* révision nommage variable fonction neofetch
|
||||
* variables de boucles en local
|
||||
* f__user, premier essai root only, fonctionnement en root, function à réviser
|
||||
|
||||
## 1.31.0 01/10/2017
|
||||
|
||||
* figet_disk: meilleure détection vendor/model quand vide sur lsblk
|
||||
|
|
Loading…
Reference in New Issue