bitb0x/roles/apps/files/clightning/entrypoint.sh
2024-02-13 12:27:33 -06:00

39 lines
843 B
Bash

#! /bin/sh
#
# entrypoint.sh
# Copyright (C) 2024 barry <barry@a9.local>
#
# 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
if [ $(echo "$1" | cut -c1) = "-" ]; then
echo "$0: assuming arguments for lightningd"
set -- lightningd "$@"
fi
echo "$@"
exec "$@"