aboutsummaryrefslogtreecommitdiffstats
path: root/community/bitcoin/bitcoin.initd
blob: 393ea453740f25e921014187ad5f1446ec92bdba (plain) (blame)
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
#!/sbin/openrc-run

# Bitcoin init.d file for Alpine Linux.

name=bitcoind
daemon=/usr/bin/$name
config=/etc/bitcoin.conf
user=bitcoin
group=bitcoin
## supercedes datadir set in $config ##
datadir=/var/lib/bitcoin
pidfile=/var/run/bitcoin/$name.pid

depend() {
        need net
        after logger firewall
}

start() {
        ebegin "Starting ${name}"
        # 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}
        start-stop-daemon --start --quiet \
                        --pidfile ${pidfile} \
                        --user ${user}:${group} \
                        --exec ${daemon} -- -conf=${config} -datadir=${datadir} -pid=${pidfile}
        eend $?
}

stop() {
        ebegin "Stopping ${name}"
                start-stop-daemon --stop --quiet \
                        --pidfile ${pidfile} \
                        --exec ${daemon}
        eend $?
}