summaryrefslogtreecommitdiffstats
path: root/network/ocserv/rc.ocserv
blob: 83fa395888f9ae82dd0af759f10fad4c09740037 (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
#!/bin/bash
# Start/stop/restart the ocserv vpn server
# This script uses the occtl tool

start_ocserv() {
  if [ -S /var/run/occtl.socket ]; then
      echo "ocserv is already running"
      exit 0
  fi
  echo "Starting ocserv"
  /usr/sbin/ocserv 2>/dev/null
}

stop_ocserv() {
  /usr/bin/occtl stop now
}

restart_ocserv() {
  stop_ocserv
  sleep 1
  start_ocserv
}

reload_ocserv() {
  /usr/bin/occtl reload
}

status_ocserv() {
  if [ -S /var/run/occtl.socket ]; then
    /usr/bin/occtl show status
  else
    echo "ocserv is stopped"
    exit 1
  fi
}

case "$1" in
'start')
  start_ocserv
  ;;
'stop')
  stop_ocserv
  ;;
'restart')
  restart_ocserv
  ;;
'reload')
  reload_ocserv
  ;;
'status')
  status_ocserv
  ;;
*)
  echo "usage $0 start|stop|restart|reload|status"
esac