-
Notifications
You must be signed in to change notification settings - Fork 430
Expand file tree
/
Copy pathswitch-node.sh
More file actions
executable file
·83 lines (66 loc) · 1.87 KB
/
switch-node.sh
File metadata and controls
executable file
·83 lines (66 loc) · 1.87 KB
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
#!/bin/bash
set -e
usage() {
cat <<-END
Usage: switch-node.sh default|bitcoincore|bitcoinknots
The default Bitcoin node implementation is selected by the BTCPay Server team.
This is currently Bitcoin Core 29.x and is planned to move to Bitcoin Core 31.0 later.
Use bitcoincore or bitcoinknots to explicitly pin your deployment to one of those implementations.
END
}
node="$1"
case "$node" in
default|bitcoincore|bitcoinknots)
;;
*)
usage
exit 1
;;
esac
if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OS
BASH_PROFILE_SCRIPT="$HOME/btcpay-env.sh"
else
# Linux
BASH_PROFILE_SCRIPT="/etc/profile.d/btcpay-env.sh"
fi
remove_fragments() {
local value="$1"
local result=""
local fragment
value="${value//,/;}"
IFS=';' read -ra fragments <<< "$value"
for fragment in "${fragments[@]}"; do
fragment="${fragment//[[:space:]]/}"
case "$fragment" in
""|bitcoin|bitcoincore|bitcoinknots)
continue
;;
esac
if [ -z "$result" ]; then
result="$fragment"
else
result="$result;$fragment"
fi
done
echo "$result"
}
append_fragment() {
local value="$1"
local fragment="$2"
if [ -z "$value" ]; then
echo "$fragment"
else
echo "$value;$fragment"
fi
}
BTCPAYGEN_ADDITIONAL_FRAGMENTS="$(remove_fragments "$BTCPAYGEN_ADDITIONAL_FRAGMENTS")"
BTCPAYGEN_EXCLUDE_FRAGMENTS="$(remove_fragments "$BTCPAYGEN_EXCLUDE_FRAGMENTS")"
if [ "$node" != "default" ]; then
BTCPAYGEN_EXCLUDE_FRAGMENTS="$(append_fragment "$BTCPAYGEN_EXCLUDE_FRAGMENTS" "bitcoin")"
BTCPAYGEN_ADDITIONAL_FRAGMENTS="$(append_fragment "$BTCPAYGEN_ADDITIONAL_FRAGMENTS" "$node")"
fi
export BTCPAYGEN_ADDITIONAL_FRAGMENTS
export BTCPAYGEN_EXCLUDE_FRAGMENTS
echo "Switching Bitcoin node implementation to $node"
. btcpay-setup.sh -i