#!/sbin/openrc-run
# Generated by `securqbitd install`. Edits are overwritten on reinstall.

name='SecurQbit VPN Daemon'
description='Manages the SecurQbit VPN tunnel, credentials and local control plane.'
command=/usr/local/bin/securqbitd
command_args='--config /etc/securqbit/config.yaml'
command_background="yes"
pidfile=/run/securqbit/securqbitd.pid
output_log=/var/log/securqbit/securqbitd.out.log
error_log=/var/log/securqbit/securqbitd.out.log

# The daemon restores the host's routing and DNS on the way out.
# Killing it early is how a machine ends up with no working network.
retry="TERM/20/KILL/5"

depend() {
	need net
	use dns logger
	after firewall
}

start_pre() {
	checkpath --directory --mode 0755 /run/securqbit
	checkpath --directory --mode 0700 /var/lib/securqbit
	checkpath --directory --mode 0750 /var/log/securqbit
	# /dev/net/tun has to exist before the first connect.
	modprobe -q tun 2>/dev/null
	return 0
}
