Mango router profiles through side switch

Hi
I have a Mango router that has been very useful to me. I use it to talk to some equipment locally. I need to change IPs on the unit for different devices. I would like to use the switch on the side to change the Mango’s IPs. Is this possible? Where would I start if its possible?
Thanks

Edit the script file located at /usr/bin/switchaction. Add code to change the IP address within the file.

1 Like

Never done this before. Could you point me to an example please?

Here is an example.

To accomplish this, you will need to use basic tools such as ssh, vim, scp.

Thanks for the example, buts thats beyond my skillset. I just want to make switch position 1 set the IP as 192.168.0.2 with gateway 192.168.0.1 and switch position 2 and 3 different IP’s to talk to some equipment I have…

reference shell code:

if [ -n "$(grep -o "BTN_1.*hi" /sys/kernel/debug/gpio)" ]; then
	switch_right=1
	# add code to set ip and gateway
elif [ -n "$(grep -o "BTN_0.*hi" /sys/kernel/debug/gpio)" ]; then
	switch_left=1
	# add code to set ip and gateway
else
	switch_middle=1
	# add code to set ip and gateway
fi
1 Like

Here the code that will help you out. if you need help, ask chatGPT, it can guide you.

#!/bin/sh
if [ -n "$(grep -o "BTN_1.*hi" /sys/kernel/debug/gpio)" ]; then
	switch_right=1
	uci set network.lan.ipaddr='10.0.1.1'
    uci set network.lan.gateway='10.0.1.254'
    uci commit network
    /etc/init.d/network restart
elif [ -n "$(grep -o "BTN_0.*hi" /sys/kernel/debug/gpio)" ]; then
	switch_left=1
	uci set network.lan.ipaddr='10.0.2.1'
    uci set network.lan.gateway='10.0.2.254'
    uci commit network
    /etc/init.d/network restart
else
	switch_middle=1
	uci set network.lan.ipaddr='10.0.3.1'
    uci set network.lan.gateway='10.0.3.254'
    uci commit network
    /etc/init.d/network restart
fi
1 Like

Thanks for the direction. I was able to get the file above modified and into the router, but I dont see changes in IPs when moving the switch.

Please use the script overwrite /usr/bin/switchaction file.