2011-11-13 01:39:56 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
[ "${ACTION}" = "released" ] || exit 0
|
|
|
|
|
|
|
|
. /lib/functions.sh
|
|
|
|
|
2012-12-21 15:47:50 +02:00
|
|
|
logger "$BUTTON pressed for $SEEN seconds"
|
|
|
|
|
|
|
|
local rfkill_state=0
|
|
|
|
|
|
|
|
wifi_rfkill_set() {
|
|
|
|
uci set wireless.$1.disabled=$rfkill_state
|
|
|
|
}
|
|
|
|
|
|
|
|
wifi_rfkill_check() {
|
|
|
|
local disabled
|
|
|
|
config_get disabled $1 disabled
|
|
|
|
[ "$disabled" = "1" ] || rfkill_state=1
|
|
|
|
}
|
|
|
|
|
2011-11-13 01:39:56 +02:00
|
|
|
case "${BUTTON}" in
|
2012-12-19 17:17:42 +02:00
|
|
|
reset)
|
2012-12-21 15:47:50 +02:00
|
|
|
if [ "$SEEN" -lt 1 ]
|
|
|
|
then
|
|
|
|
echo "REBOOT" > /dev/console
|
|
|
|
sync
|
|
|
|
reboot
|
|
|
|
elif [ "$SEEN" -gt 5 ]
|
|
|
|
then
|
|
|
|
echo "FACTORY RESET" > /dev/console
|
|
|
|
firstboot && reboot &
|
|
|
|
fi
|
2011-11-13 01:39:56 +02:00
|
|
|
;;
|
2012-12-21 15:47:50 +02:00
|
|
|
|
|
|
|
wps)
|
|
|
|
for dir in /var/run/hostapd-*; do
|
|
|
|
[ -d "$dir" ] || continue
|
|
|
|
hostapd_cli -p "$dir" wps_pbc
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
|
|
|
|
rfkill)
|
|
|
|
config_load wireless
|
|
|
|
config_foreach wifi_rfkill_check wifi-device
|
|
|
|
config_foreach wifi_rfkill_set wifi-device
|
|
|
|
uci commit wireless
|
|
|
|
wifi up
|
2011-11-13 01:39:56 +02:00
|
|
|
;;
|
2012-12-21 15:47:50 +02:00
|
|
|
|
2011-11-13 01:39:56 +02:00
|
|
|
*)
|
|
|
|
logger "unknown button ${BUTTON}"
|
|
|
|
;;
|
|
|
|
esac
|