minecraft-pi-reborn/launcher/src/run.sh

35 lines
761 B
Bash
Raw Normal View History

2021-02-09 03:52:39 +00:00
#!/bin/sh
set -e
# Check Root
if [ ! "$(id -u)" = '0' ]; then
echo 'Must Run As Root' 1>&2
exit 1
fi
2021-02-11 01:03:19 +00:00
# Check
if ! id user > /dev/null 2>&1; then
# Create User Groups
if [ -z "${USER_GID+x}" ]; then
USER_GID='1000'
fi
groupadd --force --gid "${USER_GID}" user
2021-02-09 03:52:39 +00:00
2021-02-11 01:03:19 +00:00
# Create User
if [ -z "${USER_UID+x}" ]; then
USER_UID='1000'
fi
useradd --shell /bin/sh --home-dir /home --no-create-home --uid "${USER_UID}" --gid "${USER_GID}" user
2021-02-09 03:52:39 +00:00
2021-02-11 01:03:19 +00:00
# Add Other Groups
if [ ! -z "${USER_OTHER_GIDS+x}" ]; then
for gid in ${USER_OTHER_GIDS}; do
groupadd --force --gid "${gid}" "group-${gid}"
usermod -aG "${gid}" user
done
fi
2021-02-09 03:52:39 +00:00
fi
# Start
exec gosu "${USER_UID}" ./launcher