-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbartender.sh
executable file
·83 lines (67 loc) · 1.69 KB
/
bartender.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
# Modified from: https://github.com/puzzle/lightning-beer-tap/blob/master/application.sh
DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
usage(){
cat << EOF
Usage: $0 [OPTIONS]
This script handles all interactions with the Bitcoin Bay Bartender.
OPTIONS:
start Initializes the device, starts the dashboard and bartender
stop Stops all services
build Build or rebuild the web socket to the lightning node 🦀
EXAMPLES:
application restart
EOF
}
# Start all services on the beer tap device
app_start(){
echo 🎵 hey, bartender 🎵
rm -f ${DIR}/log.txt
BARTENDER=${DIR}/target/debug/bartender
# Check if the websocket bridge has been built
if [ ! -f ${BARTENDER} ]; then
app_build
fi
# Start up the dashboard
source ${DIR}/dashboard.sh
# Start websocket server, fork to background and pipe output to file
export RUST_LOG=info
nohup ${BARTENDER} --serve > log.txt 2>&1 &
# cargo run
}
# Stop all services
app_stop(){
echo "Killing all services..."
killall bartender
pkill -o chromium
killall unclutter
}
# Build or rebuild the java lighning node web bridge
app_build(){
echo "Building the bartender web socket server 🦀"
cd ${DIR} && cargo build # >/dev/null 2>&1
}
# Argument parsing
case $1 in
start)
app_start
exit 0;
;;
stop)
app_stop
exit 0;
;;
build)
app_build
exit 0;
;;
restart)
app_stop
app_start
exit 0;
;;
*)
usage
exit 0;
;;
esac