-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstop.sh
149 lines (138 loc) · 6.25 KB
/
stop.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
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
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/env bash
# Console colors for better legibility.
COFF="\033[0m"
CINFO="\033[01;34m"
CSUCCESS="\033[0;32m"
CWARN="\033[0;33m"
CERROR="\033[0;31m"
# Toggle option to prune docker system. Helpful to clean up old and unused images, networks, etc.
STACK_DOCKER_PRUNE="False"
# Allocated container IP. Copy from the start.sh script if changed.
STACK_NETWORK_SUBNET="10.21.0.0/16"
STACK_TOR_IP="10.21.22.1"
STACK_I2PD_IP="10.21.22.2"
STACK_BITCOIND_IP="10.21.22.3"
STACK_BITCOIN_GUI_IP="10.21.22.4"
STACK_ELECTRS_IP="10.21.22.5"
STACK_ELECTRS_GUI_IP="10.21.22.6"
STACK_MEMPOOL_IP="10.21.22.7"
STACK_LIGHTNING_NODE_IP="10.21.22.8"
STACK_LIGHTNING_GUI_IP="10.21.22.9"
STACK_MEMPOOL_API_IP="10.21.22.20"
STACK_MEMPOOL_DB_IP="10.21.22.21"
STACK_EXTRAS_ORDINALS_IP="10.21.22.30"
STACK_EXTRAS_ADGUARD_IP="10.21.22.31"
STACK_EXTRAS_NOSTR_WALLET_CONNECT_IP="10.21.22.32"
STACK_EXTRAS_BACK_THAT_MAC_IP="10.21.22.33"
STACK_EXTRAS_TIMEMACHINE_IP="10.21.22.34"
STACK_EXTRAS_LLAMA_GPT_API_IP="10.21.22.35"
STACK_EXTRAS_LLAMA_GPT_UI_IP="10.21.22.36"
STACK_EXTRAS_LIGHTNING_TERMINAL_IP="10.21.22.37"
STACK_EXTRAS_MYSPEED_IP="10.21.22.38"
# Allocated container port. Copy from the start.sh script if changed.
STACK_TOR_SOCKS_PORT="9052"
STACK_TOR_CONTROL_PORT="9053"
STACK_I2PD_PORT="7656"
STACK_BITCOIND_RPC_PORT="8332"
STACK_BITCOIND_P2P_PORT="8333"
STACK_BITCOIND_TOR_PORT="8334"
STACK_BITCOIND_PUB_RAW_BLOCK_PORT="28332"
STACK_BITCOIND_PUB_RAW_TX_PORT="28333"
STACK_ELECTRS_PORT="50001"
STACK_LIGHTNING_NODE_PORT="9735"
STACK_LIGHTNING_NODE_REST_PORT="8080"
STACK_LIGHTNING_NODE_GRPC_PORT="10009"
STACK_BITCOIN_GUI_PORT="3005"
STACK_ELECTRS_GUI_PORT="3006"
STACK_MEMPOOL_PORT="3007"
STACK_LIGHTNING_GUI_PORT="3008"
STACK_MEMPOOL_API_PORT="3010"
STACK_EXTRAS_ORDINALS_PORT="3030"
STACK_EXTRAS_ADGUARD_PORT="3031"
STACK_EXTRAS_NOSTR_WALLET_CONNECT_PORT="3032"
STACK_EXTRAS_BACK_THAT_MAC_PORT="3033"
STACK_EXTRAS_LLAMA_GPT_UI_PORT="3034"
STACK_EXTRAS_LIGHTNING_TERMINAL_PORT="3035"
STACK_EXTRAS_MYSPEED_PORT="3036"
# Script error handling.
handle_exit_code() {
ERROR_CODE="$?"
if [[ ${ERROR_CODE} != "0" ]]; then
echo -e " > ${CERROR}An error occurred. Exiting with code ${ERROR_CODE}.${COFF}"
exit ${ERROR_CODE}
else
echo -e " > ${CSUCCESS}Script execution completed!${COFF}"
exit ${ERROR_CODE}
fi
}
trap "handle_exit_code" EXIT
# Breakdown of arguments available for use.
if [[ ${#@} -ne 0 ]] && [[ "${@#"--help"}" = "" ]]; then
echo -e " > ${CINFO}You can run one of the following arguments at a time:${COFF}"
echo -e " ${CINFO}script.sh --prune (Remove unused docker images and data)${COFF}"
exit 0
fi
# Enable lightning node through terminal argument.
if [[ ${#@} -ne 0 ]] && [[ "${@#"--prune"}" = "" ]]; then
echo -e " > ${CSUCCESS}Enabled docker pruning!${COFF}"
STACK_DOCKER_PRUNE="True"
fi
# Variables exported to the docker compose files. Leave as is.
export APP_NETWORK_SUBNET="${STACK_NETWORK_SUBNET}"
export APP_TOR_IP="${STACK_TOR_IP}"
export APP_I2PD_IP="${STACK_I2PD_IP}"
export APP_BITCOIND_IP="${STACK_BITCOIND_IP}"
export APP_BITCOIN_GUI_IP="${STACK_BITCOIN_GUI_IP}"
export APP_ELECTRS_IP="${STACK_ELECTRS_IP}"
export APP_ELECTRS_GUI_IP="${STACK_ELECTRS_GUI_IP}"
export APP_MEMPOOL_IP="${STACK_MEMPOOL_IP}"
export APP_LIGHTNING_NODE_IP="${STACK_LIGHTNING_NODE_IP}"
export APP_LIGHTNING_GUI_IP="${STACK_LIGHTNING_GUI_IP}"
export APP_TOR_SOCKS_PORT="${STACK_TOR_SOCKS_PORT}"
export APP_TOR_CONTROL_PORT="${STACK_TOR_CONTROL_PORT}"
export APP_I2PD_PORT="${STACK_I2PD_PORT}"
export APP_BITCOIND_RPC_PORT="${STACK_BITCOIND_RPC_PORT}"
export APP_BITCOIND_P2P_PORT="${STACK_BITCOIND_P2P_PORT}"
export APP_BITCOIND_PUB_RAW_BLOCK_PORT="${STACK_BITCOIND_PUB_RAW_BLOCK_PORT}"
export APP_BITCOIND_PUB_RAW_TX_PORT="${STACK_BITCOIND_PUB_RAW_TX_PORT}"
export APP_BITCOIN_GUI_PORT="${STACK_BITCOIN_GUI_PORT}"
export APP_ELECTRS_PORT="${STACK_ELECTRS_PORT}"
export APP_ELECTRS_GUI_PORT="${STACK_ELECTRS_GUI_PORT}"
export APP_MEMPOOL_PORT="${STACK_MEMPOOL_PORT}"
export APP_LIGHTNING_NODE_REST_PORT="${STACK_LIGHTNING_NODE_REST_PORT}"
export APP_LIGHTNING_NODE_PORT="${STACK_LIGHTNING_NODE_PORT}"
export APP_LIGHTNING_NODE_GRPC_PORT="${STACK_LIGHTNING_NODE_GRPC_PORT}"
export APP_LIGHTNING_GUI_PORT="${STACK_LIGHTNING_GUI_PORT}"
export APP_MEMPOOL_API_IP="${STACK_MEMPOOL_API_IP}"
export APP_MEMPOOL_API_PORT="${STACK_MEMPOOL_API_PORT}"
export APP_MEMPOOL_DB_IP="${STACK_MEMPOOL_DB_IP}"
export APP_EXTRAS_ORDINALS_IP="${STACK_EXTRAS_ORDINALS_IP}"
export APP_EXTRAS_ORDINALS_PORT="${STACK_EXTRAS_ORDINALS_PORT}"
export APP_EXTRAS_ADGUARD_IP="${STACK_EXTRAS_ADGUARD_IP}"
export APP_EXTRAS_ADGUARD_PORT="${STACK_EXTRAS_ADGUARD_PORT}"
export APP_EXTRAS_NOSTR_WALLET_CONNECT_IP="${STACK_EXTRAS_NOSTR_WALLET_CONNECT_IP}"
export APP_EXTRAS_NOSTR_WALLET_CONNECT_PORT="${STACK_EXTRAS_NOSTR_WALLET_CONNECT_PORT}"
export APP_EXTRAS_BACK_THAT_MAC_IP="${STACK_EXTRAS_BACK_THAT_MAC_IP}"
export APP_EXTRAS_BACK_THAT_MAC_PORT="${STACK_EXTRAS_BACK_THAT_MAC_PORT}"
export APP_EXTRAS_TIMEMACHINE_IP="${STACK_EXTRAS_TIMEMACHINE_IP}"
export APP_TIMEMACHINE_USERNAME="${STACK_TIMEMACHINE_USERNAME}"
export APP_TIMEMACHINE_PASSWORD="${STACK_TIMEMACHINE_PASSWORD}"
export APP_TIMEMACHINE_GROUPNAME="${STACK_TIMEMACHINE_GROUPNAME}"
export APP_EXTRAS_LLAMA_GPT_API_IP="${STACK_EXTRAS_LLAMA_GPT_API_IP}"
export APP_OPENAI_API_KEY="${STACK_OPENAI_API_KEY}"
export APP_EXTRAS_LLAMA_GPT_UI_IP="${STACK_EXTRAS_LLAMA_GPT_UI_IP}"
export APP_EXTRAS_LLAMA_GPT_UI_PORT="${STACK_EXTRAS_LLAMA_GPT_UI_PORT}"
export APP_LIGHTNING_TERMINAL_PASSWORD="${STACK_LIGHTNING_TERMINAL_PASSWORD}"
export APP_EXTRAS_LIGHTNING_TERMINAL_IP="${STACK_EXTRAS_LIGHTNING_TERMINAL_IP}"
export APP_EXTRAS_LIGHTNING_TERMINAL_PORT="${STACK_EXTRAS_LIGHTNING_TERMINAL_PORT}"
export APP_EXTRAS_MYSPEED_IP="${STACK_EXTRAS_MYSPEED_IP}"
export APP_EXTRAS_MYSPEED_PORT="${STACK_EXTRAS_MYSPEED_PORT}"
echo -e " > ${CINFO}Stopping docker container stack...${COFF}"
docker-compose --log-level ERROR -p crypto --file ./compose/docker-tor.yml --file ./compose/docker-bitcoin.yml --file ./compose/docker-electrs.yml --file ./compose/docker-lightning.yml --file ./compose/docker-extras.yml down
if [[ ${STACK_DOCKER_PRUNE} == "True" ]]; then
echo -e " > ${CINFO}Commencing docker system prune...${COFF}"
docker system prune -f
echo -e " > ${CSUCCESS}Docker system prune completed!${COFF}"
else
echo -e " > ${CWARN}Docker system prune skipped!${COFF}"
fi