bitcoind.init raw

   1  #!/usr/bin/env bash
   2  #
   3  #  bitcoind The bitcoin core server.
   4  #
   5  #
   6  # chkconfig: 345 80 20
   7  # description: bitcoind
   8  # processname: bitcoind
   9  #
  10  
  11  # Source function library.
  12  . /etc/init.d/functions
  13  
  14  # you can override defaults in /etc/sysconfig/bitcoind, see below
  15  if [ -f /etc/sysconfig/bitcoind ]; then
  16          . /etc/sysconfig/bitcoind
  17  fi
  18  
  19  RETVAL=0
  20  
  21  prog=bitcoind
  22  # you can override the lockfile via BITCOIND_LOCKFILE in /etc/sysconfig/bitcoind
  23  lockfile=${BITCOIND_LOCKFILE-/var/lock/subsys/bitcoind}
  24  
  25  # bitcoind defaults to /usr/bin/bitcoind, override with BITCOIND_BIN
  26  bitcoind=${BITCOIND_BIN-/usr/bin/bitcoind}
  27  
  28  # bitcoind opts default to -disablewallet, override with BITCOIND_OPTS
  29  bitcoind_opts=${BITCOIND_OPTS--disablewallet}
  30  
  31  start() {
  32      echo -n $"Starting $prog: "
  33      daemon $DAEMONOPTS $bitcoind $bitcoind_opts
  34      RETVAL=$?
  35      echo
  36      [ $RETVAL -eq 0 ] && touch $lockfile
  37      return $RETVAL
  38  }
  39  
  40  stop() {
  41      echo -n $"Stopping $prog: "
  42      killproc $prog -t600
  43      RETVAL=$?
  44      echo
  45      [ $RETVAL -eq 0 ] && rm -f $lockfile
  46      return $RETVAL
  47  }
  48  
  49  case "$1" in
  50      start)
  51          start
  52          ;;
  53      stop)
  54          stop
  55          ;;
  56      status)
  57          status $prog
  58          ;;
  59      restart)
  60          stop
  61          start
  62          ;;
  63      *)
  64          echo "Usage: service $prog {start|stop|status|restart}"
  65          exit 1
  66          ;;
  67  esac
  68