Skip to content

Commit

Permalink
Merge pull request #38 from Jepson2k/main
Browse files Browse the repository at this point in the history
Run server as minecraft user rather than root
  • Loading branch information
TheRemote authored Dec 1, 2024
2 parents c75b581 + 15d629c commit b4f4e12
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit b4f4e12

Please sign in to comment.