Files
minecraft/neoforged/Install_Script.sh
fithwum 0a79d283d3
Some checks failed
Build and Push Minecraft Docker Images on Debian-base update / poll-debian-base-and-detect-changes (push) Successful in 12s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push neoforged (push) Successful in 54s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push fabric (push) Successful in 1m0s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push forge (push) Successful in 1m9s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push testing (push) Failing after 53s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push vanilla (push) Successful in 1m3s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push bukkit (push) Successful in 2m5s
Build and Push Minecraft Docker Images on Debian-base update / generate-changelogs (push) Has been skipped
Build and Push Minecraft Docker Images on Debian-base update / generate-build-info (push) Has been skipped
fix dir error
2025-12-20 08:18:12 -08:00

88 lines
2.6 KiB
Bash

#!/bin/bash
# Copyright (c) 2022 fithwum
# All rights reserved
MC_DIR=/MCserver
EULA_FILE=$MC_DIR/eula.txt
EULA_MARKER=$MC_DIR/.eula_accepted
# Main Install Links
INSTALLER_FILE=https://maven.neoforged.net/releases/net/neoforged/neoforge/$NEOFORGED_VERSION/neoforge-$NEOFORGED_VERSION-installer.jar
# Main install (Debian).
# Check for server files and download if needed.
if [ -e $MC_DIR/neoforge-$NEOFORGED_VERSION-installer.jar ]
then
echo " "
echo "INFO ! neoforge-$NEOFORGED_VERSION-installer.jar found starting now."
else
echo " "
echo "WARNING ! neoforge-$NEOFORGED_VERSION-installer.jar is out of date/missing ... will download now."
echo " "
echo "INFO ! Cleaning old files."
cd $MC_DIR
mkdir -p /old-server-versions/
mv neoforge-*.jar old-server-versions/
mv run-*.sh old-server-versions/
mv /libraries /libraries_OLD
mv /libraries_OLD old-server-versions/
wget --no-cache --show-progress --progress=bar:force:noscroll $INSTALLER_FILE -O neoforge-$NEOFORGED_VERSION-installer.jar
chmod +x neoforge-$NEOFORGED_VERSION-installer.jar
java -jar neoforge-$NEOFORGED_VERSION-installer.jar --installServer
mv run.sh run-$NEOFORGED_VERSION.sh
chmod +x run-$NEOFORGED_VERSION.sh
cd ..
fi
echo "INFO ! Setting game port."
if [ -f $MC_DIR/server.properties ]; then
sed -i '/server-port='*'/c\server-port='$GAME_PORT'' $MC_DIR/server.properties
fi
echo "INFO ! Setting java settings."
cat > $MC_DIR/user_jvm_args.txt <<EOF
-Xmx${XMX_SIZE}
-Xms${XMS_SIZE}
EOF
[ -n "$XMN_SIZE" ] && echo "-Xmn${XMN_SIZE}" >> $MC_DIR/user_jvm_args.txt
# Wait briefly for installer/server to generate eula.txt
if [ ! -f "$EULA_FILE" ] && [ ! -f "$EULA_MARKER" ]; then
echo "INFO ! Waiting for EULA generation..."
sleep 5
fi
# If EULA already accepted once, never touch it again
if [ -f "$EULA_MARKER" ]; then
echo "INFO ! EULA previously accepted"
return 0 2>/dev/null || true
fi
# First-time decision
if [ "$ACCEPT_EULA" = "true" ]; then
echo "INFO ! Accepting EULA (one-time)"
sed -i 's/eula=false/eula=true/' "$EULA_FILE" 2>/dev/null \
|| echo "eula=true" > "$EULA_FILE"
touch "$EULA_MARKER"
elif [ "$ACCEPT_EULA" = "false" ]; then
echo "WARNING ! EULA not accepted on first run"
echo "WARNING ! Set ACCEPT_EULA=true to proceed"
sleep infinity
else
echo "ERROR ! ACCEPT_EULA must be set to true or false on first run"
sleep infinity
fi
# Set permissions.
chown 99:100 -R $MC_DIR
chmod 777 -R $MC_DIR
sleep 1
# Run Minecraft server.
echo " "
echo "INFO ! Starting Minecraft Server $NEOFORGED_VERSION"
cd $MC_DIR
exec ./run-$NEOFORGED_VERSION.sh nogui
exit