diff --git a/files/etc/config.ap/system b/files/etc/config.ap/system index 868f1606..80147254 100644 --- a/files/etc/config.ap/system +++ b/files/etc/config.ap/system @@ -1,3 +1,17 @@ config 'system' option 'hostname' '' +config button + option button 'reset' + option action 'released' + option handler '/usr/local/bin/bbhnrecoverymode' + option min '3' + option max '7' + +config button + option button 'reset' + option action 'released' + option handler 'firstboot && reboot' + option min '8' + option max '12' + diff --git a/files/etc/config.client/system b/files/etc/config.client/system index 868f1606..80147254 100644 --- a/files/etc/config.client/system +++ b/files/etc/config.client/system @@ -1,3 +1,17 @@ config 'system' option 'hostname' '' +config button + option button 'reset' + option action 'released' + option handler '/usr/local/bin/bbhnrecoverymode' + option min '3' + option max '7' + +config button + option button 'reset' + option action 'released' + option handler 'firstboot && reboot' + option min '8' + option max '12' + diff --git a/files/etc/config.mesh/system b/files/etc/config.mesh/system index 868f1606..80147254 100644 --- a/files/etc/config.mesh/system +++ b/files/etc/config.mesh/system @@ -1,3 +1,17 @@ config 'system' option 'hostname' '' +config button + option button 'reset' + option action 'released' + option handler '/usr/local/bin/bbhnrecoverymode' + option min '3' + option max '7' + +config button + option button 'reset' + option action 'released' + option handler 'firstboot && reboot' + option min '8' + option max '12' + diff --git a/files/etc/config.mesh_ap/system b/files/etc/config.mesh_ap/system index 868f1606..80147254 100644 --- a/files/etc/config.mesh_ap/system +++ b/files/etc/config.mesh_ap/system @@ -1,3 +1,17 @@ config 'system' option 'hostname' '' +config button + option button 'reset' + option action 'released' + option handler '/usr/local/bin/bbhnrecoverymode' + option min '3' + option max '7' + +config button + option button 'reset' + option action 'released' + option handler 'firstboot && reboot' + option min '8' + option max '12' + diff --git a/files/etc/config.router/system b/files/etc/config.router/system index 868f1606..80147254 100644 --- a/files/etc/config.router/system +++ b/files/etc/config.router/system @@ -1,3 +1,17 @@ config 'system' option 'hostname' '' +config button + option button 'reset' + option action 'released' + option handler '/usr/local/bin/bbhnrecoverymode' + option min '3' + option max '7' + +config button + option button 'reset' + option action 'released' + option handler 'firstboot && reboot' + option min '8' + option max '12' + diff --git a/files/etc/config/system b/files/etc/config/system index 2f0b909d..dd85d7cc 100644 --- a/files/etc/config/system +++ b/files/etc/config/system @@ -1,3 +1,16 @@ config 'system' option 'hostname' 'NOCALL' +config button + option button 'reset' + option action 'released' + option handler '/usr/local/bin/bbhnrecoverymode' + option min '3' + option max '7' + +config button + option button 'reset' + option action 'released' + option handler 'firstboot && reboot' + option min '8' + option max '12' diff --git a/files/etc/hotplug.d/button/00-button b/files/etc/hotplug.d/button/00-button new file mode 100644 index 00000000..63cc217d --- /dev/null +++ b/files/etc/hotplug.d/button/00-button @@ -0,0 +1,24 @@ +. /lib/functions.sh +do_button () { + local button + local action + local handler + local min + local max + + config_get button $1 button + config_get action $1 action + config_get handler $1 handler + config_get min $1 min + config_get max $1 max + + [ "$ACTION" = "$action" -a "$BUTTON" = "$button" -a -n "$handler" ] && { + [ -z "$min" -o -z "$max" ] && eval $handler + [ -n "$min" -a -n "$max" ] && { + [ $min -le $SEEN -a $max -ge $SEEN ] && eval $handler + } + } +} + +config_load system +config_foreach do_button button diff --git a/files/usr/local/bin/bbhnrecoverymode b/files/usr/local/bin/bbhnrecoverymode new file mode 100644 index 00000000..57a47a2c --- /dev/null +++ b/files/usr/local/bin/bbhnrecoverymode @@ -0,0 +1,17 @@ +#!/bin/sh + +DHCPLANSECTION=`uci show dhcp|grep interface=lan|sed "s/dhcp.\@dhcp\[\(.*\)\].interface=lan/\1/"` + +logger "BBHN Recovery: Reseting password to BBHN default" +/usr/local/bin/setpasswd hsmm + +if [ "$DHCPLANSECTION" != "" ] + then + logger "BBHN Recovery: Enable DHCP on lan interface" + uci set dhcp.@dhcp\[$DHCPLANSECTION\].ignore=0 + uci -q commit + + logger "BBHN Recovery: Restart dnsmasq" + /etc/init.d/dnsmasq restart +fi +