#!/bin/sh # az [2012-05-05 Sat 19:11] tiny killswitch reaction tool # if rfkill blocked, properly shut down the interface # if rfkill unblocked, bring the interface up # interface name hardcoded (lazy me) XIFACE=eth1 ME=$(busybox basename $0)"[$$]" [ -t 2 ] && LOGARGS=-s mesg () { busybox logger $LOGARGS -t "$ME" "$@" } debug_mesg () { [ -z "$DEBUG" ] && return mesg "$@" } # rfkill devs: marks state as 1 for on, 0 and 2 for off if [ "$RFKILL_TYPE" = "wlan" -a "$ACTION" = "change" ] ; then debug_mesg "interface $XIFACE/$RFKILL_TYPE to state $RFKILL_STATE" if [ "$RFKILL_STATE" = "1" ] ; then mesg "bringing up interface $XIFACE" # on hp dm1 a bit of delay is necessary, or # the interface doesn't go up, the supplicant can't scan # and we're stuck sleep 1 /sbin/ifup $XIFACE elif [ "$RFKILL_STATE" != "1" ]; then mesg "taking down interface $XIFACE" /sbin/ifdown $XIFACE fi fi exit 0