Hello there!
Any suggestion on how to reprogramm the sync button on Flint router to turn on/off wireguard client?
Hello there!
Any suggestion on how to reprogramm the sync button on Flint router to turn on/off wireguard client?
What firmware are you using? 3.214 or 4.x
Oh great, thanks for such a quick response .
Its 4.2.0 beta 2 currently
The file you should modify is
/etc/rc.button/switch
Now it print some log if you press the button
Fri Jan 20 09:13:24 2023 user.notice gl-switch: switch released
Fri Jan 20 09:13:24 2023 user.notice gl-switch: no config
Fri Jan 20 09:13:24 2023 user.notice gl-switch: switch pressed
Fri Jan 20 09:13:24 2023 user.notice gl-switch: no config
You are supposed to config in cat /etc/config/switch-button
but you can modify the above script directly.
Okay, thanks
One more question
In the folder /etc/gl-switch.d i can see some scripts like adguardhome.sh , openvpn.sh , tor.sh , wireguard.sh (!) which seem to be designed for triggering certain events when the button is pressed.
However i am not so good at bash so the contents is not completely clear for me.
#!/bin/sh
action=$1
if [ “$action” = “on” ];then
result=curl -s -k http://127.0.0.1/rpc -d "{\"jsonrpc\":\"2.0\",\"method\":\"call\",\"params\":[\"\",\"wg-client\",\"get_status\",{}],\"id\":1}" | jsonfilter -e @.result
status=echo $result | jsonfilter -e @.status
group_id=echo $result | jsonfilter -e @.group_id
peer_id=echo $result | jsonfilter -e @.peer_id
if [ “$status” = “0” -a -n “$group_id” -a “$group_id” != “0” -a -n “$peer_id” -a “$peer_id” != “0” ];then
curl -s -k http://127.0.0.1/rpc -d “{"jsonrpc":"2.0","method":"call","params":["","wg-client","start",{"group_id":$group_id,"peer_id":$peer_id}],"id":1}”
fi
fi
if [ “$action” = “off” ];then
curl -s -k http://127.0.0.1/rpc -d “{"jsonrpc":"2.0","method":"call","params":["","wg-client","stop",{}],"id":1}”
fi
sleep 5
It is for the switch button which is only available in some models.