#! /bin/sh # # entrypoint.sh # Copyright (C) 2024 barry # # Distributed under terms of the MIT license. # #!/bin/sh set -e # give bitcoind a second to bootup sleep 1 # containers on linux share file permissions with hosts. # assigning the same uid/gid from the host user # ensures that the files can be read/write from both sides if ! id clightning > /dev/null 2>&1; then USERID=${USERID:-1000} GROUPID=${GROUPID:-1000} echo "adding user clightning ($USERID:$GROUPID)" groupadd -f -g $GROUPID clightning useradd -r -u $USERID -g $GROUPID clightning # ensure correct ownership of user home dir mkdir -p /home/clightning chown -R $USERID:$GROUPID /home/clightning fi # Test if hsm_secret exist, if not create with random mnemonic if [ -s /root/.lightning/bitcoin/hsm_secret ]; then echo "hsm_secret exist, exiting..." else seed=$(python3 -c "from mnemonic import Mnemonic;m=Mnemonic('english');print(m.generate(128))") echo "Seed Phrase: $seed" > /root/.lightning/bitcoin/seed_phrase.txt expect /root/.lightning/script.exp "$seed" fi if [ $(echo "$1" | cut -c1) = "-" ]; then echo "$0: assuming arguments for lightningd" set -- lightningd "$@" fi echo "$@" exec "$@"