| 1 | #!/sbin/openrc-run |
| 2 | |
| 3 | name="ocserv" |
| 4 | description="OpenConnect VPN server" |
| 5 | command="/usr/sbin/ocserv" |
| 6 | command_args="--pid-file /run/ocserv.pid --config /etc/ocserv/ocserv.conf" |
| 7 | pidfile="/run/ocserv.pid" |
| 8 | command_background=true |
| 9 | |
| 10 | configfile="/etc/ocserv/ocserv.conf" |
| 11 | |
| 12 | extra_commands="checkconfig" |
| 13 | description_checkconfig="Checks configuration file for errors" |
| 14 | |
| 15 | depend() { |
| 16 | need net |
| 17 | } |
| 18 | |
| 19 | checkconfig() { |
| 20 | if [ ! -f "$configfile" ]; then |
| 21 | eerror "Configuration file $configfile not found" |
| 22 | eerror "Please create it before starting ocserv" |
| 23 | return 1 |
| 24 | fi |
| 25 | |
| 26 | ebegin "Checking $name configuration" |
| 27 | "$command" --test-config --config "$configfile" >/dev/null 2>&1 |
| 28 | eend $? |
| 29 | } |
| 30 | |
| 31 | start_pre() { |
| 32 | checkpath --directory --owner ocserv:ocserv --mode 0755 /var/lib/ocserv |
| 33 | checkconfig || return $? |
| 34 | } |
| 35 | |
| 36 | reload() { |
| 37 | ebegin "Reloading $name configuration" |
| 38 | start-stop-daemon --signal HUP --pidfile "$pidfile" |
| 39 | eend $? |
| 40 | } |