wlan0 (709B)
1 #!/bin/sh 2 3 dev="$(basename $0)" 4 wpasup=/etc/wpa_supplicant/wpa_supplicant.conf 5 6 usage() { 7 printf "usage: %s new|enable|disable|restart}\n" "$(basename $0)" 8 exit 1 9 } 10 11 ask() { 12 printf "(*) choose one of these:\n" 13 grep 'ssid="' $wpasup | sed 's/ssid=//' 14 printf "[essid]: " ; read net 15 [ -n "$net" ] || exit 1 16 grep -q "$net" $wpasup || exit 1 17 } 18 19 en() { 20 [ -n "$net" ] || ask 21 sudo perl -i -0pe 's/disabled=0/disabled=1/g;s/(ssid="'$net'"\n.*)disabled=1/\1disabled=0/' $wpasup 22 } 23 24 dis() { 25 sudo perl -i -0pe 's/disabled=0/disabled=1/g;' $wpasup 26 } 27 28 case "$1" in 29 en|ena|enab*) net="$2" en;; 30 di|dis|disa*) net="$2" dis;; 31 d|down) sup net $dev stop;; 32 r|restart) sup net $dev restart;; 33 *) usage;; 34 esac