summaryrefslogtreecommitdiff
path: root/package/comgt/files/3g.button
blob: 54997d870aed81e17ebb4ab3da5f691309cd130e (plain)
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
button_action() {(
	# use led for keeping track of the state
	case "$(cat /proc/diag/led/3g_green)" in
		1)
			ifdown "$1"
			ifup wan
		;;
		0)
			ifdown wan
			ifup "$1"
		;;
	esac
)}

[ "$ACTION" = "released" -a "$BUTTON" = "3g" ] && {
	(echo /bin/true > /proc/sys/kernel/hotplug)

	include /lib/network
	scan_interfaces
	config_cb() {
		config_get TYPE "$CONFIG_SECTION" TYPE
		case "$TYPE" in
			interface)
				config_get proto "$CONFIG_SECTION" proto
				config_get button "$CONFIG_SECTION" button
				case "$button" in
					1|on|enabled) [ "$proto" = "3g" ] && button_action "$CONFIG_SECTION";;
				esac
			;;
		esac
	}
	config_load network

	(echo /sbin/hotplug > /proc/sys/kernel/hotplug)
} &