-
Notifications
You must be signed in to change notification settings - Fork 0
/
btc-server
44 lines (38 loc) · 1.38 KB
/
btc-server
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
#!/bin/sh
### BEGIN INIT INFO
# Provides: btc-service.sh
# Required-Start: $local_fs $syslog $remote_fs
# Required-Stop: $local_fs $syslog $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start bitcoin daemon
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/home/limyg612/coin-projects/bitcoin/src/
NAME=btc-service
DESC=btc-service
BTCSERVER=/home/limyg612/coin-projects/bitcoin/src/bitcoind
BTCCLIENT=/home/limyg612/coin-projects/bitcoin/src/bitcoin-cli
BTCSERVER_PID=$(ps auxf | grep bitcoind | grep -v grep | awk '{print $2}')
BTCDIR="/data/.bitcoin"
case "$1" in
start)
if [ -z "${BTCSERVER_PID}" ]; then
echo "starting bitcoin server"
${BTCSERVER} -datadir=${BTCDIR} -conf=${BTCDIR}/bitcoin.conf
echo "bitcoin server started"
else
echo ${BTCDIR}
echo "bitcoin server is running"
fi
;;
stop)
if [ -n "${BTCSERVER_PID}" ]; then
${BTCCLIENT} -datadir=${BTCDIR} -conf=${BTCDIR}/bitcoin.conf stop
echo "bitcoin server stopped"
else
echo "bitcoin server is not running"
fi
;;
esac
exit 0