Build and Push Minecraft Docker Images on Debian-base update / poll-debian-base-and-detect-changes (push) Successful in 29s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push fabric (push) Successful in 34s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push bukkit (push) Successful in 34s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push forge (push) Successful in 35s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push neoforged (push) Successful in 35s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push testing (push) Successful in 33s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push quilt (push) Successful in 33s
Build and Push Minecraft Docker Images on Debian-base update / Build and Push vanilla (push) Successful in 28s
Build and Push Minecraft Docker Images on Debian-base update / generate-changelogs (push) Successful in 8s
Build and Push Minecraft Docker Images on Debian-base update / generate-build-info (push) Has been cancelled
Build and Push Minecraft Docker Images on Debian-base update / Docker prune (vm-docker-build2) (push) Successful in 4s
109 lines
3.5 KiB
Bash
109 lines
3.5 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
|
|
|
|
VERSION_CHECK=$(curl -s "https://piston-meta.mojang.com/mc/game/version_manifest_v2.json" | grep -Pom 1 '"url": "\K[^"]*'$MC_VERSION'.json')
|
|
MC_SERVER_FILE=$(curl -s $VERSION_CHECK | jq --raw-output '.downloads.server.url')
|
|
MC_RUN_FILE=https://gitea.fithwum.tech/fithwum/minecraft/raw/branch/master/vanilla/run.sh
|
|
|
|
# Install java
|
|
if dpkg -s openjdk-$JAVA_VERSION-jre-headless &> /dev/null
|
|
then
|
|
echo "INFO ! openjdk-$JAVA_VERSION-jre-headless installed ... moving on."
|
|
else
|
|
echo " "
|
|
echo "WARNING ! openjdk-$JAVA_VERSION-jre-headless not installed ... will install now."
|
|
apt-get update
|
|
apt-get --no-install-recommends -y install openjdk-$JAVA_VERSION-jre-headless
|
|
fi
|
|
|
|
# if dpkg -s msopenjdk-$JAVA_VERSION &> /dev/null
|
|
# then
|
|
# echo "INFO ! msopenjdk-$JAVA_VERSION installed ... moving on."
|
|
# else
|
|
# echo " "
|
|
# echo "WARNING ! msopenjdk-$JAVA_VERSION not installed ... will install now."
|
|
# wget https://packages.microsoft.com/config/debian/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
|
|
# dpkg -i packages-microsoft-prod.deb \
|
|
# apt-get update && apt-get install -y msopenjdk-25 \
|
|
# apt-get -y update && apt-get -y --fix-broken install
|
|
# fi
|
|
|
|
# Main install (Debian).
|
|
# Check for server files and download if needed.
|
|
if [ -e $MC_DIR/MCserver-$MC_VERSION.jar ]
|
|
then
|
|
echo " "
|
|
echo "INFO ! MCserver-$MC_VERSION.jar found starting now."
|
|
else
|
|
echo " "
|
|
echo "WARNING ! MCserver-$MC_VERSION.jar is out of date/missing ... will download now."
|
|
echo " "
|
|
echo "INFO ! Cleaning old files."
|
|
mkdir -p $MC_DIR/old-server-versions/
|
|
mv $MC_DIR/MCserver-*.jar $MC_DIR/old-server-versions/
|
|
wget --no-cache --show-progress --progress=bar:force:noscroll $MC_SERVER_FILE -O $MC_DIR/MCserver-$MC_VERSION.jar
|
|
chmod +x $MC_DIR/MCserver-$MC_VERSION.jar
|
|
fi
|
|
|
|
# Looking for run-${MC_VERSION}.sh
|
|
if [ -e $MC_DIR/run-$MC_VERSION.sh ]
|
|
then
|
|
echo " "
|
|
echo "INFO ! run-$MC_VERSION.sh found ... will use existing file."
|
|
else
|
|
echo " "
|
|
echo "WARNING ! run.sh is out of date/missing ... will download now."
|
|
mv $MC_DIR/run-*.sh $MC_DIR/old-server-versions/
|
|
wget --no-cache --show-progress --progress=bar:force:noscroll $MC_RUN_FILE -O $MC_DIR/run-$MC_VERSION.sh
|
|
chmod +x $MC_DIR/run-$MC_VERSION.sh
|
|
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
|
|
|
|
# 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 $MC_VERSION"
|
|
exec $MC_DIR/run-$MC_VERSION.sh --dataPath=$MC_DIR
|
|
|
|
exit |