forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 2
/
entrypoint.sh
39 lines (29 loc) · 976 Bytes
/
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
38
39
#!/bin/bash
set -e
if [ -n "${UID+x}" ] && [ "${UID}" != "0" ]; then
usermod -u "$UID" drivechain
fi
if [ -n "${GID+x}" ] && [ "${GID}" != "0" ]; then
groupmod -g "$GID" drivechain
fi
echo "$0: assuming uid:gid for drivechain:drivechain of $(id -u drivechain):$(id -g drivechain)"
if [ "$(echo "$1" | cut -c1)" = "-" ]; then
echo "$0: assuming arguments for drivechaind"
set -- drivechaind "$@"
fi
if [ "$(echo "$1" | cut -c1)" = "-" ] || [ "$1" = "drivechaind" ]; then
mkdir -p "$DRIVECHAIN_DATA"
chmod 700 "$DRIVECHAIN_DATA"
# Fix permissions for home dir.
chown -R drivechain:drivechain "$(getent passwd drivechain | cut -d: -f6)"
# Fix permissions for drivechain data dir.
chown -R drivechain:drivechain "$DRIVECHAIN_DATA"
echo "$0: setting data directory to $DRIVECHAIN_DATA"
set -- "$@" -datadir="$DRIVECHAIN_DATA"
fi
if [ "$1" = "drivechaind" ] || [ "$1" = "drivechain-cli" ]; then
echo
exec gosu drivechain "$@"
fi
echo
exec "$@"