Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run server as minecraft user rather than root #38

Merged
merged 1 commit into from
Dec 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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