2 .
/usr
/lib
/network
/network
6 [[ -z "$OVPN_CONFIG" ]] && OVPN_CONFIG
="/etc/openvpn/openvpn.conf"
7 [[ -z "$OVPN_PID_FILE" ]] && OVPN_PID_FILE
="/var/run/openvpn-$1.pid"
8 [[ -z "$OVPN_FLAGS" ]] && OVPN_FLAGS
=""
10 OVPN_CONF_DIR
="`dirname $OVPN_CONFIG`"
11 OVPN_CONF_FILE
="`basename $OVPN_CONFIG`"
13 /usr
/sbin
/openvpn
--writepid $OVPN_PID_FILE --daemon --cd "$OVPN_CONF_DIR" --config "$OVPN_CONF_FILE" $OVPN_FLAGS
15 if [[ $?
-ne 0 ]]; then
16 report_fail
"OpenVPN connection failed"
20 # Generate a new resolv.conf
21 if [[ -n "$DNS" ]]; then
22 [[ -e /etc
/resolv.conf
]] && cp /etc
/resolv.conf
/tmp
/openvpn-
$1-resolv.conf
24 [[ -n "$DOMAIN" ]] && echo "domain $DOMAIN" >>/etc
/resolv.conf
25 [[ -n "$SEARCH" ]] && echo "search $SEARCH" >>/etc
/resolv.conf
27 for dns
in "${DNS[@]}"; do
28 echo "nameserver $dns" >>/etc
/resolv.conf
30 elif [[ -n "$DNS1" ]]; then # support older 'ethernet' syntax.
31 [[ -e /etc
/resolv.conf
]] && cp /etc
/resolv.conf
/tmp
/openvpn-
$1-resolv.conf
33 [[ -n "$DOMAIN" ]] && echo "domain $DOMAIN" >>/etc
/resolv.conf
34 [[ -n "$SEARCH" ]] && echo "search $SEARCH" >>/etc
/resolv.conf
35 [[ -n "$DNS1" ]] && echo "nameserver $DNS1" >>/etc
/resolv.conf
36 [[ -n "$DNS2" ]] && echo "nameserver $DNS2" >>/etc
/resolv.conf
42 [[ -z "$OVPN_PID_FILE" ]] && OVPN_PID_FILE
="/var/run/openvpn-$1.pid"
44 kill $
(head -1 $OVPN_PID_FILE)
47 # Restore an old resolv.conf
48 if [[ -e /tmp
/openvpn-
$1-resolv.conf
]]; then
49 mv -f /tmp
/openvpn-
$1-resolv.conf
/etc
/resolv.conf
55 # vim: set ts=4 et sw=4: