Skip to main content

Debian/Ubuntu Bitcoin Daemon Startup Script

`bitcoind` init.d startup script

The Debian bitcoind package does not install or contain any init.d scripts, and net search failed to return any decent examples so I had to crate my own.

If this has helped please comment or follow me on twitter danielsokolows - be great.

#!/bin/sh
### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*-
### BEGIN INIT INFO
# Provides: bitcoind
# Required-Start: $network $remote_fs $local_fs
# Required-Stop: $network $remote_fs $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Bitcoin Deamon
# Description: Bitcoin Deamon
### END INIT INFO

# modified by Daniel Sokolowski 

# Install by typing  update-rc.d  defaults

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC=bitcoind
NAME=bitcoind
PIDFILE=/var/run/bitcoind.pid
USER=root
DAEMON=/usr/bin/bitcoind
#DAEMON_ARGS="-pid=$PIDFILE -datadir=/mnt/M=ST8000AS0002-1NA17Z,S=Z840PWH2/bitcoind-datadir -debuglogfile=/var/log/bitcoind.log"
DAEMON_ARGS="-daemon -pid=$PIDFILE -datadir=/mnt/M=ST8000AS0002-1NA17Z,S=Z840PWH2/bitcoind-datadir -debuglogfile=/var/log/bitcoind.log"
#SCRIPTNAME=/etc/init.d/$NAME
#WORKDIR=/var/lib/$NAME

# Check if user exists
if ! id -u $USER > /dev/null 2>&1; then
    echo "The user does not exist; execute below commands to crate and try again:"
    echo "  root@sh1:~# adduser --home /usr/local/freeswitch/ --shell /bin/false --no-create-home --ingroup daemon --disabled-password --disabled-login $USER"
    echo "  ..."
    echo "  root@sh1:~# chown freeswitch:daemon /usr/local/freeswitch/ -R"
    exit 1
fi

[ -x $DAEMON ] || exit 0
#[ -r /etc/default/$NAME ] && . /etc/default/$NAME
. /lib/init/vars.sh
. /lib/lsb/init-functions

do_start() {
  #start-stop-daemon --start --quiet \
  #     --pidfile $PIDFILE --exec $DAEMON --name $NAME --user $USER \
  #     --chdir $WORKDIR -- $DAEMON $DAEMON_OPTS \
#echo $DAEMON $DAEMON_ARGS
  nice -19 $DAEMON $DAEMON_ARGS  || return 1
  return 0
}

do_stop() {
  start-stop-daemon --stop --quiet \
    --pidfile $PIDFILE  --name $NAME --user $USER \
    --retry=TERM/30/KILL/5
}

do_reload() {
  start-stop-daemon --stop --quiet \
    --pidfile $PIDFILE --name $NAME --user $USER \
    --signal HUP
}

case "$1" in
  start)
    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
    do_start
    case "$?" in
      0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
      2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
    esac
    ;;
  stop)
    [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
    do_stop
    case "$?" in
      0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
      2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
    esac
    ;;
  status)
    status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
    ;;
  reload|force-reload)
    log_daemon_msg "Reloading $DESC" "$NAME"
    do_reload
    log_end_msg $?
    ;;
  restart)
    log_daemon_msg "Restarting $DESC" "$NAME"
    do_stop
    case "$?" in
      0|1)
        do_start
        case "$?" in
          0) log_end_msg 0 ;;
          1|*) log_end_msg 1 ;;
        esac
        ;;
      *) log_end_msg 1 ;;
    esac
    ;;
  *)
    echo "Usage:  {start|stop|status|restart|force-reload}" >&2
    exit 3
    ;;
esac

exit 0

Comments

Popular posts from this blog

Storing passwords in PuTTY

How to save SSH username/password for auto login in PuTTy The answer is you can't do it...at least in plain PuTTy. However there is an awesome fork with that let's you store the username and password and other additional features called KiTTy . So grab yourself a copy and +1 this if you do, thanks.

Softeher 'Error occurred. (Error code: 2)' sollution

Protocol error occurred. Error was returned from the destination server. The Softether server by default to run on port 443 , if you server also hosts normal https then 443 is already taken and so Softether can't bind to it. When you run `vpncmd` it attempts to connect, find an active port, but of course fails with 'Protocol error occurred. Error was returned from the destination server.' because it's not actually connecting to the vpn server. By default Softether also listens on 992 , 1194 , and 5555 so the sollution is to modify specify `localhost:5555` when executing the `vpncmnd`. If this has helped you feel free to comment or follow me on twitter @danielsokolows .

LightScribe Template Labeler for Windows 10

LightScribe Template Labeler installation "Operating System Inadequate" Issue Unfortunately 'LightScribe Template Labeler' installation will not work on Windows 8 and Windows 10 machines as the install simply will error out with 'Operating System Inadequate'. Trying to install using compatibility mode did not help. Installing LightScribe Template Labeler Workaround However if you simply copy the installed folder from an older machine like Windows 7 into your `C:\\Program Files (x86)\LightScribe Template Labeler`, create a shortcut, then the software will still happily work, see: http://answers.microsoft.com/en-us/windows/forum/windows8_1-performance/lightscribe-templatesimple-labeler-the-system-is/c2ebee28-bfb5-4aef-beb3-a43329561da8?db=5&auth=1 So you can install Windows 7 machine in a virtual machine, install 'LightScribe Template Labeler', and then copy the resulting folder to your Windows 8 or Windows 10 machine. For my own convenien...