Stopping bitcoind is done by sending a signal to the daemon. I don't know how good bitcoind tries to close its databases, but I've had once a database corruption when killing the daemon. On the bitcoin chat people advised me to to send the rpc stop command to stop it (and call start-stop-daemon later again to clean it up), checking the debug log can give some information if it is closing right (flushing the database files). Best would be that bitcoind closes itself properly after receiving a kill signal.
How can I implement this to the skript?
Change:
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
to this:
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
$DAEMON stop
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
to implement BioMike's suggestion. See the '$DAEMON stop' line. This will tell bitcoin (via rpc) to stop running.
I also ended up changing this:
NAME=/usr/local/bin/bitcoind
DAEMON=$NAME
to:
NAME=bitcoind
DAEMON=/usr/local/sbin/bitcoind
DAEMON_ARGS="-daemon"
To get things working better for me. My install of ubuntu wouldn't support long NAMEs. Also when I issued a 'start' command the process would keep running in the foreground, so I added the '-daemon' argument to stop that from happening.