2018-04-26 01:57:57 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-02-12 03:00:24 +00:00
|
|
|
# shellcheck source=start-utils
|
|
|
|
. "${SCRIPTS:-/}start-utils"
|
2020-03-06 15:52:17 +00:00
|
|
|
|
2018-09-27 07:27:50 +00:00
|
|
|
umask 0002
|
|
|
|
chmod g+w /data
|
|
|
|
|
2022-02-12 03:00:24 +00:00
|
|
|
if ! isTrue "${SKIP_SUDO:-false}" && [ "$(id -u)" = 0 ]; then
|
2020-01-17 14:27:11 +00:00
|
|
|
runAsUser=minecraft
|
|
|
|
runAsGroup=minecraft
|
|
|
|
|
|
|
|
if [[ -v UID ]]; then
|
|
|
|
if [[ $UID != 0 ]]; then
|
|
|
|
if [[ $UID != $(id -u minecraft) ]]; then
|
2020-03-06 15:52:17 +00:00
|
|
|
log "Changing uid of minecraft to $UID"
|
2020-01-17 14:27:11 +00:00
|
|
|
usermod -u $UID minecraft
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
runAsUser=root
|
|
|
|
fi
|
2018-04-26 01:57:57 +00:00
|
|
|
fi
|
2020-01-17 14:27:11 +00:00
|
|
|
|
2018-07-31 02:49:43 +00:00
|
|
|
if [[ -v GID ]]; then
|
2020-01-17 14:27:11 +00:00
|
|
|
if [[ $GID != 0 ]]; then
|
|
|
|
if [[ $GID != $(id -g minecraft) ]]; then
|
2020-03-06 15:52:17 +00:00
|
|
|
log "Changing gid of minecraft to $GID"
|
2022-02-12 03:00:24 +00:00
|
|
|
groupmod -o -g "$GID" minecraft
|
2020-01-17 14:27:11 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
runAsGroup=root
|
|
|
|
fi
|
2018-07-31 02:49:43 +00:00
|
|
|
fi
|
2018-08-18 21:56:45 +00:00
|
|
|
|
2022-02-12 03:00:24 +00:00
|
|
|
if [[ $(stat -c "%u" /data) != "$UID" ]]; then
|
2020-03-06 15:52:17 +00:00
|
|
|
log "Changing ownership of /data to $UID ..."
|
2020-01-17 14:27:11 +00:00
|
|
|
chown -R ${runAsUser}:${runAsGroup} /data
|
2018-08-18 21:56:45 +00:00
|
|
|
fi
|
|
|
|
|
2019-11-27 03:34:56 +00:00
|
|
|
if [[ ${SKIP_NSSWITCH_CONF^^} != TRUE ]]; then
|
|
|
|
echo 'hosts: files dns' > /etc/nsswitch.conf
|
|
|
|
fi
|
|
|
|
|
2022-02-12 03:00:24 +00:00
|
|
|
distro=$(getDistro)
|
|
|
|
if [[ $distro == alpine ]]; then
|
|
|
|
exec su-exec ${runAsUser}:${runAsGroup} "${SCRIPTS:-/}start-configuration" "$@"
|
|
|
|
else
|
|
|
|
exec gosu ${runAsUser}:${runAsGroup} "${SCRIPTS:-/}start-configuration" "$@"
|
|
|
|
fi
|
2018-07-31 02:49:43 +00:00
|
|
|
else
|
2022-02-12 03:00:24 +00:00
|
|
|
exec "${SCRIPTS:-/}start-configuration" "$@"
|
2018-04-26 01:57:57 +00:00
|
|
|
fi
|