Add openconnect protocol support to network scripts
[openwrt/svn-archive/archive.git] / net / openconnect / files / openconnect.sh
1 find_gw() {
2 route -n | awk '$1 == "0.0.0.0" { print $2; exit }'
3 }
4
5 scan_openconnect() {
6 config_set "$1" device "vpn-$1"
7 }
8
9 stop_interface_openconnect() {
10 local config="$1"
11 local lock="/var/lock/openconnect-$config"
12
13 uci_set_state network "$config" up 0
14
15 lock "$lock"
16
17 SERVICE_PID_FILE="/var/run/openconnect-${config}.pid" \
18 SERVICE_SIG=HUP service_stop /bin/sh
19
20 remove_dns "$config"
21
22 lock -u "$lock"
23 }
24
25 setup_interface_openconnect() {
26 local config="$2"
27
28 /sbin/insmod tun 2>&- >&-
29
30 # creating the tunnel below will trigger a net subsystem event
31 # prevent it from touching or iface by disabling .auto here
32 uci_set_state network "$config" ifname "vpn-$config"
33 uci_set_state network "$config" auto 0
34 uci_set_state network "$config" up 1
35
36 SERVICE_PID_FILE="/var/run/openconnect-${config}.pid" \
37 SERVICE_WRITE_PID=1 SERVICE_DAEMONIZE=1 \
38 service_start /usr/sbin/run-openconnect $config
39 }