summaryrefslogtreecommitdiff
path: root/net-vpn/headscale/files/headscale.initd
blob: 5a98c0e6cb34e286934656a2871f0c06a6cdcc1b (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
#!/sbin/openrc-run
# Copyright 2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

description="Headscale Server daemon"
command="/usr/bin/headscale"
user="${HEADSCALE_USER}:${HEADSCALE_GROUP}"
directory="/var/lib/headscale"
output_log="/var/log/headscale.log"
error_log="/var/log/headscale.log"

start_stop_daemon_args="--user \"${user}\" ${HEADSCALE_OPTIONS} --background"

depend() {
	need net
}

start_pre() {
	if [ ! -s /etc/headscale/config.yaml ] ; then
		eerror "Missing headscale configuration file"
		eerror "Please check the documentation directory for an example"
		return 1
	fi

	checkpath -d -m 700 -o "${user}" /run/headscale /var/lib/headscale
	checkpath -f -m 600 -o "${user}" /var/lib/headscale/db.sqlite /var/log/headscale.log
	checkpath -f -m 600 -o "${user}" /etc/headscale/config.yaml
}