blob: 040edc76f63719e23ef55f1e24b72d061c44f8f3 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#!/sbin/openrc-run
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
VPN="${RC_SVCNAME#*.}"
VPNDIR="/etc/openconnect/${VPN}"
VPNLOG="/var/log/openconnect/${VPN}"
VPNLOGFILE="${VPNLOG}/openconnect.log"
VPNERRFILE="${VPNLOG}/openconnect.err"
command="/usr/sbin/openconnect"
name="OpenConnect: ${VPN}"
pidfile="/run/openconnect/${VPN}.pid"
stopsig="SIGINT"
depend() {
before netmount
}
checkconfig() {
if [ $VPN = "openconnect" ]; then
eerror "You cannot call openconnect directly. You must create a symbolic link to it with the vpn name:"
eerror
eerror "ln -s /etc/init.d/openconnect /etc/init.d/openconnect.vpn0"
eerror
eerror "And then call it instead:"
eerror
eerror "/etc/init.d/openconnect.vpn0 start"
return 1
fi
}
checktuntap() {
if [ "$RC_UNAME" = "Linux" -a ! -e /dev/net/tun ] ; then
if ! modprobe tun ; then
eerror "TUN/TAP support is not available in this kernel"
return 1
fi
fi
}
run_hook() {
if [ -x "$1" ]; then
"$@"
fi
}
start_pre() {
checkconfig || return
checktuntap || return
checkpath -d "${VPNLOG}" || return
checkpath -d /run/openconnect || return
run_hook "${VPNDIR}/preup.sh"
}
start() {
local server vpnopts password
eval server=\$server_${VPN}
eval vpnopts=\$vpnopts_${VPN}
eval password=\$password_${VPN}
ebegin "Starting ${name}"
start-stop-daemon --start --exec "${command}" -- \
--background \
--interface="${VPN}" \
--pid-file="${pidfile}" \
${vpnopts} \
"${server}" \
>> "${VPNLOGFILE}" \
2>> "${VPNERRFILE}" \
<<EOF
${password}
EOF
eend $?
}
start_post() {
run_hook "${VPNDIR}/postup.sh"
}
stop_pre() {
checkconfig || return
run_hook "${VPNDIR}/predown.sh"
}
stop_post() {
run_hook "${VPNDIR}/postdown.sh"
}
|