-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathswitch
More file actions
executable file
·52 lines (39 loc) · 1.61 KB
/
switch
File metadata and controls
executable file
·52 lines (39 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
. /lib/functions/gl_util.sh
logger -t "gl-switch" "$BUTTON ${ACTION}"
action=off
[ "$ACTION" = "pressed" ] && action=on
[ -e /proc/gl-hw-info/screen -a -z "$SERVICE" ] && {
/usr/bin/screen_disp_switch $action
}
# ADD YOUR EXIT NODE IP ADDRESS BELOW (--exit-node=HERE)
if [ "$action" = "on" ]; then
logger -t "gl-switch" "Set Exit node"
/usr/sbin/tailscale set --exit-node=100.XXX.YYY.ZZZ
elif [ "$action" = "off" ]; then
logger -t "gl-switch" "Turn off Exit node"
/usr/sbin/tailscale set --exit-node=
fi
func=$(uci -q get switch-button.@main[0].func) || {
logger -t "gl-switch" "no config"
exit 0
}
sub_func=$(uci -q get switch-button.@main[0].sub_func)
work_mode=$(uci -q get glconfig.general.mode)
[ "$work_mode" != "router" ] && {
[ "$func" = "cellular" ] || [ "$func" = "repeater" ] || [ "$sub_func" = "guest_wifi" ] && {
logger -t "gl-switch" "system is not working on router mode, $func $sub_func can't be exec"
exit 0
}
}
client_tap=$(uci -q get ovpnclient.$(uci -q get network.ovpnclient.config).mode)
tap_s2s_disabled=$(uci -q get network.ovpnclient.disabled)
[ "$client_tap" = tap-s2s -o "$client_tap" = tap ] && [ "$tap_s2s_disabled" = "0" ] && echo "taps2senable,exit" >> /tmp/fzk && exit 0
[ -x /etc/gl-switch.d/$func.sh ] || {
logger -t "gl-switch" "/etc/gl-switch.d/$func.sh can't be exec"
exit 0
}
[ $(ubus call repeater status | jsonfilter -e "@.portal") = true ] && conflict=1
[ $(uci -q get mptun.global.enable) = "1" ] && conflict=1
[ "$work_mode" != "router" ] && conflict=1
flock /var/lock/gl-switch.lock "/etc/gl-switch.d/$func.sh" $action &