minecraft-pi-docker/debian/usr/bin/minecraft-pi

41 lines
1.4 KiB
Plaintext
Raw Normal View History

2020-09-25 23:37:22 +00:00
#!/bin/sh
set -e
2020-10-01 19:11:27 +00:00
# Ensure Features Are Selected
2020-10-01 19:25:02 +00:00
if [ -z "${MCPI_SUBSHELL}" ]; then
2020-10-05 22:29:58 +00:00
MCPI_FEATURES="$(zenity --class 'Minecraft - Pi edition' --list --checklist --column 'Enabled' --column 'Feature' TRUE 'Touch GUI' FALSE 'Survival Mode' TRUE 'Fix Bow & Arrow' TRUE 'Fix Attacking' TRUE 'Mob Spawning' TRUE 'Fancy Graphics' TRUE 'Disable Autojump By Default' TRUE 'Fix Sign Placement' TRUE 'Show Block Outlines')"
MCPI_USERNAME="$(zenity --class 'Minecraft - Pi edition' --entry --text 'Minecraft Username:' --entry-text 'StevePi')"
2020-10-01 19:11:27 +00:00
fi
export MCPI_FEATURES
export MCPI_USERNAME
2020-10-01 15:08:46 +00:00
2020-10-01 19:11:27 +00:00
# Start VirGL
2020-09-25 23:37:22 +00:00
virgl_test_server &
2020-10-01 19:11:27 +00:00
VIRGL_PID="$!"
# Ensure Groups Are Correct
2020-10-01 19:25:02 +00:00
if [ -z "${MCPI_SUBSHELL}" ]; then
2020-10-01 19:11:27 +00:00
if ! id -Gn "$(whoami)" | grep '\bdocker\b' > /dev/null; then
2020-10-10 18:54:44 +00:00
if ! command -v adduser &> /dev/null
then
pkexec usermod -aG "$(whoami)" docker
2020-10-11 00:18:04 +00:00
else
pkexec adduser "$(whoami)" docker
2020-10-10 18:54:44 +00:00
fi
2020-10-01 19:11:27 +00:00
fi
2020-10-01 19:25:02 +00:00
exec sg docker "env MCPI_SUBSHELL=1 \"$(realpath -e "$0")\""
2020-10-01 18:33:52 +00:00
fi
2020-10-01 19:11:27 +00:00
# Allow X11 Connections From Root
2020-09-25 23:37:22 +00:00
xhost local:root
2020-10-01 19:11:27 +00:00
# Launch Minecraft
2020-09-25 23:37:22 +00:00
DOCKER_COMPOSE="docker-compose -f /usr/share/minecraft-pi/docker-compose.yml"
2020-10-07 14:26:01 +00:00
${DOCKER_COMPOSE} pull | zenity --class 'Minecraft - Pi edition' --progress --pulsate --no-cancel --auto-close --text 'Updating Minecraft...'
2020-09-25 23:37:22 +00:00
${DOCKER_COMPOSE} up
${DOCKER_COMPOSE} down
2020-10-01 19:11:27 +00:00
# Kill VirGL
kill "${VIRGL_PID}"