This commit is contained in:
kyodev 2017-08-07 11:47:09 +02:00
parent 134bccde79
commit b0cd1d2ebc
1 changed files with 28 additions and 44 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=0.9.2
date="06/08/2017"
version=0.9.3
date="07/08/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues"
script="getInfo"
@ -571,18 +571,6 @@ paste_curl_markdownshare(){
}
fi_cnx(){
if ! fi_nm_wifis cnx ; then
f__error "Il manque NetworkManager ou les droits root"
fi
local text="## wifi connecté \n\n"
f__info="$RED""Attention, la clé du réseau wifi est visible!"
text+='```\n'
text+="$nm_connect \n"
text+='```\n'
echo -e "$text"
}
fi_cpu(){
local cpu_addr=$(sed -n 's/^address sizes.*: \(.*\)$/\1/p' /proc/cpuinfo | head -n 1)
local cpu_bogomips=$(sed -n 's/^bogomips.*: \(.*\)$/\1/p' /proc/cpuinfo | head -n 1)
@ -711,7 +699,7 @@ fi_gpu(){
}
fi_help(){
printf $BLUE
printf "$BLUE"
cat << 'EOF'
----------------------------------------------------------------------
./getInfo : exécution normale
@ -727,7 +715,8 @@ cat << 'EOF'
--remove, -r : suppression du script dans le système
--upgrade, -u : upgrade script si maj possible
--version, -v : version du script, en ligne et en cours d'exécution
--cnx, -c : affiche la connexion wifi en cours, root requis, /!\ infos confidentielles, sans rapport
--ssid, -s : affiche configurations ssid /!\ infos confidentielles
pas de rapport, root et NetworkManager requis
--ip : affiche ip public, /!\ infos confidentielles, sans rapport
exemple
@ -776,19 +765,25 @@ fi_nm(){
echo -e "$text" >> "$fileOutput"
}
fi_nm_wifis(){ # si $1=cnx retourne connexions wifi et assigne $connections_wifi, $nm_connect
[ -x $(which nmcli) ] || return 0
local nm_wifis=$(nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list)
connections_wifi=$(LC_ALL=C nmcli -f SSID,ACTIVE,IN-USE device wifi list | grep -E 'yes[[:space:]]+\*' | awk '{print $1}')
fi_ssid(){ # affiche configurations ssid
[ $(which nmcli) ] || f__error "il faut NetworkManager"
[ $EUID -eq 0 ] || f__error "il faut les droits root"
local nm_ssid=$(grep -vE '#|^$' /etc/NetworkManager/system-connections/*)
local text="## configuration(s) ssid networkmanager \n\n"
f__info="$RED""Attention, la clé du réseau wifi est visible $COLOR""aucun rapport n'a été créé"
text+='```\n'
text+="$nm_ssid \n"
text+='```\n'
echo -e "$text"
}
if [ "$1" == "cnx" ] && [ $EUID -eq 0 ]; then # root only
connections_wifi=$(LC_ALL=C nmcli -f SSID,ACTIVE,IN-USE device wifi list | grep -E 'yes[[:space:]]+\*' | awk '{print $1}')
nm_connect=$(grep -vE '#|^$' /etc/NetworkManager/system-connections/"$connections_wifi")
return 0
else return 1; fi
fi_nm_wifis(){
[ -x $(which nmcli) ] && [ -z "$1" ] || return 0
local nm_wifis=$(nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list)
local nm_connected=$(LC_ALL=C nmcli -f SSID,ACTIVE,IN-USE device wifi list | grep -E 'yes[[:space:]]+\*' | awk '{print $1}') # non utilisé
local text="## wifis à proximité \n\n"
text+="**nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,ACTIVE,IN-USE device wifi list** \n"
text+="**nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY device wifi list** \n"
text+='```\n'
text+="$nm_wifis \n"
text+='```\n'
@ -979,11 +974,11 @@ fi_paste(){
# initialisation
PATH='/bin:/usr/bin:/sbin' ; IFS=' '
f__affichage
f__user
fileOutput="getInfo_rapport.md"
fileLogs="/var/log/sdeb_$script.log"
dureePaste=1 # en jour
f__affichage
f__user
prg_1(){ # début
f__requis "gawk"
@ -991,31 +986,20 @@ prg_1(){ # début
rm "$fileOutput" &>/dev/null
touch "$fileOutput"
chown $user_: "$fileOutput"
}
prg_test(){ # traitements principaux
os=$(uname -s)
hote=$(uname -n)
dateRapport=$(date +"%d %b %Y %H:%M %z")
echo -e "# getInfo $version sur $hote / $os \n" >> "$fileOutput"
echo -e "Rapport au $dateRapport \n" >> "$fileOutput"
fi_systeme
# fi_reseau
}
prg_2(){ # traitements principaux
os=$(uname -s)
hote=$(uname -n)
dateRapport=$(date +"%d %b %Y %H:%M %z")
echo -e "# getInfo $version sur $hote / $os \n" > "$fileOutput"
echo -e "Rapport au $dateRapport \n" >> "$fileOutput"
}
prg_2(){ # traitements principaux
fi_systeme
fi_cpu
fi_gpu
fi_disk
fi_reseau
fi_nm
fi_nm_wifis
fi_nm # si network manager, état et conf
fi_nm_wifis # si network manager, wifi proximité
fi_usb
fi_localisation
fi_system_analyse
@ -1048,7 +1032,7 @@ for (( i=0 ; i<=$# ; i++ )); do
f__log="test mise à jour"
fscript_get_version
fscript_dl ;; # upgrade script si maj possible
--cnx | -c ) fi_cnx ;; # affiche connexion wifi en cours
--ssid | -s ) fi_ssid ;; # affiche configurations ssid
--dmesg ) fi_dmesg "dmesg" ;; # rapport dmesg only
--ip )
get_ip_public "IPv4"