-
Notifications
You must be signed in to change notification settings - Fork 146
/
docker-entrypoint.sh
37 lines (29 loc) · 964 Bytes
/
docker-entrypoint.sh
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
#!/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
# TODO: investigate hsmd error on Windows
# https://gist.github.com/jamaljsr/404c20f99be2f77fff2d834e2449158b
if [ "$1" = "lightningd" ] || [ "$1" = "lightning-cli" ]; then
echo "Running as clightning user: $@"
exec gosu clightning "$@"
fi
echo "$@"
exec "$@"