forked from uxuydev/lntap
-
Notifications
You must be signed in to change notification settings - Fork 2
/
start-tapd.sh
59 lines (53 loc) · 1.36 KB
/
start-tapd.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
52
53
54
55
56
57
58
59
#!/bin/bash
SERVICE_NAME="tapd-service"
SERVICE_PATH="tapd --network=mainnet \
--debuglevel=debug \
--lnd.host=localhost:10009 \
--lnd.macaroonpath=/root/.lnd/data/chain/bitcoin/mainnet/admin.macaroon \
--lnd.tlspath=/root/.lnd/tls.cert \
--tapddir=/root/.taproot-assets \
--rpclisten=127.0.0.1:10029 \
--restlisten=127.0.0.1:8089"
PID_FILE="/root/$SERVICE_NAME.pid"
LOG_FILE="/root/$SERVICE_NAME.log"
start_service() {
if [ -f "$PID_FILE" ]; then
echo "$SERVICE_NAME is already running."
else
echo "Starting $SERVICE_NAME..."
$SERVICE_PATH >> "$LOG_FILE" 2>&1 &
echo $! > "$PID_FILE"
echo "$SERVICE_NAME is now running with PID $!"
fi
}
stop_service() {
if [ -f "$PID_FILE" ]; then
echo "Stopping $SERVICE_NAME..."
PID=$(cat "$PID_FILE")
kill "$PID"
rm "$PID_FILE"
echo "$SERVICE_NAME has been stopped."
else
echo "$SERVICE_NAME is not running."
fi
}
restart_service() {
stop_service
start_service
}
case "$1" in
start)
start_service
;;
stop)
stop_service
;;
restart)
restart_service
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0