Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove xud.conf #722

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions images/utils/launcher/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,6 @@ def parse_command_line_arguments(self):
metavar="<ports>",
help="Expose xud service ports to your host machine"
)
group.add_argument(
"--xud.preserve-config",
action="store_true",
help="Preserve xud xud.conf file during updates"
)

group = parser.add_argument_group("arby")
group.add_argument(
Expand Down Expand Up @@ -656,7 +651,7 @@ def update_disabled(self, node, parsed, opt):

def update_arby(self, parsed):
"""Update arby related configurations from parsed TOML arby section
:param parsed: Parsed xud TOML section
:param parsed: Parsed arby TOML section
"""
node = self.nodes["arby"]
if "test-centralized-baseasset-balance" in parsed:
Expand Down Expand Up @@ -815,10 +810,6 @@ def parse_network_config(self):
except FileNotFoundError:
pass

if hasattr(self.args, "xud.preserve_config"):
if "xud" in self.nodes:
self.nodes["xud"]["preserve_config"] = True

if hasattr(self.args, "lndbtc.preserve_config"):
if "lndbtc" in self.nodes:
self.nodes["lndbtc"]["preserve_config"] = True
Expand Down
3 changes: 3 additions & 0 deletions images/utils/launcher/node/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,13 @@ def __init__(self, name: str, ctx):

def generate_environment(self):
environment = [f"NETWORK={self.network}"]

# TODO deprecate PRESERVE_CONFIG
if self.node_config["preserve_config"]:
environment.append("PRESERVE_CONFIG=true")
else:
environment.append("PRESERVE_CONFIG=false")

return environment

def generate_volumes(self):
Expand Down
4 changes: 2 additions & 2 deletions images/xud/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ RUN rm -rf seedutil/go
RUN strip seedutil/seedutil

FROM node:12-alpine3.11
RUN apk add --no-cache bash tor
RUN apk add --no-cache bash tor supervisor
COPY --from=builder /xud /app
COPY entrypoint.sh update-backup-dir.sh xud-backup.sh /
COPY entrypoint.sh update-backup-dir.sh xud-backup.sh supervisord.conf /
WORKDIR /app
RUN ln -s /app/bin/xud /usr/local/bin/xud
RUN ln -s /app/bin/xucli /usr/local/bin/xucli
Expand Down
4 changes: 2 additions & 2 deletions images/xud/Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ RUN rm -rf seedutil/go
RUN strip seedutil/seedutil

FROM node:12-alpine3.11
RUN apk add --no-cache bash tor
RUN apk add --no-cache bash tor supervisor
COPY --from=builder /xud /app
COPY entrypoint.sh update-backup-dir.sh xud-backup.sh /
COPY entrypoint.sh update-backup-dir.sh xud-backup.sh supervisord.conf /
WORKDIR /app
RUN ln -s /app/bin/xud /usr/local/bin/xud
RUN ln -s /app/bin/xucli /usr/local/bin/xucli
Expand Down
75 changes: 39 additions & 36 deletions images/xud/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ set -o nounset # -u
set -o pipefail
set -o monitor # -m

XUD_DIR=$HOME/.xud
XUD_CONF=$XUD_DIR/xud.conf
TOR_DIR=$XUD_DIR/tor
TOR_DATA_DIR=$XUD_DIR/tor-data
XUD_DIR="$HOME/.xud"
XUD_CONF="$XUD_DIR/xud.conf"
TOR_DIR="$XUD_DIR/tor"
TOR_LOG="$XUD_DIR/tor.log"
TOR_DATA_DIR="$XUD_DIR/tor-data"
LND_HOSTNAME="$TOR_DIR/hostname"


Expand Down Expand Up @@ -42,7 +43,7 @@ HiddenServicePort $P2P_PORT 127.0.0.1:$P2P_PORT
HiddenServiceVersion 3
EOF

tor -f /etc/tor/torrc &
tor -f /etc/tor/torrc >"$TOR_LOG" 2>&1 &

while [[ ! -e $LND_HOSTNAME ]]; do
echo "[entrypoint] Waiting for xud onion address"
Expand Down Expand Up @@ -76,37 +77,39 @@ while [[ ! -e /root/.lndltc/tls.cert ]]; do
sleep 1
done

# start xud-backup as daemon in background
supervisord -c /supervisord.conf &

[[ -e $XUD_CONF && $PRESERVE_CONFIG == "true" ]] || {
cp /app/sample-xud.conf $XUD_CONF

sed -i "s/network.*/network = \"$NETWORK\"/" $XUD_CONF
sed -i 's/noencrypt.*/noencrypt = false/' $XUD_CONF
sed -i '/\[http/,/^$/s/host.*/host = "0.0.0.0"/' $XUD_CONF
sed -i "/\[http/,/^$/s/port.*/port = $HTTP_PORT/" $XUD_CONF
sed -i '/\[lnd\.BTC/,/^$/s/host.*/host = "lndbtc"/' $XUD_CONF
sed -i "/\[lnd\.BTC/,/^$/s|^$|certpath = \"/root/.lndbtc/tls.cert\"\nmacaroonpath = \"/root/.lndbtc/data/chain/bitcoin/$NETWORK/admin.macaroon\"\n|" $XUD_CONF
sed -i '/\[lnd\.LTC/,/^$/s/host.*/host = "lndltc"/' $XUD_CONF
sed -i '/\[lnd\.LTC/,/^$/s/port.*/port = 10009/' $XUD_CONF
sed -i "/\[lnd\.LTC/,/^$/s|^$|certpath = \"/root/.lndltc/tls.cert\"\nmacaroonpath = \"/root/.lndltc/data/chain/litecoin/$NETWORK/admin.macaroon\"\n|" $XUD_CONF
sed -i "/\[p2p/,/^$/s/addresses.*/addresses = \[\"$XUD_ADDRESS\"]/" $XUD_CONF
sed -i "/\[p2p/,/^$/s/port.*/port = $P2P_PORT/" $XUD_CONF
sed -i '/\[p2p/,/^$/s/tor = .*/tor = true/' $XUD_CONF
sed -i '/\[p2p/,/^$/s/torport.*/torport = 9050/' $XUD_CONF
sed -i '/\[raiden/,/^$/s/disable.*/disable = true/' $XUD_CONF
sed -i '/\[rpc/,/^$/s/host.*/host = "0.0.0.0"/' $XUD_CONF
sed -i "/\[rpc/,/^$/s/port.*/port = $RPC_PORT/" $XUD_CONF
sed -i '/\[connext/,/^$/s/disable.*/disable = false/' $XUD_CONF
sed -i '/\[connext/,/^$/s/host.*/host = "connext"/' $XUD_CONF
sed -i '/\[connext/,/^$/s/port.*/port = 5040/' $XUD_CONF
sed -i '/\[connext/,/^$/s/webhookhost.*/webhookhost = "xud"/' $XUD_CONF
sed -i "/\[connext/,/^$/s/webhookport.*/webhookport = $HTTP_PORT/" $XUD_CONF
}

echo "[entrypoint] Launch with xud.conf:"
cat $XUD_CONF

/xud-backup.sh &
# for backward compatibility
if [[ -e $XUD_CONF ]]; then
mv "$XUD_CONF" "$XUD_DIR/previous-xud.$(date +%s).conf"
fi

# use exec to properly respond to SIGINT
exec xud $@
# shellcheck disable=2068
exec xud \
--network="$NETWORK" \
--noencrypt=false \
--http.host="0.0.0.0" \
--http.port="$HTTP_PORT" \
--lnd.BTC.host="lndbtc" \
--lnd.BTC.port=10009 \
--lnd.BTC.certpath="/root/.lndbtc/tls.cert" \
--lnd.BTC.macaroonpath="/root/.lndbtc/data/chain/bitcoin/$NETWORK/admin.macaroon" \
--lnd.LTC.host="lndltc" \
--lnd.LTC.port=10009 \
--lnd.LTC.certpath="/root/.lndltc/tls.cert" \
--lnd.LTC.macaroonpath="/root/.lndltc/data/chain/litecoin/$NETWORK/admin.macaroon" \
--p2p.address="$XUD_ADDRESS" \
--p2p.port="$P2P_PORT" \
--p2p.tor=true \
--p2p.torport=9050 \
--raiden.disable=true \
--rpc.host="0.0.0.0" \
--rpc.port="$RPC_PORT" \
--connext.disable=false \
--connext.host="connext" \
--connext.port=5040 \
--connext.webhookhost="xud" \
--connext.webhookport="$HTTP_PORT" \
$@
13 changes: 13 additions & 0 deletions images/xud/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[supervisord]
nodaemon=true
logfile=/supervisord.log
childlogdir=/app
user=root

[program:xud-backup]
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stdout
command=/xud-backup.sh
stopsignal=SIGINT
autorestart=true
10 changes: 9 additions & 1 deletion images/xud/xud-backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,12 @@ while ! check_backup_dir "$BACKUP_DIR"; do
sleep 5
done

./bin/xud-backup -b "$BACKUP_DIR"
./bin/xud-backup -b "$BACKUP_DIR" \
--lnd.BTC.host="lndbtc" \
--lnd.BTC.port=10009 \
--lnd.BTC.certpath="/root/.lndbtc/tls.cert" \
--lnd.BTC.macaroonpath="/root/.lndbtc/data/chain/bitcoin/$NETWORK/admin.macaroon" \
--lnd.LTC.host="lndltc" \
--lnd.LTC.port=10009 \
--lnd.LTC.certpath="/root/.lndltc/tls.cert" \
--lnd.LTC.macaroonpath="/root/.lndltc/data/chain/litecoin/$NETWORK/admin.macaroon"
1 change: 0 additions & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ Connext options:
Xud options:
--xud.expose-ports <port>[,<port>] Expose xud service ports to your host machine
--xud.preserve-config Preserve xud xud.conf file during updates
Arby options:
--arby.live-cex [true|false] Production/Demo mode (default: false)
Expand Down