-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstart
executable file
·139 lines (117 loc) · 4.11 KB
/
start
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
# Check for verbose
if [ "$1" == "-v" ]; then
VERBOSE=true
shift 1
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
HELP="Start services or run a command with overrides enabled.
Example: \`./start logs -f bitcoin\`
Commands:
restart, up, logs, ps, stop, exec, kill, rm, run, config - Docker Compose commands
Example: ./start logs -f bitcoin
jm - Shortcut command to scripts/joinmarket.bash
For nested segwit wallets
Example: ./start jm display
jm-bech32 - Shortcut command to scripts/joinmarket-bech32.bash
For native segwit wallets
Example: ./start jm-bech32 display
lnd - Shortcut command to scripts/lnd.bash
Example: ./start lnd unlock
macaroons - Shortcut command to scripts/macaroons.bash
DEPRECATED: Use \`./start lnd macaroons\`
onions - Shortcut command to scripts/onions.bash
help - Displays this message.
The default command (no parameters) is \`up -d\`"
# Make data directory if it doesn't exist already
mkdir -p "$DIR/.data"
# shellcheck source=scripts/create_env.bash
. "$DIR/scripts/create_env.bash"
# try to detect and warn user of duplicate variables
. "$DIR/scripts/detect_duplicate_vars.bash"
# try to detect and warn user of old volume mounts
. "$DIR/scripts/detect_old_data.bash"
# Start LND, Bitcoin and Tor with added overrides
CMD=""
case "$1" in
"restart" | "up" | "logs" | "ps" | "stop" | "exec" | "kill" | "rm" | "run" | "config" )
CMD=("$@")
;;
"docker-compose")
CMD=("${@:2}")
;;
"jm")
scripts/joinmarket.bash "${@:2}"
exit "$?"
;;
"jm-bech32")
DAEMON_SERVICE=joinmarketd-bech32 scripts/joinmarket.bash "${@:2}"
exit "$?"
;;
"onions")
scripts/onions.bash "${@:2}"
exit "$?"
;;
"lnd" )
scripts/lnd.bash "${@:2}"
exit "$?"
;;
"macaroons")
scripts/macaroons.bash "${@:2}"
exit "$?"
;;
"bos" )
scripts/bos.bash "${@:2}"
exit "$?"
;;
"")
CMD=(up -d)
;;
"help" | "--help" | "-h")
echo "$HELP"
exit 0
;;
* )
echo "Command '${*:1}' not recognized."
echo "$HELP"
exit 1
;;
esac
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# Get list of overrides
OVERRIDE_OPTIONS=()
shopt -s nullglob
for f in "$DIR/overrides"/*.yml
do
OVERRIDE_OPTIONS+=(-f)
OVERRIDE_OPTIONS+=("$f")
done
# Setup Docker Compose command
# Pass in 1 for sudo
set_compose_command() {
if docker compose &>/dev/null; then
if [ "$1" == 1 ]; then
DOCKER_COMPOSE_CMD=(sudo docker compose)
else
DOCKER_COMPOSE_CMD=(docker compose)
fi
elif docker-compose &>/dev/null; then
if [ "$1" == 1 ]; then
DOCKER_COMPOSE_CMD=(sudo docker-compose)
else
DOCKER_COMPOSE_CMD=(docker-compose)
fi
else
echo "Please make sure Docker Compose is installed"
fi
}
if docker info &>/dev/null; then
set_compose_command
else
set_compose_command 1
fi
# Start docker-compose with override options
if [ "$VERBOSE" ]; then
echo "${DOCKER_COMPOSE_CMD[@]}" -f docker-compose.yml "${OVERRIDE_OPTIONS[@]}" "${CMD[@]}"
fi
cd "$DIR" && exec "${DOCKER_COMPOSE_CMD[@]}" -f docker-compose.yml "${OVERRIDE_OPTIONS[@]}" "${CMD[@]}"