2020-09-25 23:37:22 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2020-12-08 21:32:12 +00:00
|
|
|
# All Feature Flags
|
2021-01-28 22:04:54 +00:00
|
|
|
export AVAILABLE_FEATURES="$(tr '\n' ' ' < /usr/share/minecraft-pi/client/features)"
|
2020-12-08 21:32:12 +00:00
|
|
|
|
|
|
|
# Print Feature Flags Option
|
|
|
|
if [ "$1" = "--print-features" ]; then
|
|
|
|
echo "${AVAILABLE_FEATURES}"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2021-03-07 18:56:27 +00:00
|
|
|
# Esnure User Is In docker Group
|
|
|
|
if ! id -nGz | grep -qzxF 'docker'; then
|
|
|
|
pkexec /usr/sbin/usermod -aG docker "$(id -un)"
|
|
|
|
fi
|
|
|
|
|
2020-12-10 22:16:44 +00:00
|
|
|
# Export Important Variables
|
|
|
|
export ZENITY_CLASS='Minecraft - Pi edition'
|
2021-01-31 02:32:20 +00:00
|
|
|
export DOCKER_COMPOSE_YML="/usr/share/minecraft-pi/client/docker-compose.yml"
|
2020-12-10 22:16:44 +00:00
|
|
|
|
2020-12-08 21:32:12 +00:00
|
|
|
# Ensure Features Are Selected
|
2020-12-08 23:20:25 +00:00
|
|
|
if [ -z "${MCPI_FEATURES+x}" ]; then
|
2021-02-02 00:35:30 +00:00
|
|
|
MCPI_FEATURES="$(eval "zenity --class \"${ZENITY_CLASS}\" --list --checklist --width 400 --height 400 --column 'Enabled' --column 'Feature' ${AVAILABLE_FEATURES}")"
|
|
|
|
fi
|
|
|
|
if [ -z "${MCPI_RENDER_DISTANCE+x}" ]; then
|
|
|
|
MCPI_RENDER_DISTANCE="$(zenity --class "${ZENITY_CLASS}" --list --radiolist --width 400 --height 400 --text 'Minecraft Render Distance:' --column 'Selected' --column 'Name' FALSE 'Far' FALSE 'Normal' TRUE 'Short' FALSE 'Tiny')"
|
2020-12-08 23:20:25 +00:00
|
|
|
fi
|
|
|
|
if [ -z "${MCPI_USERNAME+x}" ]; then
|
2020-12-10 22:16:44 +00:00
|
|
|
MCPI_USERNAME="$(zenity --class "${ZENITY_CLASS}" --entry --text 'Minecraft Username:' --entry-text 'StevePi')"
|
2020-12-08 23:20:25 +00:00
|
|
|
fi
|
2020-10-01 19:11:27 +00:00
|
|
|
export MCPI_FEATURES
|
2021-02-02 00:35:30 +00:00
|
|
|
export MCPI_RENDER_DISTANCE
|
2020-10-02 22:43:43 +00:00
|
|
|
export MCPI_USERNAME
|
2020-10-01 15:08:46 +00:00
|
|
|
|
2021-01-31 02:32:20 +00:00
|
|
|
# Prepare Environment
|
|
|
|
export USER_HOME="${HOME}"
|
2021-02-09 03:52:39 +00:00
|
|
|
export USER_UID="$(id -u)"
|
|
|
|
export USER_GID="$(id -g)"
|
|
|
|
get_gid() {
|
|
|
|
echo "$(getent group "$1" | cut -d : -f 3)"
|
|
|
|
}
|
|
|
|
export USER_OTHER_GIDS="$(get_gid video) $(get_gid render)"
|
2021-01-31 02:32:20 +00:00
|
|
|
|
2020-10-16 19:39:04 +00:00
|
|
|
# Run
|
2021-01-31 02:32:20 +00:00
|
|
|
set +e
|
2021-01-31 20:33:31 +00:00
|
|
|
sg docker /usr/lib/minecraft-pi/pre-launch.sh
|
2021-01-31 02:32:20 +00:00
|
|
|
RET=$?
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Handle Crash
|
|
|
|
if [ ${RET} -ne 0 ]; then
|
2021-02-21 00:10:13 +00:00
|
|
|
zenity --class "${ZENITY_CLASS}" --error --no-wrap --text 'Minecraft: Pi Edition has crashed!\n\nExit Code: '${RET}'\n\n<a href="file:///tmp/minecraft-pi">Open Log Folder</a>\n<a href="https://gitea.thebrokenrail.com/TheBrokenRail/minecraft-pi-reborn/src/branch/master/docs/TROUBLESHOOTING.md">Open Troubleshooting Guide</a>'
|
2021-01-31 02:32:20 +00:00
|
|
|
exit ${RET}
|
|
|
|
fi
|