diff options
author | ache <ache@ache.one> | 2018-01-15 02:06:23 +0100 |
---|---|---|
committer | ache <ache@ache.one> | 2018-01-15 02:06:23 +0100 |
commit | ce19d133fe2a245066861a345c2a15a4d0a04c40 (patch) | |
tree | 799fa7b8902267c7167c2f91d3c27c74275eb496 /coWifi | |
parent | Init crypted mount scripts (diff) |
Fix off with guess_wifi improvement
Diffstat (limited to 'coWifi')
-rwxr-xr-x | coWifi | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -5,41 +5,45 @@ interface=""; function guess_wifi { toAll="$1" + _interface="" for i in `ls /sys/class/net/`; do if [ -d "/sys/class/net/$i/wireless" ] ; then - interface="$i" + _interface="$i" fi done if [ -z $interface ] ; then - echo $'No Wireless interface found\nExit' +# echo 'No Wireless interface found\nExit' if [ "$toAll" == "all" ] ; then - echo 'flushing all' - interface=all +# echo 'flushing all' + _interface=all else + echo "${_interface}" exit 1 fi fi + echo "${_interface}" } - -echo "$@ $*" - if [ "$1" == 'off' ] ; then if [ -z "$2" ] ; then - interface="$2" + interface=$(guess_wifi '') else - guess_wifi 'all' + interface=$(guess_wifi 'all') fi echo 'OFF' sudo pkill -f dhcpcd sudo pkill -f wpa_supplicant - sudo ip route flush via "$interface"; + if [ "${interface}" = 'all' ] ; then + sudo ip route flush all + else + sudo ip route flush dev "${interface}" + fi sudo pkill -f ssh exit 0 elif [ -z "$1" ] ; then - guess_wifi '' + interface=$(guess_wifi '') else interface="$1" fi |