Des scripts pour faciliter le reconditionnement de portables - retour accueil
git clone git://bebou.netlib.re/scripts-reco
Log | Files | Refs | README |
internet (1196B)
1 # Connectivité internet 2 # Ethernet 3 4 5 tester_internet() { 6 name="$1";type="$2" 7 informer "On active l'interface $name" 8 sudo ip link set "$name" up 9 sleep 10 10 if [ "$type" = "wifi" ];then 11 sudo nmcli device wifi connect "commown-guest" 12 fi 13 if ! ping -c 1 wikipedia.org;then 14 printf "Y'a pas de connexion sur %s\n" "$name" | sauver 15 interfaces_not_working="$interfaces_not_working $name" 16 else 17 printf "Y'a de la connexion sur %s\n" "$name" | sauver 18 fi 19 sudo ip link set "$name" down 20 } 21 22 nmcli device show | 23 awk ' 24 /DEVICE/ {interfaces[++i,"name"]=$2} 25 /TYPE/ {interfaces[i,"type"]=$2} 26 END { 27 for(j=1;j<=i;j++) { 28 printf "tester_internet %s %s;\n",interfaces[j,"name"],interfaces[j,"type"] 29 } 30 } 31 ' | grep -Ev " (loopback|wifi-p2p);$" > $tmpdir/interfaces 32 33 interfaces_not_working="" 34 informer "On désactive toutes les interfaces" 35 < $tmpdir/interfaces awk '{print $2}' | 36 xargs -I{} sudo ip link set {} down 37 38 . $tmpdir/interfaces 39 40 if [ "$interfaces_not_working" ];then 41 informer "Il y a eu un souci avec $interfaces_not_working" 42 else 43 informer "Il n'y a pas eu de souci" 44 fi 45 46 < $tmpdir/interfaces grep -m1 "ethernet" | 47 awk '{print $2}' | 48 xargs -I{} sudo ip link set {} up 49