diff --git a/start.sh b/start.sh index 080af01..ad61a1f 100755 --- a/start.sh +++ b/start.sh @@ -3,6 +3,20 @@ # Author: James A. Chambers - https://jamesachambers.com/minecraft-java-bedrock-server-together-geyser-floodgate/ # GitHub Repository: https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate +# If running as root, create 'minecraft' user and restart script as 'minecraft' user +if [ "$(id -u)" = '0' ]; then + echo "Script is running as root, switching to 'minecraft' user..." + + if ! id minecraft >/dev/null 2>&1; then + echo "Creating 'minecraft' user..." + useradd -m -r -s /bin/bash minecraft + fi + + chown -R minecraft:minecraft /minecraft + + exec su minecraft -c "$0 $@" +fi + echo "Paper Minecraft Java Server Docker + Geyser/Floodgate script by James A. Chambers" echo "Latest version always at https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate" echo "Don't forget to set up port forwarding on your router! The default port is 25565 and the Bedrock port is 19132"