Compare commits
3 Commits
4a87556384
...
b89c1b9f8a
Author | SHA1 | Date |
---|---|---|
Daniel Wolf | b89c1b9f8a | |
Daniel Wolf | 1c99b25e53 | |
Daniel Wolf | 1755a34a3d |
|
@ -23,6 +23,7 @@ name: after
|
|||
steps:
|
||||
- name: notify
|
||||
image: appleboy/drone-discord
|
||||
failure: ignore
|
||||
settings:
|
||||
avatar_url: https://nephatrine.net/images/buttons/drone-ci.png
|
||||
message: "Build of **[{{repo.name}}:{{commit.branch}}](<https://code.nephatrine.net/nephatrine/{{repo.name}}/src/branch/{{commit.branch}}>)** returned [{{build.status}}](<{{build.link}}>)."
|
||||
|
@ -42,6 +43,6 @@ trigger:
|
|||
|
||||
---
|
||||
kind: signature
|
||||
hmac: de523a0f816def70d9b83189674f2fcf596148ff6ecf24cd781c7bdbeb13c80d
|
||||
hmac: 15d0b2178d726ebdc8490861f0bc8ef704ae35d31275f07da9143c4f2e40a50f
|
||||
|
||||
...
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
sign-build.sh
|
||||
test-build.sh
|
||||
fix-perms.sh
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
if pgrep -f minedock >/dev/null; then
|
||||
s6-setuidgid guardian screen -S minedock -X stuff "`echo -ne \"say MINECRAFT SERVER SHUTTING DOWN!\r\"`"
|
||||
s6-setuidgid guardian screen -S minedock -X stuff "`echo -ne \"save-all\r\"`"
|
||||
s6-setuidgid guardian screen -S minedock -X stuff "`echo -ne \"say 3...\r\"`"
|
||||
sleep 2
|
||||
s6-setuidgid guardian screen -S minedock -X stuff "`echo -ne \"say 2...\r\"`"
|
||||
sleep 2
|
||||
s6-setuidgid guardian screen -S minedock -X stuff "`echo -ne \"say 1...\r\"`"
|
||||
sleep 2
|
||||
s6-setuidgid guardian screen -S minedock -X stuff "`echo -ne \"stop\r\"`"
|
||||
sleep 2
|
||||
fi
|
|
@ -1,218 +0,0 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
|
||||
if [[ -z "${SERVER_PUBLIC}" ]]; then
|
||||
if [[ -e /mnt/config/etc/myip ]]; then
|
||||
find /mnt/config/etc/myip -mtime +1 -delete
|
||||
fi
|
||||
if [[ ! -e /mnt/config/etc/myip ]]; then
|
||||
s6-setuidgid guardian wget -q -O /mnt/config/etc/myip https://myip.dnsomatic.com/
|
||||
fi
|
||||
SERVER_PUBLIC=$(cat /mnt/config/etc/myip)
|
||||
fi
|
||||
|
||||
SERVER_NAME=${SERVER_NAME:-"custom"}
|
||||
|
||||
MODPACK_NAME=${MODPACK_NAME:-"${SERVER_NAME}"}
|
||||
MODPACK_PUBLIC=${MODPACK_PUBLIC:-"https://${SERVER_PUBLIC}"}
|
||||
|
||||
# === Minecraft Version ===
|
||||
|
||||
if [[ -z "${MINECRAFT_VERSION}" ]]; then
|
||||
if [[ -e /mnt/config/etc/minecraft/version_manifest.json ]]; then
|
||||
find /mnt/config/etc/minecraft/version_manifest.json -mtime +1 -delete
|
||||
fi
|
||||
if [[ ! -e /mnt/config/etc/minecraft/version_manifest.json ]]; then
|
||||
if [[ ! -d /mnt/config/etc/minecraft ]]; then
|
||||
s6-setuidgid guardian mkdir /mnt/config/etc/minecraft
|
||||
fi
|
||||
s6-setuidgid guardian wget -P /mnt/config/etc/minecraft "https://launchermeta.mojang.com/mc/game/version_manifest.json"
|
||||
fi
|
||||
MINECRAFT_VERSION=$(jq -r '.latest.release' /mnt/config/etc/minecraft/version_manifest.json)
|
||||
fi
|
||||
|
||||
# === Fabric Installer Version ===
|
||||
|
||||
if [[ -e /mnt/config/etc/fabric-installer/maven-metadata.xml ]]; then
|
||||
find /mnt/config/etc/fabric-installer/maven-metadata.xml -mtime +1 -delete
|
||||
fi
|
||||
if [[ ! -e /mnt/config/etc/fabric-installer/maven-metadata.xml ]]; then
|
||||
if [[ ! -d /mnt/config/etc/fabric-installer ]]; then
|
||||
s6-setuidgid guardian mkdir -p /mnt/config/etc/fabric-installer
|
||||
fi
|
||||
s6-setuidgid guardian wget -P /mnt/config/etc/fabric-installer "https://maven.fabricmc.net/net/fabricmc/fabric-installer/maven-metadata.xml"
|
||||
fi
|
||||
|
||||
FABRIC_INSTALLER_VERSION=${FABRIC_INSTALLER_VERSION:-"release"}
|
||||
if ! printf "$FABRIC_INSTALLER_VERSION" | grep -q [0-9]; then
|
||||
FABRIC_INSTALLER_VERSION=$(xmllint --xpath "metadata/versioning/${FABRIC_INSTALLER_VERSION}/text()" /mnt/config/etc/fabric-installer/maven-metadata.xml)
|
||||
fi
|
||||
|
||||
# === Fabric Loader Version ===
|
||||
|
||||
if [[ -e /mnt/config/etc/fabric-loader/maven-metadata.xml ]]; then
|
||||
find /mnt/config/etc/fabric-loader/maven-metadata.xml -mtime +1 -delete
|
||||
fi
|
||||
if [[ ! -e /mnt/config/etc/fabric-loader/maven-metadata.xml ]]; then
|
||||
if [[ ! -d /mnt/config/etc/fabric-loader ]]; then
|
||||
s6-setuidgid guardian mkdir -p /mnt/config/etc/fabric-loader
|
||||
fi
|
||||
s6-setuidgid guardian wget -P /mnt/config/etc/fabric-loader "https://maven.fabricmc.net/net/fabricmc/fabric-loader/maven-metadata.xml"
|
||||
fi
|
||||
|
||||
FABRIC_VERSION=${FABRIC_VERSION:-"release"}
|
||||
if [[ ! -z "${FABRIC_VERSION}" ]]; then
|
||||
if ! printf "$FABRIC_VERSION" | grep -q [0-9]; then
|
||||
FABRIC_VERSION=$(xmllint --xpath "metadata/versioning/${FABRIC_VERSION}/text()" /mnt/config/etc/fabric-loader/maven-metadata.xml)
|
||||
fi
|
||||
fi
|
||||
|
||||
# === Yarn Version ===
|
||||
|
||||
if [[ -e /mnt/config/etc/yarn/versions.json ]]; then
|
||||
find /mnt/config/etc/yarn/versions.json -mtime +1 -delete
|
||||
fi
|
||||
if [[ ! -e /mnt/config/etc/yarn/versions.json ]]; then
|
||||
if [[ ! -d /mnt/config/etc/yarn ]]; then
|
||||
s6-setuidgid guardian mkdir -p /mnt/config/etc/yarn
|
||||
fi
|
||||
s6-setuidgid guardian wget -P /mnt/config/etc/yarn "https://maven.fabricmc.net/net/fabricmc/yarn/versions.json"
|
||||
fi
|
||||
|
||||
if [[ ! -z "${MINECRAFT_VERSION}" && -z "${FORGE_VERSION}" ]]; then
|
||||
YARN_VERSION="${MINECRAFT_VERSION}+build.$(jq -r --arg ver "$MINECRAFT_VERSION" '.[$ver][-1]' </mnt/config/etc/yarn/versions.json)"
|
||||
fi
|
||||
|
||||
# === Download MCUpdater ===
|
||||
|
||||
if [[ -e /mnt/config/bin/MCU-FastPack-latest.jar ]]; then
|
||||
find /mnt/config/www/minecraft/MCU-FastPack-latest.jar -mtime +7 -delete
|
||||
fi
|
||||
if [[ ! -e /mnt/config/bin/MCU-FastPack-latest.jar ]]; then
|
||||
if [[ ! -d /mnt/config/bin ]]; then
|
||||
s6-setuidgid guardian mkdir -p /mnt/config/bin
|
||||
fi
|
||||
s6-setuidgid guardian wget -P /mnt/config/bin "https://files.mcupdater.com/MCU-FastPack-latest.jar"
|
||||
fi
|
||||
|
||||
if [[ -e /mnt/config/www/minecraft/MCUpdater-latest.jar ]]; then
|
||||
find /mnt/config/www/minecraft/MCUpdater-latest.jar -mtime +7 -delete
|
||||
fi
|
||||
if [[ ! -e /mnt/config/www/minecraft/MCUpdater-latest.jar ]]; then
|
||||
if [[ ! -d /mnt/config/www/minecraft ]]; then
|
||||
s6-setuidgid guardian mkdir -p /mnt/config/www/minecraft
|
||||
fi
|
||||
s6-setuidgid guardian wget -P /mnt/config/www/minecraft "https://files.mcupdater.com/MCUpdater-latest.jar"
|
||||
fi
|
||||
|
||||
if [[ ! -e /mnt/config/www/minecraft/modpack.xsl ]]; then
|
||||
if [[ ! -d /mnt/config/www/minecraft ]]; then
|
||||
s6-setuidgid guardian mkdir -p /mnt/config/www/minecraft
|
||||
fi
|
||||
s6-setuidgid guardian wget -O /mnt/config/www/minecraft/modpack.xsl "https://raw.githubusercontent.com/MCUpdater/pack-optional/master/ServerPack.xsl"
|
||||
fi
|
||||
|
||||
# === Download Mod Loader ===
|
||||
|
||||
if [[ ! -d /mnt/config/data/server ]]; then
|
||||
s6-setuidgid guardian mkdir -p /mnt/config/data/server
|
||||
fi
|
||||
if [[ -d /mnt/config/data/server/mods ]]; then
|
||||
rm -rf /mnt/config/data/server/mods
|
||||
fi
|
||||
if [[ -d /mnt/config/data/server/scripts ]]; then
|
||||
rm -rf /mnt/config/data/server/scripts
|
||||
fi
|
||||
find /mnt/config/data/server -type l -delete
|
||||
|
||||
if [[ ! -z "${FABRIC_INSTALLER_VERSION}" ]]; then
|
||||
if [[ ! -e /mnt/config/bin/fabric-${MINECRAFT_VERSION}-${FABRIC_VERSION}.jar ]]; then
|
||||
if [[ ! -d /mnt/config/bin ]]; then
|
||||
s6-setuidgid guardian mkdir -p /mnt/config/bin
|
||||
fi
|
||||
s6-setuidgid guardian wget -O /mnt/config/bin/fabric-${MINECRAFT_VERSION}-${FABRIC_VERSION}.jar "https://meta.fabricmc.net/v2/versions/loader/${MINECRAFT_VERSION}/${FABRIC_VERSION}/${FABRIC_INSTALLER_VERSION}/server/jar"
|
||||
fi
|
||||
s6-setuidgid guardian ln -s /mnt/config/bin/fabric-${MINECRAFT_VERSION}-${FABRIC_VERSION}.jar /mnt/config/data/server/server-launcher.jar
|
||||
fi
|
||||
|
||||
# === Create Symlinks ===
|
||||
|
||||
if [[ ! -d /mnt/config/www/minecraft/modpack ]]; then
|
||||
s6-setuidgid guardian mkdir -p /mnt/config/www/minecraft/modpack
|
||||
fi
|
||||
|
||||
s6-setuidgid guardian mkdir -p /mnt/config/data/server/mods
|
||||
if [[ -d /mnt/config/www/minecraft/modpack/mods ]]; then
|
||||
s6-setuidgid guardian ln -s /mnt/config/www/minecraft/modpack/mods/* /mnt/config/data/server/mods/
|
||||
fi
|
||||
if [[ -d /mnt/config/www/minecraft/modpack/optional ]]; then
|
||||
s6-setuidgid guardian ln -s /mnt/config/www/minecraft/modpack/optional/* /mnt/config/data/server/mods/
|
||||
fi
|
||||
if [[ -d /mnt/config/www/minecraft/modpack/server ]]; then
|
||||
s6-setuidgid guardian ln -s /mnt/config/www/minecraft/modpack/server/* /mnt/config/data/server/mods/
|
||||
fi
|
||||
if [[ -d /mnt/config/data/modpack/mods ]]; then
|
||||
s6-setuidgid guardian ln -s /mnt/config/data/modpack/mods/* /mnt/config/data/server/mods/
|
||||
fi
|
||||
if [[ -d /mnt/config/data/modpack/optional ]]; then
|
||||
s6-setuidgid guardian ln -s /mnt/config/data/modpack/optional/* /mnt/config/data/server/mods/
|
||||
fi
|
||||
if [[ -d /mnt/config/data/modpack/server ]]; then
|
||||
s6-setuidgid guardian ln -s /mnt/config/data/modpack/server/* /mnt/config/data/server/mods/
|
||||
fi
|
||||
|
||||
if [[ ! -d /mnt/config/data/server/config ]]; then
|
||||
s6-setuidgid guardian mkdir -p /mnt/config/data/server/config
|
||||
fi
|
||||
if [[ -d /mnt/config/www/minecraft/modpack/config ]]; then
|
||||
s6-setuidgid guardian cp -R /mnt/config/www/minecraft/modpack/config/* /mnt/config/data/server/config/
|
||||
fi
|
||||
if [[ -d /mnt/config/data/modpack/config ]]; then
|
||||
s6-setuidgid guardian cp -R /mnt/config/data/modpack/config/* /mnt/config/data/server/config/
|
||||
fi
|
||||
|
||||
s6-setuidgid guardian mkdir -p /mnt/config/data/server/scripts
|
||||
if [[ -d /mnt/config/www/minecraft/modpack/scripts ]]; then
|
||||
s6-setuidgid guardian cp -R /mnt/config/www/minecraft/modpack/scripts/* /mnt/config/data/server/scripts/
|
||||
fi
|
||||
if [[ -d /mnt/config/data/modpack/scripts ]]; then
|
||||
s6-setuidgid guardian cp -R /mnt/config/data/modpack/scripts/* /mnt/config/data/server/scripts/
|
||||
fi
|
||||
|
||||
cd /mnt/config/data/server
|
||||
if [[ -d /mnt/config/www/minecraft/modpack/extract ]]; then
|
||||
s6-setuidgid guardian find /mnt/config/www/minecraft/modpack/extract/ -name '*.zip' -exec unzip -o {} \;
|
||||
fi
|
||||
if [[ -d /mnt/config/data/modpack/extract ]]; then
|
||||
s6-setuidgid guardian cp -R /mnt/config/data/modpack/extract/ -name '*.zip' -exec unzip -o {} \;
|
||||
fi
|
||||
if [[ ! -f /mnt/config/data/server/eula.txt ]]; then
|
||||
s6-setuidgid guardian java ${JAVA_OPTS} -jar server-launcher.jar nogui
|
||||
fi
|
||||
|
||||
# === Create Modpack ===
|
||||
|
||||
unset FASTPACK_PARAMS
|
||||
if [[ ! -z "${FORGE_VERSION}" ]]; then
|
||||
FASTPACK_PARAMS="${FASTPACK_PARAMS} --forge ${MINECRAFT_VERSION}-${FORGE_VERSION}"
|
||||
elif [[ ! -z "${FABRIC_VERSION}" ]]; then
|
||||
FASTPACK_PARAMS="${FASTPACK_PARAMS} --fabric ${FABRIC_VERSION}"
|
||||
fi
|
||||
if [[ -e /mnt/config/www/minecraft/modpack.xsl ]]; then
|
||||
FASTPACK_PARAMS="${FASTPACK_PARAMS} --xslt ${MODPACK_PUBLIC}/modpack.xsl"
|
||||
fi
|
||||
if [[ -e /mnt/config/www/minecraft/index.html ]]; then
|
||||
FASTPACK_PARAMS="${FASTPACK_PARAMS} --newsURL ${MODPACK_PUBLIC}/index.html"
|
||||
else
|
||||
FASTPACK_PARAMS="${FASTPACK_PARAMS} --newsURL ${MODPACK_PUBLIC}/modpack.xml"
|
||||
fi
|
||||
|
||||
cd /mnt/config/log
|
||||
s6-setuidgid guardian java -jar /mnt/config/bin/MCU-FastPack-latest.jar \
|
||||
--mcserver "${SERVER_PUBLIC}" --name "${SERVER_NAME}" \
|
||||
--baseURL "${MODPACK_PUBLIC}/modpack" --id "${MODPACK_NAME}" \
|
||||
--out "/mnt/config/www/minecraft/modpack.xml" --path "/mnt/config/www/minecraft/modpack" \
|
||||
--mc "${MINECRAFT_VERSION}"${FASTPACK_PARAMS} \
|
||||
--revision "$(date +'%F_%H%M')" --autoConnect false
|
||||
sed -i "s/yarn=latest/yarn=${YARN_VERSION}/g" /mnt/config/www/minecraft/modpack.xml
|
||||
sed -i "s/depends=\"cloth-config\"/depends=\"\"/g" /mnt/config/www/minecraft/modpack.xml
|
||||
sed -i 's/+/%2B/g' /mnt/config/www/minecraft/modpack.xml
|
|
@ -1,4 +0,0 @@
|
|||
/mnt/config/data/launcher true guardian:users,1000:100 0644 0755
|
||||
/mnt/config/data/modpack true guardian:users,1000:100 0644 0755
|
||||
/mnt/config/data/server true guardian:users,1000:100 0644 0755
|
||||
/mnt/config/www/minecraft true guardian:users,1000:100 0644 0755
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1 @@
|
|||
oneshot
|
|
@ -0,0 +1,2 @@
|
|||
#!/command/execlineb
|
||||
foreground { /command/with-contenv /bin/bash /usr/local/bin/fastpack }
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
#!/command/execlineb
|
||||
foreground { /bin/bash /usr/local/bin/minecraft-shutdown }
|
|
@ -0,0 +1 @@
|
|||
oneshot
|
|
@ -0,0 +1 @@
|
|||
#!/command/execlineb
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
#!/command/with-contenv /bin/bash
|
||||
|
||||
cd /mnt/config/data/server
|
||||
|
||||
if [[ ! -f /mnt/config/data/server/eula.txt ]]; then
|
||||
export HOME=/mnt/config/home
|
||||
/command/s6-setuidgid guardian /usr/bin/java ${JAVA_OPTS} -jar server-launcher.jar nogui
|
||||
fi
|
||||
while /bin/grep -q false eula.txt; do
|
||||
echo "please accept data/server/eula.txt..."
|
||||
sleep 30
|
||||
done
|
||||
|
||||
if [[ ! -f /mnt/config/data/server/eula.txt ]]; then
|
||||
exit 1
|
||||
fi
|
||||
if /bin/grep -q false eula.txt; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! /usr/bin/pgrep -f minedock >/dev/null; then
|
||||
export HOME=/mnt/config/home
|
||||
/command/s6-setuidgid guardian /usr/bin/screen -dmS minedock /usr/bin/java -Dlog4j2.formatMsgNoLookups=true ${JAVA_OPTS} -jar server-launcher.jar nogui;
|
||||
sleep 10
|
||||
fi
|
||||
while /usr/bin/pgrep -f minedock >/dev/null; do
|
||||
sleep 60
|
||||
done
|
|
@ -0,0 +1 @@
|
|||
longrun
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
cd /mnt/config/data/server
|
||||
while grep -q false eula.txt; do
|
||||
echo "please accept data/server/eula.txt..."
|
||||
sleep 30
|
||||
done
|
||||
if ! pgrep -f minedock >/dev/null; then
|
||||
s6-setuidgid guardian screen -dmS minedock java -Dlog4j2.formatMsgNoLookups=true ${JAVA_OPTS} -jar server-launcher.jar nogui;
|
||||
fi
|
||||
sleep 10
|
||||
while pgrep -f minedock >/dev/null; do
|
||||
sleep 30
|
||||
done
|
|
@ -0,0 +1,272 @@
|
|||
#!/command/with-contenv /bin/bash
|
||||
|
||||
if /usr/bin/pgrep -f minedock >/dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SERVER_NAME=${SERVER_NAME:-"custom"}
|
||||
MODPACK_NAME=${MODPACK_NAME:-"${SERVER_NAME}"}
|
||||
|
||||
if [[ -z "${SERVER_PUBLIC}" ]]; then
|
||||
if [[ -f /mnt/config/tmp/ipify ]]; then
|
||||
/usr/bin/find /mnt/config/tmp/ipify -mtime +1 -delete
|
||||
fi
|
||||
if [[ ! -f /mnt/config/tmp/ipify ]]; then
|
||||
if [[ ! -d /mnt/config/tmp ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/tmp
|
||||
fi
|
||||
/command/s6-setuidgid guardian /usr/bin/wget -q -O /mnt/config/tmp/ipify https://api.ipify.org/
|
||||
fi
|
||||
SERVER_PUBLIC=$(/bin/cat /mnt/config/tmp/ipify)
|
||||
fi
|
||||
MODPACK_PUBLIC=${MODPACK_PUBLIC:-"https://${SERVER_PUBLIC}"}
|
||||
|
||||
# === Default Minecraft Version ===
|
||||
|
||||
MINECRAFT_VERSION=${MINECRAFT_VERSION:-"release"}
|
||||
|
||||
if ! printf "$MINECRAFT_VERSION" | /bin/grep -q [0-9]; then
|
||||
if [[ -f /mnt/config/tmp/minecraft_manifest.json ]]; then
|
||||
/usr/bin/find /mnt/config/tmp/minecraft_manifest.json -mtime +1 -delete
|
||||
fi
|
||||
if [[ ! -f /mnt/config/tmp/minecraft_manifest.json ]]; then
|
||||
if [[ ! -d /mnt/config/tmp ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/tmp
|
||||
fi
|
||||
/command/s6-setuidgid guardian /usr/bin/wget -q -O /mnt/config/tmp/minecraft_manifest.json "https://launchermeta.mojang.com/mc/game/version_manifest.json"
|
||||
fi
|
||||
MINECRAFT_VERSION=$(/usr/bin/jq -r ".latest.${MINECRAFT_VERSION}" /mnt/config/tmp/minecraft_manifest.json)
|
||||
fi
|
||||
|
||||
# === Default Fabric Installer Version ===
|
||||
|
||||
FABRIC_INSTALLER_VERSION=${FABRIC_INSTALLER_VERSION:-"release"}
|
||||
|
||||
if ! printf "$FABRIC_INSTALLER_VERSION" | /bin/grep -q [0-9]; then
|
||||
if [[ -f /mnt/config/tmp/fabric-installer.xml ]]; then
|
||||
/usr/bin/find /mnt/config/tmp/fabric-installer.xml -mtime +1 -delete
|
||||
fi
|
||||
if [[ ! -f /mnt/config/tmp/fabric-installer.xml ]]; then
|
||||
if [[ ! -d /mnt/config/tmp ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/tmp
|
||||
fi
|
||||
/command/s6-setuidgid guardian /usr/bin/wget -q -O /mnt/config/tmp/fabric-installer.xml "https://maven.fabricmc.net/net/fabricmc/fabric-installer/maven-metadata.xml"
|
||||
fi
|
||||
FABRIC_INSTALLER_VERSION=$(/usr/bin/xmllint --xpath "metadata/versioning/${FABRIC_INSTALLER_VERSION}/text()" /mnt/config/tmp/fabric-installer.xml)
|
||||
fi
|
||||
|
||||
# === Default Fabric Loader Version ===
|
||||
|
||||
FABRIC_VERSION=${FABRIC_VERSION:-"release"}
|
||||
|
||||
if ! printf "$FABRIC_VERSION" | /bin/grep -q [0-9]; then
|
||||
if [[ -f /mnt/config/tmp/fabric-loader.xml ]]; then
|
||||
/usr/bin/find /mnt/config/tmp/fabric-loader.xml -mtime +1 -delete
|
||||
fi
|
||||
if [[ ! -f /mnt/config/tmp/fabric-loader.xml ]]; then
|
||||
if [[ ! -d /mnt/config/tmp ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/tmp
|
||||
fi
|
||||
/command/s6-setuidgid guardian /usr/bin/wget -q -O /mnt/config/tmp/fabric-loader.xml "https://maven.fabricmc.net/net/fabricmc/fabric-loader/maven-metadata.xml"
|
||||
fi
|
||||
FABRIC_VERSION=$(/usr/bin/xmllint --xpath "metadata/versioning/${FABRIC_VERSION}/text()" /mnt/config/tmp/fabric-loader.xml)
|
||||
fi
|
||||
|
||||
# === Default Yarn Version ===
|
||||
|
||||
if [[ -z "${YARN_VERSION}" ]]; then
|
||||
if [[ -f /mnt/config/tmp/yarn_versions.json ]]; then
|
||||
/usr/bin/find /mnt/config/tmp/yarn_versions.json -mtime +1 -delete
|
||||
fi
|
||||
if [[ ! -f /mnt/config/tmp/yarn_versions.json ]]; then
|
||||
if [[ ! -d /mnt/config/tmp ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/tmp
|
||||
fi
|
||||
/command/s6-setuidgid guardian /usr/bin/wget -q -O /mnt/config/tmp/yarn_versions.json "https://maven.fabricmc.net/net/fabricmc/yarn/versions.json"
|
||||
fi
|
||||
YARN_VERSION="${MINECRAFT_VERSION}+build.$(/usr/bin/jq -r --arg ver "$MINECRAFT_VERSION" '.[$ver][-1]' /mnt/config/tmp/yarn_versions.json)"
|
||||
fi
|
||||
|
||||
# === Download MCUpdater ===
|
||||
|
||||
if [[ -f /mnt/config/bin/MCU-FastPack.jar ]]; then
|
||||
/usr/bin/find /mnt/config/bin/MCU-FastPack.jar -mtime +7 -delete
|
||||
fi
|
||||
if [[ ! -f /mnt/config/bin/MCU-FastPack.jar ]]; then
|
||||
if [[ ! -d /mnt/config/bin ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/bin
|
||||
fi
|
||||
/command/s6-setuidgid guardian /usr/bin/wget -q -O /mnt/config/bin/MCU-FastPack.jar "https://files.mcupdater.com/MCU-FastPack-latest.jar"
|
||||
fi
|
||||
|
||||
if [[ -f /mnt/config/www/minecraft/MCUpdater.jar ]]; then
|
||||
/usr/bin/find /mnt/config/www/minecraft/MCUpdater.jar -mtime +7 -delete
|
||||
fi
|
||||
if [[ ! -f /mnt/config/www/minecraft/MCUpdater.jar ]]; then
|
||||
if [[ ! -d /mnt/config/www/minecraft ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/www/minecraft
|
||||
fi
|
||||
/command/s6-setuidgid guardian /usr/bin/wget -q -O /mnt/config/www/minecraft/MCUpdater.jar "https://files.mcupdater.com/MCUpdater-latest.jar"
|
||||
fi
|
||||
|
||||
if [[ -f /mnt/config/www/minecraft/ServerPack.xsl ]]; then
|
||||
/usr/bin/find /mnt/config/www/minecraft/ServerPack.xsl -mtime +7 -delete
|
||||
fi
|
||||
if [[ ! -f /mnt/config/www/minecraft/ServerPack.xsl ]]; then
|
||||
if [[ ! -d /mnt/config/www/minecraft ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/www/minecraft
|
||||
fi
|
||||
/command/s6-setuidgid guardian /usr/bin/wget -q -O /mnt/config/www/minecraft/ServerPack.xsl "https://raw.githubusercontent.com/MCUpdater/pack-optional/master/ServerPack.xsl"
|
||||
fi
|
||||
|
||||
# === Download Fabric Installer ===
|
||||
|
||||
if [[ ! -f /mnt/config/bin/fabric-${MINECRAFT_VERSION}-${FABRIC_VERSION}-${FABRIC_INSTALLER_VERSION}.jar ]]; then
|
||||
if [[ ! -d /mnt/config/bin ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/bin
|
||||
fi
|
||||
/command/s6-setuidgid guardian /usr/bin/wget -q -O /mnt/config/bin/fabric-${MINECRAFT_VERSION}-${FABRIC_VERSION}-${FABRIC_INSTALLER_VERSION}.jar "https://meta.fabricmc.net/v2/versions/loader/${MINECRAFT_VERSION}/${FABRIC_VERSION}/${FABRIC_INSTALLER_VERSION}/server/jar"
|
||||
fi
|
||||
|
||||
# === Create Modpack ===
|
||||
|
||||
if [[ ! -d /mnt/config/www/minecraft/modpack ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/www/minecraft/modpack
|
||||
fi
|
||||
|
||||
unset FASTPACK_PARAMS
|
||||
|
||||
if [[ ! -z "${FABRIC_VERSION}" ]]; then
|
||||
FASTPACK_PARAMS="${FASTPACK_PARAMS} --fabric ${FABRIC_VERSION}"
|
||||
fi
|
||||
if [[ ! -z "${YARN_VERSION}" ]]; then
|
||||
FASTPACK_PARAMS="${FASTPACK_PARAMS} --yarn ${YARN_VERSION}"
|
||||
fi
|
||||
|
||||
if [[ -f /mnt/config/www/minecraft/index.html ]]; then
|
||||
FASTPACK_PARAMS="${FASTPACK_PARAMS} --newsURL ${MODPACK_PUBLIC}/index.html"
|
||||
else
|
||||
FASTPACK_PARAMS="${FASTPACK_PARAMS} --newsURL ${MODPACK_PUBLIC}/modpack.xml"
|
||||
fi
|
||||
if [[ -f /mnt/config/www/minecraft/modpack.xsl ]]; then
|
||||
FASTPACK_PARAMS="${FASTPACK_PARAMS} --xslt ${MODPACK_PUBLIC}/modpack.xsl"
|
||||
elif [[ -f /mnt/config/www/minecraft/ServerPack.xsl ]]; then
|
||||
FASTPACK_PARAMS="${FASTPACK_PARAMS} --xslt ${MODPACK_PUBLIC}/ServerPack.xsl"
|
||||
fi
|
||||
|
||||
if [[ ! -d /mnt/config/log ]]; then
|
||||
/bin/mkdir -p /mnt/config/log
|
||||
fi
|
||||
cd /mnt/config/log
|
||||
|
||||
export HOME=/mnt/config/home
|
||||
/command/s6-setuidgid guardian /usr/bin/java -jar /mnt/config/bin/MCU-FastPack.jar \
|
||||
--mcserver "${SERVER_PUBLIC}" --name "${SERVER_NAME}" \
|
||||
--baseURL "${MODPACK_PUBLIC}/modpack" --id "${MODPACK_NAME}" \
|
||||
--out "/mnt/config/www/minecraft/modpack.xml" --path "/mnt/config/www/minecraft/modpack" \
|
||||
--mc "${MINECRAFT_VERSION}"${FASTPACK_PARAMS} \
|
||||
--revision "$(date +'%F_%H%M')" --autoConnect false
|
||||
/command/s6-setuidgid guardian /bin/sed -i 's/+/%2B/g' /mnt/config/www/minecraft/modpack.xml
|
||||
|
||||
# === Create Server Directory ===
|
||||
|
||||
if [[ ! -d /mnt/config/data/server ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/server
|
||||
fi
|
||||
|
||||
if [[ -d /mnt/config/data/server/mods ]]; then
|
||||
/bin/rm -rf /mnt/config/data/server/mods
|
||||
fi
|
||||
if [[ -d /mnt/config/data/server/scripts ]]; then
|
||||
/bin/rm -rf /mnt/config/data/server/scripts
|
||||
fi
|
||||
/usr/bin/find /mnt/config/data/server -type l -delete
|
||||
|
||||
/command/s6-setuidgid guardian /bin/ln -s /mnt/config/bin/fabric-${MINECRAFT_VERSION}-${FABRIC_VERSION}-${FABRIC_INSTALLER_VERSION}.jar /mnt/config/data/server/server-launcher.jar
|
||||
|
||||
# === Copy Mods ===
|
||||
|
||||
if [[ -d /mnt/config/www/minecraft/modpack/server ]]; then
|
||||
if [[ ! -d /mnt/config/data/server/mods ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/server/mods
|
||||
fi
|
||||
/command/s6-setuidgid guardian /bin/ln -s /mnt/config/www/minecraft/modpack/server/* /mnt/config/data/server/mods/
|
||||
fi
|
||||
|
||||
if [[ -d /mnt/config/www/minecraft/modpack/mods ]]; then
|
||||
if [[ ! -d /mnt/config/data/server/mods ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/server/mods
|
||||
fi
|
||||
/command/s6-setuidgid guardian /bin/ln -s /mnt/config/www/minecraft/modpack/mods/* /mnt/config/data/server/mods/
|
||||
fi
|
||||
|
||||
if [[ -d /mnt/config/www/minecraft/modpack/optional ]]; then
|
||||
if [[ ! -d /mnt/config/data/server/mods ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/server/mods
|
||||
fi
|
||||
/command/s6-setuidgid guardian /bin/ln -s /mnt/config/www/minecraft/modpack/optional/* /mnt/config/data/server/mods/
|
||||
fi
|
||||
|
||||
if [[ -d /mnt/config/data/modpack/server ]]; then
|
||||
if [[ ! -d /mnt/config/data/server/mods ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/server/mods
|
||||
fi
|
||||
/command/s6-setuidgid guardian /bin/ln -s /mnt/config/data/modpack/server/* /mnt/config/data/server/mods/
|
||||
fi
|
||||
|
||||
if [[ -d /mnt/config/data/modpack/mods ]]; then
|
||||
if [[ ! -d /mnt/config/data/server/mods ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/server/mods
|
||||
fi
|
||||
/command/s6-setuidgid guardian /bin/ln -s /mnt/config/data/modpack/mods/* /mnt/config/data/server/mods/
|
||||
fi
|
||||
|
||||
if [[ -d /mnt/config/data/modpack/optional ]]; then
|
||||
if [[ ! -d /mnt/config/data/server/mods ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/server/mods
|
||||
fi
|
||||
/command/s6-setuidgid guardian /bin/ln -s /mnt/config/data/modpack/optional/* /mnt/config/data/server/mods/
|
||||
fi
|
||||
|
||||
# === Copy Configs ===
|
||||
|
||||
if [[ -d /mnt/config/www/minecraft/modpack/config ]]; then
|
||||
if [[ ! -d /mnt/config/data/server/config ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/server/config
|
||||
fi
|
||||
/command/s6-setuidgid guardian /bin/cp -R /mnt/config/www/minecraft/modpack/config/* /mnt/config/data/server/config/
|
||||
fi
|
||||
|
||||
if [[ -d /mnt/config/data/modpack/config ]]; then
|
||||
if [[ ! -d /mnt/config/data/server/config ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/server/config
|
||||
fi
|
||||
/command/s6-setuidgid guardian /bin/cp -R /mnt/config/data/modpack/config/* /mnt/config/data/server/config/
|
||||
fi
|
||||
|
||||
# === Copy Scripts ===
|
||||
|
||||
if [[ -d /mnt/config/www/minecraft/modpack/scripts ]]; then
|
||||
if [[ ! -d /mnt/config/data/server/scripts ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/server/scripts
|
||||
fi
|
||||
/command/s6-setuidgid guardian /bin/cp -R /mnt/config/www/minecraft/modpack/scripts/* /mnt/config/data/server/scripts/
|
||||
fi
|
||||
|
||||
if [[ -d /mnt/config/data/modpack/scripts ]]; then
|
||||
if [[ ! -d /mnt/config/data/server/scripts ]]; then
|
||||
/command/s6-setuidgid guardian /bin/mkdir -p /mnt/config/data/server/scripts
|
||||
fi
|
||||
/command/s6-setuidgid guardian /bin/cp -R /mnt/config/data/modpack/scripts/* /mnt/config/data/server/scripts/
|
||||
fi
|
||||
|
||||
# === Extract Zips ===
|
||||
|
||||
cd /mnt/config/data/server
|
||||
|
||||
if [[ -d /mnt/config/www/minecraft/modpack/extract ]]; then
|
||||
/command/s6-setuidgid guardian /usr/bin/find /mnt/config/www/minecraft/modpack/extract/ -name '*.zip' -exec /usr/bin/unzip -o {} \;
|
||||
fi
|
||||
if [[ -d /mnt/config/data/modpack/extract ]]; then
|
||||
/command/s6-setuidgid guardian /usr/bin/find /mnt/config/data/modpack/extract/ -name '*.zip' -exec /usr/bin/unzip -o {} \;
|
||||
fi
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
if /usr/bin/pgrep -f minedock >/dev/null; then
|
||||
/command/s6-setuidgid guardian /usr/bin/screen -S minedock -X stuff "`echo -ne \"say MINECRAFT SERVER SHUTTING DOWN!\r\"`"
|
||||
/command/s6-setuidgid guardian /usr/bin/screen -S minedock -X stuff "`echo -ne \"save-all\r\"`"
|
||||
sleep 6
|
||||
/command/s6-setuidgid guardian /usr/bin/screen -S minedock -X stuff "`echo -ne \"stop\r\"`"
|
||||
fi
|
Reference in New Issue