2018-04-26 01:57:57 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-06-19 16:05:32 +00:00
|
|
|
. ${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
|
|
|
|
|
2021-04-02 23:23:05 +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"
|
2020-01-17 14:27:11 +00:00
|
|
|
groupmod -o -g $GID minecraft
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
runAsGroup=root
|
|
|
|
fi
|
2018-07-31 02:49:43 +00:00
|
|
|
fi
|
2018-08-18 21:56:45 +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
|
|
|
|
|
2020-06-19 20:01:28 +00:00
|
|
|
exec gosu ${runAsUser}:${runAsGroup} ${SCRIPTS:-/}start-configuration $@
|
2018-07-31 02:49:43 +00:00
|
|
|
else
|
2020-06-19 16:05:32 +00:00
|
|
|
exec ${SCRIPTS:-/}start-configuration $@
|
2018-04-26 01:57:57 +00:00
|
|
|
fi
|