X-Git-Url: https://git.llucax.com/software/wpe.git/blobdiff_plain/519405f3b7a45197b8c3a934da82e4e8d033410b..c7290e0558f4006d126bdc20d5554223d86f7772:/rotate-key?ds=inline diff --git a/rotate-key b/rotate-key index 82ab5a9..c8385db 100644 --- a/rotate-key +++ b/rotate-key @@ -1,5 +1,8 @@ #!/bin/sh +# Copyleft 2006 - Leandro Lucarella +# This script is under the BOLA license, please see the LICENSE file. + # Must edit ########### # Wireless interface @@ -30,6 +33,10 @@ KEY_FORMAT="$KEY_BASE%D%p" KEY_SIZE=13 # Hash command/algorithm used to compute the actual key HASH_PROG="sha1sum" +# ifconfig path +IFCONFIG="/sbin/ifconfig" +# iwconfig path +IWCONFIG="/sbin/iwconfig" # Do not touch ############## @@ -37,10 +44,17 @@ HASH_PROG="sha1sum" export LANG=C +# Check if interface exists +if ! $IFCONFIG "$IFACE" > /dev/null 2>&1 +then + exit 0 +fi + # Check if they are using our essid if [ -n "$ESSID" ] then - curr_essid=`iwconfig $IFACE | grep ESSID | sed 's/.*ESSID:"\([^"]\+\)".*/\1/'` + curr_essid=`$IWCONFIG $IFACE | grep ESSID \ + | sed 's/.*ESSID:"\([^"]\+\)".*/\1/'` if [ "$curr_essid" != "$ESSID" ] then exit 0 @@ -55,12 +69,12 @@ key=`echo "$str" | $HASH_PROG | cut -c-$size` # Compute the new channel if [ -n "$ROTATE_CHANNEL" ] then - chan=`echo $key | tr abcdef 847502 | cut -c-6` + chan=1`echo $key | tr abcdef 847502 | cut -c-6` chan=$(($chan % $MAX_CHANNEL + 1)) channel="channel $chan" fi # Commit changes -/sbin/iwconfig $IFACE key $SECURITY_MODE $key $channel $COMMIT +$IWCONFIG $IFACE key $SECURITY_MODE $key $channel $COMMIT # vim: set et sw=2 sts=2 :