aboutsummaryrefslogtreecommitdiff
path: root/coWifi
diff options
context:
space:
mode:
authorache <ache@ache.one>2018-01-15 02:06:23 +0100
committerache <ache@ache.one>2018-01-15 02:06:23 +0100
commitce19d133fe2a245066861a345c2a15a4d0a04c40 (patch)
tree799fa7b8902267c7167c2f91d3c27c74275eb496 /coWifi
parentInit crypted mount scripts (diff)
Fix off with guess_wifi improvement
Diffstat (limited to 'coWifi')
-rwxr-xr-xcoWifi26
1 files changed, 15 insertions, 11 deletions
diff --git a/coWifi b/coWifi
index 517d419..5e17619 100755
--- a/coWifi
+++ b/coWifi
@@ -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