-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbitcoin-initd.sh
executable file
·51 lines (40 loc) · 1.32 KB
/
bitcoin-initd.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
#
# simple script to daemonize bitcoind
#
set -e
PIDPATH="/var/run/bitcoind"
BASEPATH="/home/user/bitcoin/src" # SET TO directory where script is found
DAEMON="${BASEPATH}/bitcoind"
DAEMON_OPTS="" # SET TO whatever arguments you need
CHUID="bitcoin:bitcoin" # SET TO user:group you want to run the process
NAME="bitcoind" # SET TO unique name if you copy/paste this script to run multiple instances of this script
PIDFILE="${PIDPATH}/${NAME}.pid"
DAEMON_OPTS="${DAEMON_OPTS}"
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
case "$1" in
start)
echo -n "Starting daemon: ${NAME}"
if [ ! -d ${PIDPATH} ];then
mkdir ${PIDPATH} && chmod 777 ${PIDPATH}
fi
start-stop-daemon --background --chuid $CHUID --start --quiet --exec $DAEMON -- $DAEMON_OPTS
echo "."
;;
stop)
echo -n "Stopping daemon: ${NAME}"
start-stop-daemon --stop --quiet --oknodo --retry=TERM/30/KILL/5 --pidfile $PIDFILE
echo "."
;;
restart)
echo -n "Restarting daemon: ${NAME}"
start-stop-daemon --stop --quiet --oknodo --retry=TERM/30/KILL/5 --pidfile $PIDFILE
start-stop-daemon --background --chuid $CHUID --start --quiet --exec $DAEMON -- $DAEMON_OPTS
echo "."
;;
*)
echo "Usage: ${1} {start|stop|restart}"
exit 1
;;
esac
exit 0