mirror of https://framagit.org/kyodev/kyopages.git
1.0.4
This commit is contained in:
parent
d43a76918a
commit
8eb062ea1e
|
@ -1,12 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
version=1.0.3
|
||||
date="17/08/2017"
|
||||
version=1.0.4
|
||||
date="18/08/2017"
|
||||
projet="simpledeb"
|
||||
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues"
|
||||
script="getInfo"
|
||||
urlScript="https://framagit.org/kyodev/kyopages/raw/master/scripts/$script"
|
||||
urlNotice="https://kyodev.frama.io/kyopages/scripts/getInfo/"
|
||||
lognameDev="kyodev"
|
||||
|
||||
##### license LPRAB/WTFPL
|
||||
# auteur: simpledeb
|
||||
|
@ -149,7 +150,7 @@ f__wget_test(){ # v07/2017
|
|||
}
|
||||
|
||||
# inscription dans tache upgrade en anacron hebdomadaire, via cron horaire
|
||||
fscript_cronAnacron(){ # v17/08/2017
|
||||
fscript_cronAnacron(){ # v18/08/2017
|
||||
local dirAnacron="/home/$user_/.config/anacron"
|
||||
local dirSpool="$dirAnacron/spool"
|
||||
local fileAnacron="$dirAnacron/$script.anacrontab"
|
||||
|
@ -159,7 +160,8 @@ fscript_cronAnacron(){ # v17/08/2017
|
|||
mkdir -p "$dirAnacron"
|
||||
# table anacron
|
||||
echo "7 01 $script nice /opt/bin/$script --upgrade" > "$fileAnacron"
|
||||
## test: anacron journalier: echo "1 01 $script test nice /opt/bin/$script --upgrade 2>/dev/null" >> "$fileAnacron"
|
||||
## dev: anacron journalier:
|
||||
[ "$LOGNAME" == "$lognameDev" ] && echo "1 01 $script test nice /opt/bin/$script --upgrade 1>/dev/null" >> "$fileAnacron"
|
||||
# création spool anacron utilisateur
|
||||
mkdir -p "$dirSpool"
|
||||
chown -R "$user_": "$dirAnacron" "$dirSpool"
|
||||
|
@ -410,13 +412,15 @@ get_gpu() { # thanks neofetch, assigne $gpu
|
|||
}
|
||||
|
||||
get_ip() { # $ip_local, $gateway, $gateway_type, $gateway_one, $ip_local, $ip_local_type, $ifname, $ifname_type
|
||||
gateway="$(ip route | awk '/default.*via/ {print $3, "pour", $5}')"
|
||||
gateway_one="$(head -n 1 <<< $gateway | awk '{print $1}')"
|
||||
ip_local="$(ip route | awk '/proto.*src/ {print $9, "pour",$3}')"
|
||||
ifname="$(ip route | awk '/proto.*src/ {print $3}')"
|
||||
gateway_type="$(sed -E 's/(^.*wl.*)/\1 (wifi)/;s/(^.*en.*|^.*eth.µ)/\1 (ethernet)/' <<< $gateway)"
|
||||
# ip_local="$(ip route | awk '/proto.*src/ {print $9, "pour",$3}')"
|
||||
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)"
|
||||
ifname="$(ip -4 route | awk '/proto kernel/ {print $3}')"
|
||||
ifname_type="$(sed -E 's/(^wl.*)/\1 (wifi)/;s/(^en.*|^eth.*)/\1 (ethernet)/' <<< $ifname)"
|
||||
# gateway="$(ip route | awk '/default.*via/ {print $3, "pour", $5}')"
|
||||
gateway="$(LC_ALL=C ip -4 route | awk '/default via/ {print $3,"(",$5,")"}'; LC_ALL=C ip -6 route | awk '/default via/ {print $3,"(",$5,")"}')"
|
||||
gateway_type="$(sed -E 's/(^.*wl.*)/\1 (wifi)/;s/(^.*en.*|^.*eth.µ)/\1 (ethernet)/' <<< $gateway)"
|
||||
gateway_one="$(head -n 1 <<< $gateway | awk '{print $1}')"
|
||||
}
|
||||
|
||||
get_ip_public(){ # $1=IPv4|IPv6, assigne $ip_public
|
||||
|
@ -537,7 +541,7 @@ get_modules(){ # thanks wireless-info for 'net', $1 net|video, assigne $exportTe
|
|||
fi
|
||||
exportText+='```\n'
|
||||
exportText+="$modules \n"
|
||||
exportText+='```\n'
|
||||
exportText+='```\n\n'
|
||||
# grep -vE '#|^$' /etc/modules
|
||||
}
|
||||
|
||||
|
@ -828,27 +832,27 @@ fi_nm_wifis(){
|
|||
fi_reseau(){
|
||||
local netcards="$(lspci -nnk | grep -iEA 3 'network|ethernet')"
|
||||
# local netcards="$(lspci -nnvvv | grep -iEA 12 'network|ethernet')"
|
||||
local ip_a="$(ip -4 address show)"
|
||||
# get_ip_public "IPv6"
|
||||
local ip_a="$(ip a | sed '/inet6.*scope global/d; /link\/ether/d; /valid_lft/d')" # filtre sur inet6 & scope global & adr MAC & bail?
|
||||
|
||||
local iwconfig="$(iwconfig 2>&1 | grep -v 'no wireless extensions' | grep -v '^$')"
|
||||
local interfaces="$(sed '/^#/d;s/^wpa-psk [[:graph:]]\+/wpa-psk <WPA key removed>/;/^$/d;s/\(.*\)/\1 /' /etc/network/interfaces)"
|
||||
local route="$(ip route show)"
|
||||
local resolv="$(grep -vE '#|^$' /etc/resolv.conf)"
|
||||
NETMGRPATHS=("/usr/sbin/NetworkManager" "/usr/sbin/wicd" "/usr/sbin/connmand") # thanks wireless-info
|
||||
NETMGRNAMES=("NetworkManager" "Wicd" "ConnMan") # thanks wireless-info
|
||||
for ii in "${!NETMGRPATHS[@]}"; do
|
||||
if [ -f "${NETMGRPATHS[$ii]}" ]; then NETMGRINST+="${NETMGRNAMES[$ii]}"; fi
|
||||
if [ "$(ps -ef | grep -c ${NETMGRPATHS[$ii]})" -ge 2 ]; then netmgrrun+="$(ps -ef | grep -o "${NETMGRPATHS[$ii]}.*$" | head -n 1)"; fi
|
||||
netmgrpaths=("/usr/sbin/NetworkManager" "/usr/sbin/wicd" "/usr/sbin/connmand") # thanks wireless-info
|
||||
netmgrnames=("NetworkManager" "Wicd" "ConnMan") # thanks wireless-info
|
||||
for ii in "${!netmgrpaths[@]}"; do
|
||||
if [ -f "${netmgrpaths[$ii]}" ]; then netmgrinst+="${netmgrnames[$ii]}"; fi
|
||||
if [ "$(ps -ef | grep -c ${netmgrpaths[$ii]})" -ge 2 ]; then netmgrrun+="$(ps -ef | grep -o "${netmgrpaths[$ii]}.*$" | head -n 1)"; fi
|
||||
done
|
||||
local text="## réseau \n\n"
|
||||
if which iwlist &>/dev/null; then # liste canaux wifi paquet wireless-tools requis
|
||||
local liste_canaux_wifi="$(iwlist chan 2>&1 | grep -vE 'no frequency information|^$')"
|
||||
fi
|
||||
|
||||
###
|
||||
get_ip; text+="**IP locale(s):** \n"
|
||||
text+='```\n'
|
||||
text+="$ip_local_type \n"
|
||||
text+='```\n'
|
||||
text+='```\n\n'
|
||||
if grep -q 'wlx' <<< "$ifname"; then
|
||||
text+="**Attention:** une interface wifi est en erreur: $(grep -o 'wlx' <<< $ifname) \n"
|
||||
text+="l'interface n'est pas reconnue et est donc mal nommée \n"
|
||||
|
@ -856,39 +860,38 @@ fi_reseau(){
|
|||
fi
|
||||
text+="**Passerelle(s):** \n"
|
||||
text+='```\n'
|
||||
text+="$gateway \n"
|
||||
text+='```\n'
|
||||
text+="l'IP publique n'apparaît pas pour ne pas être publiée, mais elle peut être connue avec: \n"
|
||||
text+='`'"./getInfo --ip ou getInfo --ip (script installé)"'`\n\n'
|
||||
text+="$gateway_type \n"
|
||||
text+='```\n\n'
|
||||
text+="l'IP publique peut être connue avec: "'`./getInfo --ip` ou `getInfo --ip` (script installé)\n\n'
|
||||
text+="**lspci -nnk | grep -iEA 3 'network|ethernet'** \n"
|
||||
text+='```\n'
|
||||
text+="$netcards \n"
|
||||
text+='```\n'
|
||||
text+="**ip address show** \n"
|
||||
text+='```\n\n'
|
||||
text+="**ip address** (ipv6 lien local, pas d'adresses MAC) \n"
|
||||
text+='```\n'
|
||||
text+="$ip_a \n"
|
||||
text+='```\n'
|
||||
text+='```\n\n'
|
||||
if [ "$iwconfig" ]; then
|
||||
text+="**iwconfig** \n"
|
||||
text+='```\n'
|
||||
text+="$iwconfig \n"
|
||||
text+='```\n'
|
||||
text+='```\n\n'
|
||||
fi
|
||||
text+="**/etc/network/interfaces** \n"
|
||||
text+='```\n'
|
||||
text+="$interfaces \n"
|
||||
text+='```\n'
|
||||
text+='```\n\n'
|
||||
text+="**ip route show** \n"
|
||||
text+='```\n'
|
||||
text+="$route \n"
|
||||
text+='```\n'
|
||||
text+='```\n\n'
|
||||
text+="**/etc/resolv.conf** \n"
|
||||
text+='```\n'
|
||||
text+="$resolv \n"
|
||||
text+='```\n'
|
||||
if [ "$NETMGRINST" ]; then
|
||||
text+='```\n\n'
|
||||
if [ "$netmgrinst" ]; then
|
||||
text+="### network managers \n\n"
|
||||
[ "$NETMGRINST" ] && text+="installé(s): **$NETMGRINST** \n" || text+="non trouvé parmi: ${NETMGRNAMES[@]} \n"
|
||||
[ "$netmgrinst" ] && text+="installé(s): **$netmgrinst** \n" || text+="non trouvé parmi: ${netmgrnames[@]} \n"
|
||||
text+="en fonctionnement: "
|
||||
[ "$netmgrrun" ] && text+="**$netmgrrun** \n" || text+="non trouvé \n"
|
||||
get_modules net; text+="$exportText"
|
||||
|
@ -897,7 +900,7 @@ fi_reseau(){
|
|||
text+="**iwlist chan** \n"
|
||||
text+='```\n'
|
||||
text+="$liste_canaux_wifi \n"
|
||||
text+='```\n'
|
||||
text+='```\n\n'
|
||||
fi
|
||||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
@ -973,7 +976,7 @@ fi_system_analyse(){
|
|||
}
|
||||
|
||||
fi_systeme(){
|
||||
[ -d /sys/firmware/efi ] && local mbr="**EFI boot**" || local mbr="Legacy boot"
|
||||
[ -d /sys/firmware/efi ] && local mbr="**EFI boot**" || local mbr="**Legacy boot**"
|
||||
[ -x "/usr/bin/lsb_release" ] && local description="$(lsb_release -ds)" #dépend de apt install lsb-release, sur debian, en standard, juste : lsb-base
|
||||
local uname="$(uname -rmo)"
|
||||
local bootImage="$(sed 's/root=[^ ]*//;s/[ ]\+/, /g' /proc/cmdline)"
|
||||
|
@ -984,14 +987,13 @@ fi_systeme(){
|
|||
local shells="$(grep -v "^#" /etc/shells | sed 's/\/bin\///' | tr '\n' ' ')"
|
||||
local lastboot="$(last -R -n 1 --time-format iso reboot | head -n 1 | grep -o '[0-9:T+-]*' | sed 's/T/ /')"
|
||||
local uptime="$(uptime -p)"
|
||||
uptime="$(sed 's/up/depuis/; s/days/jours/; s/day/jour/; s/hour[s]*/h/; s/minute[s]*/mn/' <<< $uptime)"
|
||||
|
||||
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)"
|
||||
###
|
||||
local text="## système \n\n"
|
||||
get_cpu; text+="**CPU: $cpu** \n"
|
||||
get_gpu; text+="**GPU: $gpu** \n"
|
||||
text+="**type de boot: $mbr** \n"
|
||||
get_cpu; text+="CPU: **$cpu** \n"
|
||||
get_gpu; text+="GPU: **$gpu** \n"
|
||||
text+="type de boot: $mbr \n"
|
||||
get_distro; text+="**$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"
|
||||
|
@ -1007,8 +1009,7 @@ fi_systeme(){
|
|||
get_disk; text+="disque(s): $disk \n"
|
||||
get_battery; text+="batteries(s): $battery \n"
|
||||
text+="dernier boot: $lastboot, uptime: $uptime \n"
|
||||
get_ip; text+="$ip_local_type \n"
|
||||
text+='```\n'
|
||||
text+='```\n\n'
|
||||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
|
@ -1054,7 +1055,8 @@ prg_1(){ # début programme
|
|||
echo -e "# getInfo $version sur $hote / $os \n" > "$fileOutput"
|
||||
echo -e "Rapport au $dateRapport \n" >> "$fileOutput"
|
||||
}
|
||||
prg_test(){ # traitements principaux
|
||||
prg_2test(){ # traitements tests
|
||||
printf "."
|
||||
fi_reseau; printf "."
|
||||
}
|
||||
prg_2(){ # traitements principaux
|
||||
|
@ -1100,7 +1102,7 @@ for i in "$options"; do
|
|||
fi ;; # programme
|
||||
--ip )
|
||||
get_ip_public "IPv4"
|
||||
f__info "$GREEN""ip4: $ip_public"
|
||||
f__info "raw" "$GREEN ip4: $ip_public"
|
||||
get_ip_public "IPv6"
|
||||
f__info "$BLUE""ip6: $ip_public" ;; # affiche ip public
|
||||
--upgrade | -u )
|
||||
|
|
|
@ -1,16 +1,26 @@
|
|||
# changelog getInfo
|
||||
|
||||
## todo
|
||||
|
||||
* if which iwlist &>/dev/null; --> if [ "$(which iwlist)" ]; plus court
|
||||
* ifconfig au lieu de iproute2
|
||||
* adresses MAC?
|
||||
|
||||
## 1.0.4 18/08/2017
|
||||
|
||||
* maj fscript_cronAnacron pour dev
|
||||
* fix affichage ipv6, filtre sur inet6 & scope global & adr MAC
|
||||
* adresse MAC non affichée
|
||||
* révision ip locale, système et réseau
|
||||
|
||||
## 1.0.3 17/08/2017
|
||||
|
||||
* version publique
|
||||
* fix bug: fi_systeme
|
||||
* get_distro(neofetch)
|
||||
* révision protection variables
|
||||
* désactivation affichage ipv6 en attente meilleur filtrage
|
||||
|
||||
## 1.0.1 17/08/2017
|
||||
|
||||
* version publique
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -35,3 +45,5 @@ http://ndossougbe.github.io/strapdown/
|
|||
|
||||
https://www.pastery.net/api/
|
||||
license non libre? pas de depot, mais ça marche
|
||||
|
||||
## PR neofetch, debian version sur debian pure
|
||||
|
|
Loading…
Reference in New Issue