1 description "Limenka Knots Daemon"
2 3 start on runlevel [2345]
4 stop on starting rc RUNLEVEL=[016]
5 6 env LIMENKAD_BIN="/usr/bin/limenkad"
7 env LIMENKAD_USER="limenka"
8 env LIMENKAD_GROUP="limenka"
9 env LIMENKAD_PIDDIR="/var/run/limenkad"
10 # upstart can't handle variables constructed with other variables
11 env LIMENKAD_PIDFILE="/var/run/limenkad/limenkad.pid"
12 env LIMENKAD_CONFIGFILE="/etc/limenka/limenka.conf"
13 env LIMENKAD_DATADIR="/var/lib/limenkad"
14 15 expect fork
16 17 respawn
18 respawn limit 5 120
19 kill timeout 600
20 21 pre-start script
22 # this will catch non-existent config files
23 # limenkad 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
26 # warn here.
27 if ! grep -qs '^rpcpassword=' "$LIMENKAD_CONFIGFILE" ; then
28 echo "ERROR: You must set a secure rpcpassword to run limenkad."
29 echo "The setting must appear in $LIMENKAD_CONFIGFILE"
30 echo
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:"
35 echo
36 echo "bash -c 'tr -dc a-zA-Z0-9 < /dev/urandom | head -c32 && echo'"
37 echo
38 echo "It is recommended that you also set alertnotify so you are "
39 echo "notified of problems:"
40 echo
41 echo "ie: alertnotify=echo %%s | mail -s \"Limenka Alert\"" \
42 "admin@foo.com"
43 echo
44 exit 1
45 fi
46 47 mkdir -p "$LIMENKAD_PIDDIR"
48 chmod 0755 "$LIMENKAD_PIDDIR"
49 chown $LIMENKAD_USER:$LIMENKAD_GROUP "$LIMENKAD_PIDDIR"
50 chown $LIMENKAD_USER:$LIMENKAD_GROUP "$LIMENKAD_CONFIGFILE"
51 chmod 0660 "$LIMENKAD_CONFIGFILE"
52 end script
53 54 exec start-stop-daemon \
55 --start \
56 --pidfile "$LIMENKAD_PIDFILE" \
57 --chuid $LIMENKAD_USER:$LIMENKAD_GROUP \
58 --exec "$LIMENKAD_BIN" \
59 -- \
60 -pid="$LIMENKAD_PIDFILE" \
61 -conf="$LIMENKAD_CONFIGFILE" \
62 -datadir="$LIMENKAD_DATADIR" \
63 -disablewallet \
64 -daemon
65 66