forked from itzg/docker-minecraft-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start
46 lines (38 loc) · 962 Bytes
/
start
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
40
41
42
43
44
45
46
#!/bin/bash
. /start-utils
umask 0002
chmod g+w /data
if [ $(id -u) = 0 ]; then
runAsUser=minecraft
runAsGroup=minecraft
if [[ -v UID ]]; then
if [[ $UID != 0 ]]; then
if [[ $UID != $(id -u minecraft) ]]; then
log "Changing uid of minecraft to $UID"
usermod -u $UID minecraft
fi
else
runAsUser=root
fi
fi
if [[ -v GID ]]; then
if [[ $GID != 0 ]]; then
if [[ $GID != $(id -g minecraft) ]]; then
log "Changing gid of minecraft to $GID"
groupmod -o -g $GID minecraft
fi
else
runAsGroup=root
fi
fi
if [[ $(stat -c "%u" /data) != $UID ]]; then
log "Changing ownership of /data to $UID ..."
chown -R ${runAsUser}:${runAsGroup} /data
fi
if [[ ${SKIP_NSSWITCH_CONF^^} != TRUE ]]; then
echo 'hosts: files dns' > /etc/nsswitch.conf
fi
exec su-exec ${runAsUser}:${runAsGroup} /start-configuration $@
else
exec /start-configuration $@
fi