`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
Post a Comment