Fix Startup Script

This commit is contained in:
TheBrokenRail 2020-10-01 15:11:27 -04:00
parent f2c2fdff43
commit 9198fff5b3
4 changed files with 25 additions and 10 deletions

View File

@ -4,4 +4,4 @@ Maintainer: TheBrokenRail <connor24nolan@live.com>
Description: Fun with Blocks
Homepage: https://www.minecraft.net/en-us/edition/pi
Architecture: amd64
Depends: docker.io, docker-compose, virgl-server, zenity, policykit-1
Depends: docker.io, docker-compose, virgl-server, zenity, policykit-1, adduser

View File

@ -2,21 +2,36 @@
set -e
FEATURES="$(zenity --class minecraft-pi --list --checklist --column 'Enabled' --column 'Feature' FALSE 'Touch GUI' FALSE 'Survival Mode' FALSE 'Fix Bow & Arrow' FALSE 'Fix Attacking' FALSE 'Mob Spawning')"
export FEATURES
# Ensure Features Are Selected
USER_LAUNCH=1
if [ -z "${MCPI_FEATURES}" ]; then
MCPI_FEATURES="$(zenity --class minecraft-pi --list --checklist --column 'Enabled' --column 'Feature' FALSE 'Touch GUI' FALSE 'Survival Mode' FALSE 'Fix Bow & Arrow' FALSE 'Fix Attacking' FALSE 'Mob Spawning')"
else
USER_LAUNCH=0
fi
export MCPI_FEATURES
# Start VirGL
virgl_test_server &
PID="$!"
VIRGL_PID="$!"
if ! id -Gn "$(whoami)" | grep '\bdocker\b' > /dev/null; then
pkexec adduser "$(whoami)" docker
# Ensure Groups Are Correct
if [ "${USER_LAUNCH}" = "1" ]; then
if ! id -Gn "$(whoami)" | grep '\bdocker\b' > /dev/null; then
pkexec adduser "$(whoami)" docker
fi
su -p "$(whoami)" "$(realpath -e "$0")"
exit "$?"
fi
# Allow X11 Connections From Root
xhost local:root
# Launch Minecraft
DOCKER_COMPOSE="docker-compose -f /usr/share/minecraft-pi/docker-compose.yml"
${DOCKER_COMPOSE} up
${DOCKER_COMPOSE} down
kill "${PID}"
# Kill VirGL
kill "${VIRGL_PID}"

View File

@ -9,4 +9,4 @@ services:
- '~/.minecraft-pi:/root/.minecraft'
environment:
- 'DISPLAY=unix${DISPLAY}'
- 'FEATURES=${FEATURES}'
- 'MCPI_FEATURES=${MCPI_FEATURES}'

View File

@ -68,7 +68,7 @@ static void handleClick_injection(unsigned char *this, unsigned char *param_2, u
}
static int has_feature(const char *name) {
char *env = getenv("FEATURES");
char *env = getenv("MCPI_FEATURES");
char *features = strdup(env != NULL ? env : "");
char *tok = strtok(features, "|");
int ret = 0;