Mudi gl-e750 vpn switch

@alzhao
On the Mudi e750 router, Is it possible to map the switch to a custom script so I can start and stop a script instead of starting and stopping a vpn or tor when the switch is turned up or turned down. How would I go about getting this control?
Any help greatly appreciated
Thanks

While if you set it up to turn on/off vpn or tor, you can actually see how it works.

Pls check the following files to see how it works.

/etc/init.d/initswitch
/usr/bin/switchaction

In this file /etc/config/glconfig you can find the defination of switch buttion actions if you have set in the UI. You can change to your own function

config service 'switch_button'
        option enable '1'
        option function 'myfun'

Then in /usr/bin/switchaction you can write your own script like below. You need to add both on and off

"myfun")
         #this is your own script, toggle on
         /usr/bin/myownscript.sh on
;;

Like in this images. /usr/bin/myownscript.sh is your own script

Thanks for the detailed response. It works !