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

52 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
set -e
# All Feature Flags
export AVAILABLE_FEATURES="$(echo \
"TRUE 'Touch GUI'" \
"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'" \
"FALSE 'Expand Creative Inventory'" \
"FALSE 'Peaceful Mode'" \
"TRUE 'Animated Water'" \
"TRUE 'Remove Invalid Item Background'" \
"TRUE 'Disable gui_blocks Atlas'" \
"TRUE 'Smooth Lighting'" \
"FALSE '3D Anaglyph'")"
# Print Feature Flags Option
if [ "$1" = "--print-features" ]; then
echo "${AVAILABLE_FEATURES}"
exit 0
fi
# Export Important Variables
export ZENITY_CLASS='Minecraft - Pi edition'
export DOCKER_COMPOSE="docker-compose -f /usr/share/minecraft-pi/client/docker-compose.yml"
# Ensure Features Are Selected
if [ -z "${MCPI_FEATURES+x}" ]; then
MCPI_FEATURES="$(sh -c "zenity --class \"${ZENITY_CLASS}\" --list --checklist --column 'Enabled' --column 'Feature' ${AVAILABLE_FEATURES}")"
fi
if [ -z "${MCPI_USERNAME+x}" ]; then
MCPI_USERNAME="$(zenity --class "${ZENITY_CLASS}" --entry --text 'Minecraft Username:' --entry-text 'StevePi')"
fi
export MCPI_FEATURES
export MCPI_USERNAME
# Ensure Groups Are Correct
if ! id -Gn "$(whoami)" | grep '\bdocker\b' > /dev/null; then
pkexec usermod -aG docker "$(whoami)"
fi
# Allow X11 Connections From Root
xhost local:root
# Run
sg docker /usr/lib/minecraft-pi/pre-launch.sh