diff --git a/Dockerfile.client b/Dockerfile.client
index 91d148393..47d642b64 100644
--- a/Dockerfile.client
+++ b/Dockerfile.client
@@ -38,6 +38,11 @@ RUN ./build/build-mods.sh
# Runtime Environment
FROM runtime-base AS runtime
+# Setup /home Permissions
+RUN \
+ mkdir -p /home && \
+ chmod -R a+rw /home
+
# Include Exported Libraries
COPY --from=build /app/export /
# Include Mods
diff --git a/README.md b/README.md
index 01c1c9468..81a1f3354 100644
--- a/README.md
+++ b/README.md
@@ -35,16 +35,23 @@ Minecraft: Pi Edition Modding Project
| ``minecraft-pi-reborn-virgl`` | Minecraft Pi Edition Using VirGL For Hardware Acceleration (Recommended For Desktop) |
| ``minecraft-pi-reborn-native`` | Minecraft: Pi Edition Using Docker Device Mounting For GPU Acceleration (Recommended For ARM Devices (ie. Raspberry Pi, PinePhone, etc)) |
-## Troubleshooting Crashes
+## Troubleshooting
Game logs are located in ``/tmp/minecraft-pi``.
### ``Error response from daemon: error gathering device information while adding custom device "/dev/dri": no such file or directory``
-Make sure you are using the correct GPU drivers for your system. If you are using a Raspberry Pi, make sure you have set your GPU driver to ``Full KMS`` or ``Fake KMS`` in ``raspi-config``.
+Make sure you are using the correct GPU drivers for your system. If you are using a Raspberry Pi, make sure your GPU driver is set to ``Full KMS`` or ``Fake KMS`` in ``raspi-config``.
-### ``Segmentation Fault``
+### ``Segmentation Fault`` (Exit Code: ``139``)
1. Attempt To Reproduce Issue And Record Instructions
2. Report On Issue Tracker Including The Instructions To Reproduce
+### ``[ERR]: Invalid ~/.minecraft-pi Permissions``
+Run:
+```sh
+sudo chown -R "$(id -u):$(id -g)" ~/.minecraft-pi
+chmod -R u+rw ~/.minecraft-pi
+```
+
## Dedicated Server
The dedicated server is a version of Minecraft: Pi Edition modified to run in a headless environment. It loads settings from a ``server.properties`` file.
diff --git a/debian/client/common/DEBIAN/postrm b/debian/client/common/DEBIAN/postrm
new file mode 100755
index 000000000..215ed5c8d
--- /dev/null
+++ b/debian/client/common/DEBIAN/postrm
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+set -e
+
+docker image rm thebrokenrail/minecraft-pi-reborn:client
\ No newline at end of file
diff --git a/debian/client/common/usr/bin/minecraft-pi b/debian/client/common/usr/bin/minecraft-pi
index b9325285b..721287c94 100755
--- a/debian/client/common/usr/bin/minecraft-pi
+++ b/debian/client/common/usr/bin/minecraft-pi
@@ -13,7 +13,7 @@ fi
# Export Important Variables
export ZENITY_CLASS='Minecraft - Pi edition'
-export DOCKER_COMPOSE="docker-compose -f /usr/share/minecraft-pi/client/docker-compose.yml"
+export DOCKER_COMPOSE_YML="/usr/share/minecraft-pi/client/docker-compose.yml"
# Ensure Features Are Selected
if [ -z "${MCPI_FEATURES+x}" ]; then
@@ -25,13 +25,21 @@ fi
export MCPI_FEATURES
export MCPI_USERNAME
-# Ensure Groups Are Correct
-if ! id -Gn "$(whoami)" | grep '\bdocker\b' > /dev/null; then
- pkexec /sbin/usermod -aG docker "$(whoami)"
-fi
-
# Allow X11 Connections From Root
xhost local:root
+# Prepare Environment
+export USER_HOME="${HOME}"
+export USER_UID="$(id -u)"
+
# Run
-sg docker /usr/lib/minecraft-pi/pre-launch.sh
\ No newline at end of file
+set +e
+/usr/lib/minecraft-pi/pre-launch.sh
+RET=$?
+set -e
+
+# Handle Crash
+if [ ${RET} -ne 0 ]; then
+ zenity --class "${ZENITY_CLASS}" --error --no-wrap --text 'Minecraft: Pi Edition has crashed!\n\nExit Code: '${RET}'\n\nOpen Log Folder\nOpen Troubleshooting Guide'
+ exit ${RET}
+fi
\ No newline at end of file
diff --git a/debian/client/common/usr/lib/minecraft-pi/pre-launch.sh b/debian/client/common/usr/lib/minecraft-pi/pre-launch.sh
index 4301c980a..5c8f87784 100755
--- a/debian/client/common/usr/lib/minecraft-pi/pre-launch.sh
+++ b/debian/client/common/usr/lib/minecraft-pi/pre-launch.sh
@@ -2,6 +2,9 @@
set -e
+# Prepare Data Folder
+mkdir -p "${USER_HOME}/.minecraft-pi"
+
# Create Log Folder
rm -rf /tmp/minecraft-pi
mkdir -p /tmp/minecraft-pi
@@ -20,8 +23,5 @@ set -e
# Kill Logging
kill ${TAIL_PID}
-# Handle Crash
-if [ ${RET} -ne 0 ]; then
- zenity --class "${ZENITY_CLASS}" --error --no-wrap --text 'Minecraft: Pi Edition has crashed!\nLogs are located in /tmp/minecraft-pi.\n\nExit Code: '${RET}
- exit ${RET}
-fi
\ No newline at end of file
+# Exit
+exit ${RET}
\ No newline at end of file
diff --git a/debian/client/native/usr/lib/minecraft-pi/run.sh b/debian/client/native/usr/lib/minecraft-pi/run.sh
index 8b870266c..39dee336b 100755
--- a/debian/client/native/usr/lib/minecraft-pi/run.sh
+++ b/debian/client/native/usr/lib/minecraft-pi/run.sh
@@ -3,4 +3,4 @@
set -e
# Launch Minecraft
-${DOCKER_COMPOSE} run --rm minecraft-pi
\ No newline at end of file
+docker-compose -f "${DOCKER_COMPOSE_YML}" run --rm minecraft-pi
\ No newline at end of file
diff --git a/debian/client/native/usr/share/minecraft-pi/client/docker-compose.yml b/debian/client/native/usr/share/minecraft-pi/client/docker-compose.yml
index 639d0d589..e6fa139a1 100644
--- a/debian/client/native/usr/share/minecraft-pi/client/docker-compose.yml
+++ b/debian/client/native/usr/share/minecraft-pi/client/docker-compose.yml
@@ -3,13 +3,15 @@ services:
minecraft-pi:
image: 'thebrokenrail/minecraft-pi-reborn:client'
network_mode: 'host'
+ user: '${USER_UID}'
volumes:
- /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static
- '/tmp/.X11-unix:/tmp/.X11-unix'
- - '~/.minecraft-pi:/root/.minecraft'
+ - '${USER_HOME}/.minecraft-pi:/root/.minecraft'
devices:
- '/dev/dri:/dev/dri'
environment:
+ - 'HOME=/root'
- 'DISPLAY=unix${DISPLAY}'
- 'MCPI_FEATURES=${MCPI_FEATURES}'
- 'MCPI_USERNAME=${MCPI_USERNAME}'
diff --git a/debian/client/virgl/usr/lib/minecraft-pi/run.sh b/debian/client/virgl/usr/lib/minecraft-pi/run.sh
index 09099f7d8..8caeb8c26 100755
--- a/debian/client/virgl/usr/lib/minecraft-pi/run.sh
+++ b/debian/client/virgl/usr/lib/minecraft-pi/run.sh
@@ -8,7 +8,7 @@ VIRGL_PID=$!
# Launch Minecraft
set +e
-${DOCKER_COMPOSE} run --rm minecraft-pi
+docker-compose -f "${DOCKER_COMPOSE_YML}" run --rm minecraft-pi
RET=$?
set -e
diff --git a/debian/client/virgl/usr/share/minecraft-pi/client/docker-compose.yml b/debian/client/virgl/usr/share/minecraft-pi/client/docker-compose.yml
index 5c8e30197..8b90a50ee 100644
--- a/debian/client/virgl/usr/share/minecraft-pi/client/docker-compose.yml
+++ b/debian/client/virgl/usr/share/minecraft-pi/client/docker-compose.yml
@@ -3,12 +3,14 @@ services:
minecraft-pi:
image: 'thebrokenrail/minecraft-pi-reborn:client'
network_mode: 'host'
+ user: '${USER_UID}'
volumes:
- /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static
- '/tmp/.X11-unix:/tmp/.X11-unix'
- '/tmp/.virgl_test:/tmp/.virgl_test'
- - '~/.minecraft-pi:/root/.minecraft'
+ - '${USER_HOME}/.minecraft-pi:/home/.minecraft'
environment:
+ - 'HOME=/home'
- 'DISPLAY=unix${DISPLAY}'
- 'MCPI_FEATURES=${MCPI_FEATURES}'
- 'MCPI_USERNAME=${MCPI_USERNAME}'
diff --git a/debian/server/usr/bin/minecraft-pi-server b/debian/server/usr/bin/minecraft-pi-server
index 093053a7d..4f0bfd986 100755
--- a/debian/server/usr/bin/minecraft-pi-server
+++ b/debian/server/usr/bin/minecraft-pi-server
@@ -2,8 +2,10 @@
set -e
+# Prepare Environment
export MCPI_ROOT="${PWD}"
+export USER_UID="${UID}"
# Launch Minecraft
-DOCKER_COMPOSE="docker-compose -f /usr/share/minecraft-pi/server/docker-compose.yml"
-${DOCKER_COMPOSE} run --rm minecraft-pi-server
+DOCKER_COMPOSE_YML='/usr/share/minecraft-pi/server/docker-compose.yml'
+docker-compose -f "${DOCKER_COMPOSE_YML}" run --rm minecraft-pi-server
diff --git a/debian/server/usr/share/minecraft-pi/server/docker-compose.yml b/debian/server/usr/share/minecraft-pi/server/docker-compose.yml
index ba080d3c4..6705ae86a 100644
--- a/debian/server/usr/share/minecraft-pi/server/docker-compose.yml
+++ b/debian/server/usr/share/minecraft-pi/server/docker-compose.yml
@@ -3,6 +3,9 @@ services:
minecraft-pi-server:
image: 'thebrokenrail/minecraft-pi-reborn:server'
network_mode: 'host'
+ user: '${USER_UID}'
volumes:
- /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static
- - '${MCPI_ROOT}:/root/.minecraft'
+ - '${MCPI_ROOT}:/home/.minecraft'
+ environment:
+ - 'HOME=/home'
diff --git a/mods/src/test/test.c b/mods/src/test/test.c
index d75df5814..fd300ae74 100644
--- a/mods/src/test/test.c
+++ b/mods/src/test/test.c
@@ -1,3 +1,5 @@
+#define _GNU_SOURCE
+
#include
#include
#include
@@ -23,20 +25,35 @@ struct timespec32 {
void run_tests() {
// Test clock_gettime64
- struct timespec64 ts64;
- long out = syscall(SYS_clock_gettime64, CLOCK_MONOTONIC, &ts64);
- if (out != 0) {
- if (errno == ENOSYS) {
- // clock_gettime64 Unsupported, Testing clock_gettime
- struct timespec32 ts32;
- out = syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &ts32);
- if (out != 0) {
+ {
+ struct timespec64 ts64;
+ long out = syscall(SYS_clock_gettime64, CLOCK_MONOTONIC, &ts64);
+ if (out != 0) {
+ if (errno == ENOSYS) {
+ // clock_gettime64 Unsupported, Testing clock_gettime
+ struct timespec32 ts32;
+ out = syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &ts32);
+ if (out != 0) {
+ // Failure
+ ERR("Unable To Run clock_gettime Syscall: %s", strerror(errno));
+ }
+ } else {
// Failure
- ERR("Unable To Run clock_gettime Syscall: %s", strerror(errno));
+ ERR("Unable To Run clock_gettime64 Syscall: %s", strerror(errno));
}
- } else {
+ }
+ }
+
+ // Test ~/.minecraft Permissions
+ {
+ char *path = NULL;
+ asprintf(&path, "%s/.minecraft", getenv("HOME"));
+ int ret = access(path, R_OK | W_OK);
+ free(path);
+
+ if (ret != 0) {
// Failure
- ERR("Unable To Run clock_gettime64 Syscall: %s", strerror(errno));
+ ERR("%s", "Invalid ~/.minecraft-pi Permissions");
}
}
}
\ No newline at end of file
diff --git a/scripts/package.sh b/scripts/package.sh
index 64fcb4a8c..c4e8b71e0 100755
--- a/scripts/package.sh
+++ b/scripts/package.sh
@@ -6,7 +6,7 @@ DEB_VERSION='1.0.0'
# Dependencies
REQUIRED_DOCKER_VERSION='19.03'
COMMON_DEPENDENCIES="docker.io (>=${REQUIRED_DOCKER_VERSION}) | docker-ce (>=${REQUIRED_DOCKER_VERSION}), libseccomp2 (>=2.4.2), docker-compose, binfmt-support"
-CLIENT_DEPENDENCIES="zenity, policykit-1, passwd, login, x11-xserver-utils"
+CLIENT_DEPENDENCIES="zenity, x11-xserver-utils"
RECOMMENDED_DEPENDENCIES="qemu-user-static"
set -e
@@ -40,7 +40,7 @@ package_client() {
cp debian/tmp/client-image.tar.gz "debian/tmp/$1/usr/share/minecraft-pi/client/image.tar.gz"
prepare_control "debian/tmp/$1" ", ${CLIENT_DEPENDENCIES}"
# Build
- dpkg -b "debian/tmp/$1" out/deb
+ dpkg-deb -b --root-owner-group "debian/tmp/$1" out/deb
}
package_client virgl
package_client native
@@ -55,7 +55,7 @@ package_server() {
cp debian/tmp/server-image.tar.gz debian/tmp/server/usr/share/minecraft-pi/server/image.tar.gz
prepare_control debian/tmp/server ''
# Build
- dpkg -b debian/tmp/server out/deb
+ dpkg-deb -b --root-owner-group debian/tmp/server out/deb
}
package_server