]> Git Repo - VerusCoin.git/blob - contrib/init/bitcoind.openrc
Merge pull request #5360
[VerusCoin.git] / contrib / init / bitcoind.openrc
1 #!/sbin/runscript
2
3 # backward compatibility for existing gentoo layout 
4 #
5 if [ -d "/var/lib/bitcoin/.bitcoin" ]; then
6         BITCOIND_DEFAULT_DATADIR="/var/lib/bitcoin/.bitcoin"
7 else
8         BITCOIND_DEFAULT_DATADIR="/var/lib/bitcoind"
9 fi
10
11 BITCOIND_CONFIGFILE=${BITCOIND_CONFIGFILE:-/etc/bitcoin/bitcoin.conf}
12 BITCOIND_PIDDIR=${BITCOIND_PIDDIR:-/var/run/bitcoind}
13 BITCOIND_PIDFILE=${BITCOIND_PIDFILE:-${BITCOIND_PIDDIR}/bitcoind.pid}
14 BITCOIND_DATADIR=${BITCOIND_DATADIR:-${BITCOIND_DEFAULT_DATADIR}}
15 BITCOIND_USER=${BITCOIND_USER:-${BITCOIN_USER:-bitcoin}}
16 BITCOIND_GROUP=${BITCOIND_GROUP:-bitcoin}
17 BITCOIND_BIN=${BITCOIND_BIN:-/usr/bin/bitcoind}
18 BITCOIND_NICE=${BITCOIND_NICE:-${NICELEVEL:-0}}
19 BITCOIND_OPTS="${BITCOIND_OPTS:-${BITCOIN_OPTS}}"
20
21 name="Bitcoin Core Daemon"
22 description="Bitcoin crypto-currency p2p network daemon"
23
24 command="/usr/bin/bitcoind"
25 command_args="-pid=\"${BITCOIND_PIDFILE}\" \
26                 -conf=\"${BITCOIND_CONFIGFILE}\" \
27                 -datadir=\"${BITCOIND_DATADIR}\" \
28                 -daemon \
29                 ${BITCOIND_OPTS}"
30
31 required_files="${BITCOIND_CONFIGFILE}"
32 start_stop_daemon_args="-u ${BITCOIND_USER} \
33                         -N ${BITCOIND_NICE} -w 2000"
34 pidfile="${BITCOIND_PIDFILE}"
35 retry=60
36
37 depend() {
38         need localmount net
39 }
40
41 # verify
42 # 1) that the datadir exists and is writable (or create it)
43 # 2) that a directory for the pid exists and is writable
44 # 3) ownership and permissions on the config file
45 start_pre() {
46         checkpath \
47         -d \
48         --mode 0750 \
49         --owner "${BITCOIND_USER}:${BITCOIND_GROUP}" \
50         "${BITCOIND_DATADIR}"
51
52         checkpath \
53         -d \
54         --mode 0755 \
55         --owner "${BITCOIND_USER}:${BITCOIND_GROUP}" \
56         "${BITCOIND_PIDDIR}"
57
58         checkpath -f \
59         -o ${BITCOIND_USER}:${BITCOIND_GROUP} \
60         -m 0660 \
61         ${BITCOIND_CONFIGFILE}
62
63         checkconfig || return 1
64 }
65
66 checkconfig()
67 {
68         if ! grep -qs '^rpcpassword=' "${BITCOIND_CONFIGFILE}" ; then
69                 eerror ""
70                 eerror "ERROR: You must set a secure rpcpassword to run bitcoind."
71                 eerror "The setting must appear in ${BITCOIND_CONFIGFILE}"
72                 eerror ""
73                 eerror "This password is security critical to securing wallets "
74                 eerror "and must not be the same as the rpcuser setting."
75                 eerror "You can generate a suitable random password using the following"
76                 eerror "command from the shell:"
77                 eerror ""
78                 eerror "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'"
79                 eerror ""
80                 eerror "It is also recommended that you also set alertnotify so you are "
81                 eerror "notified of problems:"
82                 eerror ""
83                 eerror "ie: alertnotify=echo %%s | mail -s \"Bitcoin Alert\"" \
84                         "[email protected]"
85                 eerror ""
86                 return 1
87         fi
88 }
This page took 0.029407 seconds and 4 git commands to generate.