Potential RC.Button script improvement

I was trying out the rc.button script by @illusion (below), which ‘allows recovery from non-functioning wifi due to using client mode (AP+STA) and the client network being unavailable or misconfigured’, and noticed that when it disables STA it is no longer possible to set up a repeater without going to LUCI to manually enable the client interface.

I think I may have found a solution to this, but I’m not sure exactly how to script it. If the script was to enable DHCP mode (done manually in the GLI interface by going to Internet Settings > Cable > DHCP > Submit) then it would broadcast the SSID and allow repeater set-up through the GLI web interface. Can anyone help me modify the below script to achieve this?

#!/bin/sh

[ “${ACTION}” = “released” ] || exit 0

. /lib/functions.sh

logger “$BUTTON pressed for $SEEN seconds”

if [ “$SEEN” -lt 2 ]
then
/usr/bin/wifionoff
elif [ “$SEEN” -ge 2 ] && [ “$SEEN” -lt 5 ]
then
logger “Disabling STA interface”
/sbin/uci set wireless.sta.disabled=‘1’
/sbin/uci commit
/sbin/wifi up
elif [ “$SEEN” -gt 5 ]
then
echo “FACTORY RESET” > /dev/console
/usr/bin/flashleds &
jffs2reset -y && reboot &
fi

Yes. you can go back to DHCP mode. I marked all changes in bold. I didn’t test. But this should works fine.

 

#!/bin/sh

[ “${ACTION}” = “released” ] || exit 0

. /lib/functions.sh

logger “$BUTTON pressed for $SEEN seconds”

if [ “$SEEN” -lt 2 ]
then
/usr/bin/wifionoff
elif [ “$SEEN” -ge 2 ] && [ “$SEEN” -lt 5 ]
then
logger “Disabling STA interface”
/sbin/uci set wireless.sta.disabled=’1′
/sbin/uci commit wireless

uci set network.wan.proto='dhcp'

uci set network.wan.ifname='eth0'

uci commet network

/etc/init.d/network restart
/sbin/wifi up
elif [ “$SEEN” -gt 5 ]
then
echo “FACTORY RESET” > /dev/console
/usr/bin/flashleds &
jffs2reset -y && reboot &
fi

I’m not sure what “STA” means. Can someone explain that to me?

sta means “Station”, i.e. client.