source: freewrt/package/openvpn/files/openvpn-webif.init@ 93451a15

Last change on this file since 93451a15 was 93451a15, checked in by Dirk Nehring <dnehring@…>, 19 years ago

Sync to HEAD

git-svn-id: svn://www.freewrt.org/branches/dn-kernel-2.4.33@640 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100755
File size: 1.4 KB
Line 
1#!/bin/sh
2
3case "$(nvram get openvpn_cli)" in
4 on|enabled|1)
5 continue
6 ;;
7 off|disabled|0)
8 exit 0
9 ;;
10esac
11
12case "$1" in
13 autostart)
14 test x"$openvpn" = x"NO" && exit 0
15 exec $0 start
16 ;;
17 start)
18 SERVER=$(nvram get openvpn_cli_server)
19 PROTO=$(nvram get openvpn_cli_proto)
20 PORT=$(nvram get openvpn_cli_port)
21
22 [ "$SERVER" ] || {
23 logger "$0: remote server not configured!"
24 exit
25 }
26 case "$(nvram get openvpn_cli_auth)" in
27 cert)
28 AUTH_OPTION="--ns-cert-type server --pkcs12"
29 AUTH_FILE="/etc/openvpn/certificate.p12"
30 PKCS12PASS="$(nvram get openvpn_cli_pkcs12pass)"
31 [ "$PKCS12PASS" ] && {
32 echo -n "$PKCS12PASS" > /etc/openvpn/pkcs12pass.tmp
33 chmod 600 /etc/openvpn/pkcs12pass.tmp
34 AUTH_OPTION="--askpass /etc/openvpn/pkcs12pass.tmp $AUTH_OPTION"
35 }
36 ;;
37 psk)
38 AUTH_OPTION="--secret"
39 AUTH_FILE="/etc/openvpn/shared.key"
40 ;;
41 *)
42 logger "$0: unknown authentication type, aborting!"
43 exit
44 ;;
45 esac
46 [ -f "$AUTH_FILE" ] || {
47 logger "$0: no certificat/keyfile found!"
48 exit
49 }
50 openvpn --client \
51 --proto "${PROTO:-udp}" \
52 --port "${PORT:-1194}" \
53 --remote "$SERVER" \
54 --dev tun \
55 --nobind \
56 $AUTH_OPTION "$AUTH_FILE" \
57 --comp-lzo \
58 --daemon \
59 --status /tmp/openvpn-status.log \
60 --verb 3
61 ;;
62 restart)
63 $0 stop
64 sleep 3
65 $0 start
66 ;;
67 reload)
68 killall -SIGHUP openvpn
69 ;;
70 stop)
71 killall openvpn
72 ;;
73esac
Note: See TracBrowser for help on using the repository browser.