-
Notifications
You must be signed in to change notification settings - Fork 1
/
openvpn
executable file
·67 lines (54 loc) · 1.01 KB
/
openvpn
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
#!/usr/bin/env bash
# start stop script for openvpn on OS X installed from macports
CONF_DIR="/etc/openvpn"
PIDFILE=/var/run/openvpn.pid
check_status () {
if [ -x $PIDFILE ]; then
ps -p `cat $PIDFILE` | grep -q `cat $PIDFILE`
if [ $? -eq "0" ]; then
echo "pid `cat $PIDFILE` is running..."
else
echo "VPN is not running"
fi
else
echo "VPN is not running"
fi
}
if [ $( whoami ) != "root" ]; then
if [ $1 == "status" ]; then
check_status
else
echo "You must be root to run this script"
exit 1
fi
fi
if [ $2 ]; then
CONFIG="${CONF_DIR}/${2}.conf"
else
CONFIG=`ls ${CONF_DIR}/*.conf | head -1`
fi
case $1 in
start)
/opt/local/sbin/openvpn2 --cd $CONF_DIR --config $CONFIG --daemon --writepid $PIDFILE
;;
stop)
kill `cat $PIDFILE` || true
rm -f $PIDFILE
;;
restart)
shift
$0 stop ${@}
sleep 1
$0 start ${@}
;;
reload)
kill -USR1 `cat $PIDFILE`
;;
status)
#check_status
;;
*)
echo "Usage: $0 {start|stop|restart} [site]"
exit 1
;;
esac