alzhao
2
First detect the switch location, then do something.
This script only works when you move the switch, not when router power up. So you’d better put the script in /etc/init.d/initswitch (firmware 2.x) or /usr/bin/switchaction (firmware 3.x)
You will find there are a lot of script already. So you may need to modify instead of write something yourself.
The ideas are:
switch_left=$(grep -o "BTN_8.*hi" /sys/kernel/debug/gpio)
if [ -n "$switch_left" ]; then
#this is the left side, let's use repeater. If we renamed gl_health, name it back
mv /usr/bin/gl_health1 /usr/bin/gl_health
/usr/bin/gl_health &
uci set wireless.sta.disabled=0
uci commit wireless
wifi #if in startup script, remove this line
else
#this is the right side, let's disable repeater and repeater manager. We also rename gl_health so that it will not called up by the UI or other scripts
killall /usr/bin/gl_health
mv /usr/bin/gl_health /usr/bin/gl_health1
uci set wireless.sta.disabled=1
uci commit wireless
wifi #if in startup script, remove this line
fi
1 Like