From aa1a0e31fd902b6b04fc713ce8faa5a1beceee31 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 17 Mar 2023 11:03:37 +1030 Subject: [PATCH] Docker: run directory for post-start if present. Also, fix the case where we didn't use --network with EXPOSE_TCP, as reported by @theborakompanioni: ``` I get Wrong network! Our Bitcoin backend is running on 'regtest', but we expect 'main'. with LIGHTNINGD_NETWORK := regtest when param --network is not provided. ``` Signed-off-by: Rusty Russell --- tools/docker-entrypoint.sh | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tools/docker-entrypoint.sh b/tools/docker-entrypoint.sh index bb06db53a..8d7bbfd2d 100755 --- a/tools/docker-entrypoint.sh +++ b/tools/docker-entrypoint.sh @@ -4,18 +4,24 @@ networkdatadir="${LIGHTNINGD_DATA}/${LIGHTNINGD_NETWORK}" -if [ "$EXPOSE_TCP" == "true" ]; then - set -m - lightningd "$@" & +set -m +lightningd --network="${LIGHTNINGD_NETWORK}" "$@" & - echo "Core-Lightning starting" - while read -r i; do if [ "$i" = "lightning-rpc" ]; then break; fi; done \ +echo "Core-Lightning starting" +while read -r i; do if [ "$i" = "lightning-rpc" ]; then break; fi; done \ < <(inotifywait -e create,open --format '%f' --quiet "${networkdatadir}" --monitor) - echo "Core-Lightning started" + +if [ "$EXPOSE_TCP" == "true" ]; then echo "Core-Lightning started, RPC available on port $LIGHTNINGD_RPC_PORT" socat "TCP4-listen:$LIGHTNINGD_RPC_PORT,fork,reuseaddr" "UNIX-CONNECT:${networkdatadir}/lightning-rpc" & - fg %- -else - exec lightningd --network="${LIGHTNINGD_NETWORK}" "$@" fi + +# Now run any scripts which exist in the lightning-poststart.d directory +if [ -d "$LIGHTNINGD_DATA"/lightning-poststart.d ]; then + for f in "$LIGHTNINGD_DATA"/lightning-poststart.d/*; do + "$f" + done +fi + +fg %-