mirror of https://framagit.org/kyodev/kyopages.git
0.4.0
This commit is contained in:
parent
559afe6c6b
commit
3fce4c21f2
149
scripts/getInfo
149
scripts/getInfo
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
version=0.3.0
|
||||
date="07/2017"
|
||||
projet="simpledebian"
|
||||
version=0.4.0
|
||||
date="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/getInfo"
|
||||
|
@ -13,7 +13,7 @@ urlNotice=""
|
|||
# contributeurs: kyodev
|
||||
#####
|
||||
|
||||
PATH='/bin:/usr/bin' ; IFS=' '
|
||||
PATH='/bin:/usr/bin:/sbin' ; IFS=' '
|
||||
|
||||
f__affichage(){
|
||||
# définition couleurs
|
||||
|
@ -83,30 +83,13 @@ f__requis(){
|
|||
"apt install $dependsFail"
|
||||
}
|
||||
|
||||
fi_divers(){
|
||||
local uptime=$(uptime -p)
|
||||
local lastboot=$(last -R -n 1 --time-format iso reboot | head -n 1 | grep -o '[0-9:T+-]*' | sed 's/T/ /')
|
||||
#dépend de apt install lsb-release, debian standard juste : lsb-base
|
||||
[ -x "/usr/bin/lsb_release" ] && local description=$(lsb_release -ds)
|
||||
local uname=$(uname -rmo)
|
||||
local parametreKernel=$(sed 's/root=[^ ]*//;s/[ ]\+/, /g;s/^BOOT_IMAGE=[^ ]*//' /proc/cmdline)
|
||||
echo "dernier boot: $lastboot, uptime: $uptime""$rcmd"
|
||||
[ $description ] && echo "description: $description""$rcmd"
|
||||
echo "uname: $uname""$rcmd"
|
||||
echo "parametreKernel: $parametreKernel""$rcmd"
|
||||
}
|
||||
|
||||
fi_carte_reseau(){
|
||||
netcards="$(lspci -nnk | grep -iEA 3 'network|ethernet')"
|
||||
}
|
||||
|
||||
trim_quotes() { # thanks neofetch
|
||||
trim_output="${1//\'}"
|
||||
trim_output="${trim_output//\"}"
|
||||
printf "%s" "$trim_output"
|
||||
}
|
||||
|
||||
get_de() { # thanks neofetch
|
||||
get_de() { # thanks neofetch, assigne $de
|
||||
de="${XDG_CURRENT_DESKTOP/i3}"
|
||||
de="${de/'X-'}"
|
||||
de="${de/Budgie:GNOME/Budgie}"
|
||||
|
@ -124,7 +107,7 @@ get_de() { # thanks neofetch
|
|||
esac
|
||||
}
|
||||
|
||||
get_distro() { # thanks neofetch
|
||||
get_distro() { # thanks neofetch, assigne $distro
|
||||
[[ "$distro" ]] && return
|
||||
case "$os" in
|
||||
"Linux" | "GNU")
|
||||
|
@ -167,6 +150,86 @@ get_distro() { # thanks neofetch
|
|||
[[ -z "$distro" ]] && distro="$os (Unknown)"
|
||||
}
|
||||
|
||||
fi_systeme(){
|
||||
local uname=$(uname -rmo)
|
||||
#dépend de apt install lsb-release, debian standard juste : lsb-base
|
||||
[ -x "/usr/bin/lsb_release" ] && local description=$(lsb_release -ds)
|
||||
local uptime=$(uptime -p)
|
||||
local lastboot=$(last -R -n 1 --time-format iso reboot | head -n 1 | grep -o '[0-9:T+-]*' | sed 's/T/ /')
|
||||
local bootImage=$(sed 's/root=[^ ]*//;s/[ ]\+/, /g' /proc/cmdline)
|
||||
|
||||
get_de
|
||||
get_distro
|
||||
local text="\n## système\n\n"
|
||||
text+="$distro \n"
|
||||
text+="$bootImage \n"
|
||||
text+="dernier boot: $lastboot, uptime: $uptime \n"
|
||||
[ $description ] && text+="description: $description \n"
|
||||
text+="uname: $uname \n"
|
||||
text+="Desktop: $de \n"
|
||||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
fi_reseau(){
|
||||
local netcards=$(lspci -nnk | grep -iEA 3 'network|ethernet')
|
||||
local ifconfig=$(ip address show)
|
||||
local iwconfig=$(iwconfig 2>/dev/null | grep -v 'no wireless extensions')
|
||||
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 -v '^#' /etc/resolv.conf)
|
||||
NETMGRPATHS=("/usr/sbin/NetworkManager" "/usr/sbin/wicd" "/usr/sbin/connmand")
|
||||
NETMGRNAMES=("NetworkManager" "Wicd" "ConnMan")
|
||||
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="\n## réseau\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'
|
||||
text+="$ifconfig \n"
|
||||
text+='```\n'
|
||||
text+="**iwconfig** \n"
|
||||
text+='```\n'
|
||||
text+="$iwconfig \n"
|
||||
text+='```\n'
|
||||
text+="**/etc/network/interfaces** \n"
|
||||
text+='```\n'
|
||||
text+="$interfaces \n"
|
||||
text+='```\n'
|
||||
text+="**ip route show** \n"
|
||||
text+='```\n'
|
||||
text+="$route \n"
|
||||
text+='```\n'
|
||||
text+="**grep -v '^#' /etc/resolv.conf** \n"
|
||||
text+='```\n'
|
||||
text+="$resolv \n"
|
||||
text+='```\n'
|
||||
text+="**network managers** \n"
|
||||
[ "$NETMGRINST" ] && text+="installé: $NETMGRINST \n" || text+="non trouvé parmi: ${NETMGRNAMES[@]} \n"
|
||||
text+="en fonctionnement: "
|
||||
[ "$netmgrrun" ] && text+="$netmgrrun" || text+="non trouvé\n"
|
||||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
fi_modules(){ # thanks wireless-info, $1 net|all
|
||||
[ "$1" == "net" ] && local text="\n## modules réseau\n\nliste non garantie complète \n" || \
|
||||
local text="\n\n## tous les modules\n\n**lsmod** \n"
|
||||
if [ "$1" == "net" ]; then
|
||||
local 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)"
|
||||
local LSMODMATCHES="(wmi|(dell|ideapad)[-_]laptop)"
|
||||
local modules=$(lsmod | grep -E "(^|[[:punct:] ])($MODMATCHES|$LSMODMATCHES)[^[:punct:] ]*([[:punct:] ]|$)")
|
||||
else local modules=$(lsmod); fi
|
||||
text+='```\n'
|
||||
text+="$modules \n"
|
||||
text+='```\n'
|
||||
echo -e "$text" >> "$fileOutput"
|
||||
}
|
||||
|
||||
fi_curl_markdownshare(){
|
||||
[ -e "$1" ] || f__error "fichier $1 inexistant"
|
||||
curl -H "Accept: application/json" -X POST -F "text=<$1" https://markdownshare.com/create/
|
||||
|
@ -182,44 +245,41 @@ fi_curl_pastery(){
|
|||
local testCurl
|
||||
# curl -X POST "https://www.pastery.net/api/paste/?title=getInfo&language=markdown" -F file=@$1
|
||||
#curl -X POST "https://www.pastery.net/api/paste/?title=getInfo_$version&language=markdown&duration=$((7*1440))" --data-binary @$1
|
||||
testCurl=$(curl --silent -X POST "https://www.pastery.net/api/paste/?title=getInfo_$version&language=markdown&duration=$((1*1440))" --data-binary @$1)
|
||||
testCurl=$(curl --silent -X POST "https://www.pastery.net/api/paste/?title=getInfo_$version&language=markdown&duration=$((1*1440))" --data-binary @$1)
|
||||
local id=$(echo $testCurl | cut -d '"' -f 4)
|
||||
f__info "\n\n votre paste:" "https://www.pastery.net/$id/"
|
||||
|
||||
#?api_key=<api_key>
|
||||
#&duration=<duration> en mn, 1 jour par défaut
|
||||
#&title=<title>
|
||||
#&language=<language>
|
||||
#&max_views=<max_views>
|
||||
|
||||
100ko max
|
||||
}
|
||||
|
||||
# initialisation
|
||||
f__affichage
|
||||
f__architecture || f__error "Architecture non supportée" "vous pouvez contacter contacter $projet $contact pour parfaire le script"
|
||||
fileOutput="getInfo_rapport.md"
|
||||
rcmd=" " # retour ligne markdown
|
||||
f__architecture || f__error "Architecture non supportée" \
|
||||
"vous pouvez contacter contacter $projet $contact pour parfaire le script"
|
||||
f__requis "curl"
|
||||
os="$(uname -s)"
|
||||
fileLogs="/var/log/sdeb_getFinfo.log"
|
||||
fileOutput="getInfo_rapport.md"
|
||||
|
||||
os=$(uname -s)
|
||||
hote=$(uname -n)
|
||||
dateRapport=$(date +"%d %b %Y %H:%M %z")
|
||||
|
||||
rm "$fileOutput" &>/dev/null
|
||||
echo -e "# getInfo $version sur $hote / $os \n" > "$fileOutput"
|
||||
echo -e "Rapport au $dateRapport" >> "$fileOutput"
|
||||
|
||||
echo -e "# getInfo $version\n" > "$fileOutput"
|
||||
echo -e "Rapport au $dateRapport sur $(uname -n)" >> "$fileOutput"
|
||||
fi_systeme
|
||||
fi_reseau
|
||||
fi_modules "net"
|
||||
|
||||
echo -e "\n## système\n" >> "$fileOutput"
|
||||
fi_divers | tee -a "$fileOutput"
|
||||
get_de && echo "DE: $de""$rcmd" | tee -a "$fileOutput"
|
||||
get_distro && echo "distro: $distro""$rcmd" | tee -a "$fileOutput"
|
||||
cat $fileOutput
|
||||
exit
|
||||
|
||||
echo -e "\n## réseau\n" >> "$fileOutput"
|
||||
echo '```' >> "$fileOutput"
|
||||
fi_carte_reseau && echo "$netcards""$rcmd" | tee -a "$fileOutput"
|
||||
echo '```' >> "$fileOutput"
|
||||
|
||||
#fi_curl_markdownshare "$fileOutput"
|
||||
fi_curl_pastery "$fileOutput"
|
||||
#fi_curl_markdownshare "$fileOutput"
|
||||
|
||||
echo
|
||||
exit
|
||||
|
@ -259,3 +319,6 @@ http://ndossougbe.github.io/strapdown/
|
|||
https://www.pastery.net/api/
|
||||
mais license non libre? et pas de depot
|
||||
mais ça marche
|
||||
|
||||
wget https://framagit.org/kyodev/kyopages/raw/master/scripts/getInfo
|
||||
chmod +x getInfo && ./getInfo
|
||||
|
|
Loading…
Reference in New Issue