updates to add auto update
vintage-story-build-latest / Docker prune (vm-docker-build2) (push) Successful in 52s
vintage-story-build-testing / Docker prune (vm-docker-build2) (push) Successful in 59s
vintage-story-build-latest / Build and Push latest (push) Successful in 1m6s
vintage-story-build-testing / Build and Push testing (push) Successful in 1m4s
vintage-story-build-latest / generate-changelogs (push) Successful in 9s
vintage-story-build-testing / generate-changelogs (push) Successful in 8s
vintage-story-build-latest / generate-build-info (push) Successful in 10s
vintage-story-build-testing / generate-build-info (push) Successful in 11s

This commit is contained in:
2026-07-29 09:08:51 -07:00
parent f5ede67568
commit 74cd0b5bb2
2 changed files with 121 additions and 47 deletions
+62 -25
View File
@@ -6,8 +6,8 @@ VS_SERVER_DIR=/vs_server/server
VS_DATA_DIR=/vs_server/server/data
LOG_FILE=$VS_DATA_DIR/Logs/server-main.log
MARKER_FILE=$VS_SERVER_DIR/.setup_done
START_FILE_1=$VS_SERVER_DIR/server-$VS_VERSION.sh
VS_SERVER_FILE=https://cdn.vintagestory.at/gamefiles/$VS_CHANNEL/vs_server_linux-x64_$VS_VERSION.tar.gz
INSTALLED_VERSION=$VS_SERVER_DIR/installed-$TARGET_VERSION
START_FILE=$VS_SERVER_DIR/server.sh
MS_REPO_URL=https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb
USERNAME=adduser vintagestory
@@ -59,33 +59,70 @@ else
sleep infinity
fi
# Main install (Debian).
# Main install & auto update.
# Check for server files and download if needed.
if [ -e $START_FILE_1 ]
then
# Fallback to stable channel if VS_CHANNEL is blank
: "${VS_CHANNEL:=stable}"
echo "Using channel: $VS_CHANNEL"
# Get the currently installed version from filesystem
CUR_V=$(find "$VS_SERVER_DIR" -name "installed-*" | cut -d - -f2-)
echo "Current local version: '${CUR_V:-None}'"
# Fetch the API JSON cleanly
API_URL="http://api.vintagestory.at/${VS_CHANNEL}.json"
JSON=$(wget -qO- "$API_URL")
# Validate that we actually received valid JSON
if [ -z "$JSON" ] || ! echo "$JSON" | jq . >/dev/null 2>&1; then
echo "Error: Failed to fetch valid JSON from $API_URL"
exit 1
fi
# Resolve the target version dynamically from the JSON Object keys
if [ ! -z "$VS_VERSION" ] && [ "$VS_VERSION" != "latest" ]; then
# User specified an exact version. Check if it exists as a key in the object
TARGET_VERSION=$(echo "$JSON" | jq -r --arg version "$VS_VERSION" 'if .[$version] then $version else "" end')
if [ -z "$TARGET_VERSION" ]; then
echo "Error: Specified version '$VS_VERSION' not found in the $VS_CHANNEL channel API."
exit 1
fi
else
# No version specified or "latest" chosen. Get the very first key from the object
TARGET_VERSION=$(echo "$JSON" | jq -r 'keys_unsorted | .[0]')
fi
echo "Target version determined: '$TARGET_VERSION'"
# Compare versions and only download if they do NOT match
if [ "$CUR_V" != "$TARGET_VERSION" ]; then
echo "Versions differ ($CUR_V vs $TARGET_VERSION). Fetching CDN download URL..."
# Extract the CDN download link using the valid object key structure
VS_SERVER_FILE=$(echo "$JSON" | jq -r --arg version "$TARGET_VERSION" '.[$version].linuxserver.urls.cdn')
if [ "$VS_SERVER_FILE" == "null" ] || [ -z "$VS_SERVER_FILE" ]; then
echo "Error: Download URL not found for version $TARGET_VERSION"
exit 1
fi
echo "Ready to download: $VS_SERVER_FILE"
echo " "
echo "INFO ! server-$VS_VERSION.sh found starting now."
else
echo " "
echo "WARNING ! server-$VS_VERSION.sh is out of date/missing ... will download now."
echo " "
echo "INFO ! Cleaning old files."
mkdir -pv $VS_SERVER_DIR/old-server-versions/
mv *.sh $VS_SERVER_DIR/old-server-versions/
rm -fr $VS_SERVER_DIR/assets $VS_SERVER_DIR/Lib $VS_SERVER_DIR/Mods
rm -fr $VS_SERVER_DIR/VintagestoryServer $VS_SERVER_DIR/*.dll $VS_SERVER_DIR/*.pdb $VS_SERVER_DIR/*.json $VS_SERVER_DIR/*.xml $VS_SERVER_DIR/*.txt
wget --no-cache --show-progress --progress=bar:force:noscroll $VS_SERVER_FILE -O /vstemp/vs_server_linux-x64_$VS_VERSION.tar.gz
tar -xzf /vstemp/vs_server_linux-x64_$VS_VERSION.tar.gz -C /vstemp/files
rm -fr /vstemp/*.tar.gz
mv -uf /vstemp/files/* $VS_SERVER_DIR/
mv $VS_SERVER_DIR/server.sh $START_FILE_1
chmod +x $START_FILE_1
echo "INFO ! Cleaning old files."
mkdir -pv $VS_SERVER_DIR/old-server-versions/
mv *.sh $VS_SERVER_DIR/old-server-versions/
rm -fr $VS_SERVER_DIR/assets $VS_SERVER_DIR/Lib $VS_SERVER_DIR/Mods
rm -fr $VS_SERVER_DIR/VintagestoryServer $VS_SERVER_DIR/*.dll $VS_SERVER_DIR/*.pdb $VS_SERVER_DIR/*.json $VS_SERVER_DIR/*.xml $VS_SERVER_DIR/*.txt
wget --no-cache --show-progress --progress=bar:force:noscroll $VS_SERVER_FILE -O /vstemp/vs_server_linux-x64_$TARGET_VERSION.tar.gz
tar -xzf /vstemp/vs_server_linux-x64_$TARGET_VERSION.tar.gz -C /vstemp/files
rm -fr /vstemp/*.tar.gz
mv -uf /vstemp/files/* $VS_SERVER_DIR/
chmod +x $START_FILE
touch $INSTALLED_VERSION
else
echo "No update required. Local version matches target version."
fi
echo "INFO ! Setting server path."
sed -i -E "s|^VSPATH='/home/vintagestory/server'|VSPATH='$VS_SERVER_DIR'|" $START_FILE_1
sed -i -E "s|^VSPATH='/home/vintagestory/server'|VSPATH='$VS_SERVER_DIR'|" $START_FILE
echo "INFO ! Setting data path."
sed -i -E "s|^DATAPATH='/var/vintagestory/data'|DATAPATH='$VS_DATA_DIR'|" $START_FILE_1
sed -i -E "s|^DATAPATH='/var/vintagestory/data'|DATAPATH='$VS_DATA_DIR'|" $START_FILE
# Set permissions.
chown 99:100 -R $VS_SERVER_DIR
@@ -94,7 +131,7 @@ chmod 776 -R $VS_SERVER_DIR
# Setup the server
if [ ! -f $MARKER_FILE ]; then
echo "First time run: Setting up server environment..."
yes y | $VS_SERVER_DIR/server-1.21.5.sh setup $USERNAME $VS_DATA_DIR
yes y | $VS_SERVER_DIR/server.sh setup $USERNAME $VS_DATA_DIR
touch $MARKER_FILE
echo "Setup successfully completed."
fi
@@ -102,7 +139,7 @@ fi
# Run vintage-story server.
echo " "
echo "INFO ! Starting vintage-story Server $VS_VERSION"
.$START_FILE_1 start
.$START_FILE start
echo "Waiting for the server log file to be created..."
# Loop indefinitely until the log file actually exists on disk
+59 -22
View File
@@ -6,9 +6,9 @@ VS_SERVER_DIR=/vs_server/server
VS_DATA_DIR=/vs_server/server/data
LOG_FILE=$VS_DATA_DIR/Logs/server-main.log
MARKER_FILE=$VS_SERVER_DIR/.setup_done
START_FILE_1=$VS_SERVER_DIR/server-$VS_VERSION.sh
INSTALLED_VERSION=$VS_SERVER_DIR/installed-$TARGET_VERSION
START_FILE_1=$VS_SERVER_DIR/server.sh
START_FILE_2=https://gitea.fithwum.tech/fithwum/vintage-story/raw/branch/main/testing/start.sh
VS_SERVER_FILE=https://cdn.vintagestory.at/gamefiles/$VS_CHANNEL/vs_server_linux-x64_$VS_VERSION.tar.gz
MS_REPO_URL=https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb
USERNAME=adduser vintagestory
@@ -60,27 +60,64 @@ else
sleep infinity
fi
# Main install (Debian).
# Main install & auto update.
# Check for server files and download if needed.
if [ -e $START_FILE_1 ]
then
# Fallback to stable channel if VS_CHANNEL is blank
: "${VS_CHANNEL:=stable}"
echo "Using channel: $VS_CHANNEL"
# Get the currently installed version from filesystem
CUR_V=$(find "$VS_SERVER_DIR" -name "installed-*" | cut -d - -f2-)
echo "Current local version: '${CUR_V:-None}'"
# Fetch the API JSON cleanly
API_URL="http://api.vintagestory.at/${VS_CHANNEL}.json"
JSON=$(wget -qO- "$API_URL")
# Validate that we actually received valid JSON
if [ -z "$JSON" ] || ! echo "$JSON" | jq . >/dev/null 2>&1; then
echo "Error: Failed to fetch valid JSON from $API_URL"
exit 1
fi
# Resolve the target version dynamically from the JSON Object keys
if [ ! -z "$VS_VERSION" ] && [ "$VS_VERSION" != "latest" ]; then
# User specified an exact version. Check if it exists as a key in the object
TARGET_VERSION=$(echo "$JSON" | jq -r --arg version "$VS_VERSION" 'if .[$version] then $version else "" end')
if [ -z "$TARGET_VERSION" ]; then
echo "Error: Specified version '$VS_VERSION' not found in the $VS_CHANNEL channel API."
exit 1
fi
else
# No version specified or "latest" chosen. Get the very first key from the object
TARGET_VERSION=$(echo "$JSON" | jq -r 'keys_unsorted | .[0]')
fi
echo "Target version determined: '$TARGET_VERSION'"
# Compare versions and only download if they do NOT match
if [ "$CUR_V" != "$TARGET_VERSION" ]; then
echo "Versions differ ($CUR_V vs $TARGET_VERSION). Fetching CDN download URL..."
# Extract the CDN download link using the valid object key structure
VS_SERVER_FILE=$(echo "$JSON" | jq -r --arg version "$TARGET_VERSION" '.[$version].linuxserver.urls.cdn')
if [ "$VS_SERVER_FILE" == "null" ] || [ -z "$VS_SERVER_FILE" ]; then
echo "Error: Download URL not found for version $TARGET_VERSION"
exit 1
fi
echo "Ready to download: $VS_SERVER_FILE"
echo " "
echo "INFO ! server-$VS_VERSION.sh found starting now."
else
echo " "
echo "WARNING ! server-$VS_VERSION.sh is out of date/missing ... will download now."
echo " "
echo "INFO ! Cleaning old files."
mkdir -pv $VS_SERVER_DIR/old-server-versions/
mv *.sh $VS_SERVER_DIR/old-server-versions/
rm -fr $VS_SERVER_DIR/assets $VS_SERVER_DIR/Lib $VS_SERVER_DIR/Mods
rm -fr $VS_SERVER_DIR/VintagestoryServer $VS_SERVER_DIR/*.dll $VS_SERVER_DIR/*.pdb $VS_SERVER_DIR/*.json $VS_SERVER_DIR/*.xml $VS_SERVER_DIR/*.txt
wget --no-cache --show-progress --progress=bar:force:noscroll $VS_SERVER_FILE -O /vstemp/vs_server_linux-x64_$VS_VERSION.tar.gz
tar -xzf /vstemp/vs_server_linux-x64_$VS_VERSION.tar.gz -C /vstemp/files
rm -fr /vstemp/*.tar.gz
mv -uf /vstemp/files/* $VS_SERVER_DIR/
mv $VS_SERVER_DIR/server.sh $START_FILE_1
chmod +x $START_FILE_1
echo "INFO ! Cleaning old files."
mkdir -pv $VS_SERVER_DIR/old-server-versions/
mv *.sh $VS_SERVER_DIR/old-server-versions/
rm -fr $VS_SERVER_DIR/assets $VS_SERVER_DIR/Lib $VS_SERVER_DIR/Mods
rm -fr $VS_SERVER_DIR/VintagestoryServer $VS_SERVER_DIR/*.dll $VS_SERVER_DIR/*.pdb $VS_SERVER_DIR/*.json $VS_SERVER_DIR/*.xml $VS_SERVER_DIR/*.txt
wget --no-cache --show-progress --progress=bar:force:noscroll $VS_SERVER_FILE -O /vstemp/vs_server_linux-x64_$TARGET_VERSION.tar.gz
tar -xzf /vstemp/vs_server_linux-x64_$TARGET_VERSION.tar.gz -C /vstemp/files
rm -fr /vstemp/*.tar.gz
mv -uf /vstemp/files/* $VS_SERVER_DIR/
chmod +x $START_FILE_1
touch $INSTALLED_VERSION
else
echo "No update required. Local version matches target version."
fi
echo "INFO ! Setting server path."
@@ -95,7 +132,7 @@ chmod 776 -R $VS_SERVER_DIR
# Setup the server
if [ ! -f $MARKER_FILE ]; then
echo "First time run: Setting up server environment..."
yes y | $VS_SERVER_DIR/server-1.21.5.sh setup $USERNAME $VS_DATA_DIR
yes y | $VS_SERVER_DIR/server.sh setup $USERNAME $VS_DATA_DIR
touch $MARKER_FILE
echo "Setup successfully completed."
fi