No Longer Run MCPI As Root
This commit is contained in:
parent
b5556e91c3
commit
f6dd4a17e6
@ -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
|
||||
|
13
README.md
13
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.
|
||||
|
||||
|
5
debian/client/common/DEBIAN/postrm
vendored
Executable file
5
debian/client/common/DEBIAN/postrm
vendored
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
docker image rm thebrokenrail/minecraft-pi-reborn:client
|
22
debian/client/common/usr/bin/minecraft-pi
vendored
22
debian/client/common/usr/bin/minecraft-pi
vendored
@ -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
|
||||
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\n<a href="file:///tmp/minecraft-pi">Open Log Folder</a>\n<a href="https://gitea.thebrokenrail.com/TheBrokenRail/minecraft-pi-reborn#troubleshooting">Open Troubleshooting Guide</a>'
|
||||
exit ${RET}
|
||||
fi
|
@ -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
|
||||
# Exit
|
||||
exit ${RET}
|
@ -3,4 +3,4 @@
|
||||
set -e
|
||||
|
||||
# Launch Minecraft
|
||||
${DOCKER_COMPOSE} run --rm minecraft-pi
|
||||
docker-compose -f "${DOCKER_COMPOSE_YML}" run --rm minecraft-pi
|
@ -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}'
|
||||
|
@ -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
|
||||
|
||||
|
@ -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}'
|
||||
|
6
debian/server/usr/bin/minecraft-pi-server
vendored
6
debian/server/usr/bin/minecraft-pi-server
vendored
@ -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
|
||||
|
@ -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'
|
||||
|
@ -1,3 +1,5 @@
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user