1 description "Bitcoin Core Daemon"
3 start on runlevel [2345]
4 stop on starting rc RUNLEVEL=[016]
6 env BITCOIND_BIN="/usr/bin/bitcoind"
7 env BITCOIND_USER="bitcoin"
8 env BITCOIND_GROUP="bitcoin"
9 env BITCOIND_PIDDIR="/var/run/bitcoind"
10 # upstart can't handle variables constructed with other variables
11 env BITCOIND_PIDFILE="/var/run/bitcoind/bitcoind.pid"
12 env BITCOIND_CONFIGFILE="/etc/bitcoin/bitcoin.conf"
13 env BITCOIND_DATADIR="/var/lib/bitcoind"
22 # this will catch non-existent config files
23 # bitcoind will check and exit with this very warning, but it can do so
24 # long after forking, leaving upstart to think everything started fine.
25 # since this is a commonly encountered case on install, just check and
27 if ! grep -qs '^rpcpassword=' "$BITCOIND_CONFIGFILE" ; then
28 echo "ERROR: You must set a secure rpcpassword to run bitcoind."
29 echo "The setting must appear in $BITCOIND_CONFIGFILE"
31 echo "This password is security critical to securing wallets "
32 echo "and must not be the same as the rpcuser setting."
33 echo "You can generate a suitable random password using the following"
34 echo "command from the shell:"
36 echo "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'"
38 echo "It is also recommended that you also set alertnotify so you are "
39 echo "notified of problems:"
41 echo "ie: alertnotify=echo %%s | mail -s \"Bitcoin Alert\"" \
47 mkdir -p "$BITCOIND_PIDDIR"
48 chmod 0755 "$BITCOIND_PIDDIR"
49 chown $BITCOIND_USER:$BITCOIND_GROUP "$BITCOIND_PIDDIR"
50 chown $BITCOIND_USER:$BITCOIND_GROUP "$BITCOIND_CONFIGFILE"
51 chmod 0660 "$BITCOIND_CONFIGFILE"
54 exec start-stop-daemon \
56 --pidfile "$BITCOIND_PIDFILE" \
57 --chuid $BITCOIND_USER:$BITCOIND_GROUP \
58 --exec "$BITCOIND_BIN" \
60 -pid="$BITCOIND_PIDFILE" \
61 -conf="$BITCOIND_CONFIGFILE" \
62 -datadir="$BITCOIND_DATADIR" \