0

Trying to start bitcoind on CentOS 6, but just getting command not found errors.

#!/bin/bash
#
#  bitcoind The bitcoin core server.
#
#
# chkconfig: 345 80 20
# description: bitcoind
# processname: bitcoind
#

# Source function library.
. /etc/init.d/functions

prog=bitcoind
lockfile=/var/lock/subsys/bitcoind

start() {
    echo -n $"Starting $prog: "
    daemon --user bitcoind LD_LIBRARY_PATH=/home/bitcoind/bitcoind/deps/lib /home/bitcoind/bitcoind/downloads/bitcoin-0.9.4/src/bitcoind
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch $lockfile
    return $RETVAL
}

stop() {
    echo -n $"Stopping $prog: "
    killproc $prog
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f $lockfile
    return $RETVAL
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status $prog
        ;;
    restart)
        stop
        start
        ;;
    *)
        echo "Usage: service $prog {start|stop|status|restart}"
        exit 1
        ;;
esac

But then when I try to run it:

root@server1 [/etc/init.d]# service bitcoind start
Starting bitcoind: /etc/init.d/bitcoind: line 19:  : command not found
/etc/init.d/bitcoind: line 20:  : command not found

/etc/init.d/bitcoind: line 22: [: -eq: unary operator expected
root@server1 [/etc/init.d]#
Brad B
  • 1
  • 2

1 Answers1

1

Beneath the sourcing of functions, please add:

RETVAL=0

so that the lines look like:

# Source function library.
. /etc/init.d/functions
RETVAL=0

If you take a look into many of CentOS init scripts, majority of them has RETVAL=0 initialized.

% grep RETVAL=0 /etc/init.d/*
acpid:RETVAL=0
atop:RETVAL=0
auditd:RETVAL=0
autofs:     RETVAL=0
...
sshd:RETVAL=0
...
winbind:RETVAL=0
wine:RETVAL=0
Jakov Sosic
  • 5,157
  • 3
  • 22
  • 33