The only script that worked for me is the usual way - in /etc/init.d directory:
################################################################################
#! /bin/sh
user="kostaz";
# peer="
";
dir="/home/${user}";
daemon="bitcoind";
pidfile="${dir}/.bitcoin/${daemon}.pid";
daemonfull="/usr/bin/bitcoind";
# args="-daemon -addnode=${peer}";
# args="-daemon";
do_start ()
{
echo "Starting bitcoin server..."
echo "start-stop-daemon --start --chuid $user --chdir $dir --pidfile $pidfile --startas $daemonfull"
# start-stop-daemon --start --chuid $user --chdir $dir --pidfile $pidfile --startas $daemonfull -- $args
start-stop-daemon --start --chuid $user --chdir $dir --pidfile $pidfile --startas $daemonfull
}
do_stop ()
{
echo "Stopping bitcoin server..."
echo "start-stop-daemon --stop --chuid $user --chdir $dir --pidfile $pidfile --startas $daemonfull"
start-stop-daemon --stop --chuid $user --chdir $dir --pidfile $pidfile --startas $daemonfull
}
do_status ()
{
echo "Checking status of bitcoin server..."
echo "start-stop-daemon --status --chuid $user --chdir $dir --pidfile $pidfile --startas $daemonfull"
start-stop-daemon --status --chuid $user --chdir $dir --pidfile $pidfile --startas $daemonfull
}
case "$1" in
start|"")
do_start
;;
stop)
do_stop
;;
status)
do_status
;;
restart)
do_stop
sleep 10
do_start
;;
*)
echo "Wrong arguments"
exit 3
;;
esac
:
################################################################################
After copying the script to /etc/init.d/bitcoin file and making it executable (with chmod +x) you can do:
$ sudo service bitcoin start
$ sudo service bitcoin stop
And by creating soft link to this script at /etc/rc2.d directory bitcoin server is started after the Ubuntu 14.04 boot:
$ ln -s /etc/init.d/bitcoin S93bitcoin
--- Kosta