aboutsummaryrefslogtreecommitdiffstats
path: root/community/bitcoin/bitcoin.initd
blob: a9c63fffde7d5cc8a1125752a9aafd94c064f00b (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
#!/sbin/openrc-run
supervisor=supervise-daemon

description="Bitcoin daemon"
name=bitcoind
command=/usr/bin/$name
config=/etc/bitcoin.conf
user=bitcoin
group=bitcoin
datadir=/var/lib/bitcoin
pidfile="/run/bitcoin/$SVCNAME.sd.pid"
command_args="-server -conf=$config -datadir=$datadir -pid=$pidfile"
supervise_daemon_args="-u $user -g $group"
nice="-19"

depend() {
	use net
	after logger firewall
}

in_contr() {
	grep "container=" /proc/1/environ
}

start_pre() {
	# enforce permissions
	checkpath -q -d ${pidfile%/*} -o ${user}:${group}
	checkpath -q -d ${datadir} -m 0700 -o ${user}:${group}
	checkpath -q -f ${config} -m 0600 -o ${user}:${group}

	# in lxc sys_nice capability is dropped by default
	if [ -z "$(in_contr)" ]; then
		supervise_daemon_args="$supervise_daemon_args -N $nice"
	fi
}