Files
minecraft/neoforged/Install_Script.sh
fithwum 1406c69f9b
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 fabric (push) Successful in 18s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push testing-fabric (push) Successful in 20s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push testing-neoforged (push) Successful in 20s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push neoforged (push) Successful in 1m6s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push testing-vanilla (push) Successful in 1m5s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push vanilla (push) Has been cancelled
Build and Push Minecraft Docker Images on Debian-base update / generate-changelogs (push) Has been cancelled
Build and Push Minecraft Docker Images on Debian-base update / generate-build-info (push) Has been cancelled
test
2025-12-18 10:02:37 -08:00

106 lines
3.0 KiB
Bash

#!/bin/bash
# Copyright (c) 2022 fithwum
# All rights reserved
FIRST_RUN=false
[ ! -d "$MC_DIR/world" ] && FIRST_RUN=true
MC_DIR=/MCserver
# Main Install Links
INSTALLER_FILE=https://maven.neoforged.net/releases/net/neoforged/neoforge/$NEOFORGED_VERSION/neoforge-$NEOFORGED_VERSION-installer.jar
SERVER_FILE=https://github.com/neoforged/ServerStarterJar/releases/download/$SERVER_VERSION/server.jar
MC_RUN_FILE=https://gitea.fithwum.tech/fithwum/minecraft/raw/branch/master/neoforged/run.sh
# 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
rm -fr neoforge-*.jar run-*.sh /libraries
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
# Check for EULA
if [ ! -f $MC_DIR/eula.txt ]; then
:
else
if [ "$ACCEPT_EULA" == "false" ]; then
if grep -rq 'eula=true' $MC_DIR/eula.txt; then
sed -i '/eula=true/c\eula=false' $MC_DIR/eula.txt
fi
echo " "
echo "WARNING ! EULA not accepted, you must accept the EULA"
echo " to start the Server, putting server in sleep mode"
sleep infinity
fi
fi
if [ ! -f $MC_DIR/eula.txt ]; then
echo " "
echo "WARNING ! EULA not found please stand by..."
sleep 5
fi
if [ "$ACCEPT_EULA" == "true" ]; then
if grep -rq 'eula=false' $MC_DIR/eula.txt; then
sed -i '/eula=false/c\eula=true' $MC_DIR/eula.txt
echo " "
echo "INFO ! EULA accepted, server restarting, please wait..."
sleep 1
cd $MC_DIR
exec ./run-$NEOFORGED_VERSION.sh nogui
exit 0
fi
elif [ "$ACCEPT_EULA" == "false" ]; then
echo " "
echo "WARNING ! EULA not accepted, you must accept the EULA"
echo " to start the Server, putting server in sleep mode"
sleep infinity
else
echo " "
echo "WARNING ! Something went wrong, please check EULA variable"
fi
echo "INFO ! Setting game port."
if [ -f 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
-Xms${XMS_SIZE}
-Xmx${XMX_SIZE}
EOF
[ -n "$XMN_SIZE" ] && echo "-Xmn${XMN_SIZE}" >> $MC_DIR/user_jvm_args.txt
# 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
if [ "$FIRST_RUN" = "true" ]; then
echo "INFO ! First bootstrap run (datapack generation)"
"./run-${NEOFORGED_VERSION}.sh"
else
exec "./run-${NEOFORGED_VERSION}.sh" nogui
fi
exit