From fe60ed03ab8b0fb0e043841602684121b7ed5bb4 Mon Sep 17 00:00:00 2001 From: fithwum Date: Tue, 28 Jul 2026 11:17:01 -0700 Subject: [PATCH] update add new start file --- latest/install_script.sh | 38 ++++++++++++++++++++++++++------------ latest/start.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 latest/start.sh diff --git a/latest/install_script.sh b/latest/install_script.sh index ffb7259..0b1c26d 100644 --- a/latest/install_script.sh +++ b/latest/install_script.sh @@ -7,6 +7,7 @@ VS_SERVER_DIR=/vs_server/server VS_DATA_DIR=/vs_server/server/data START_FILE=$VS_SERVER_DIR/server-$VS_VERSION.sh LOG_FILE=$VS_DATA_DIR/Logs/server-main.log +START_FILE=https://gitea.fithwum.tech/fithwum/vintage-story/raw/branch/main/latest/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 @@ -94,23 +95,36 @@ 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 && touch $MARKER_FILE + yes y | $VS_SERVER_DIR/server-1.21.5.sh setup $USERNAME $VS_DATA_DIR + touch $MARKER_FILE echo "Setup successfully completed." fi +# Download the start file for the screen session +if [ -f $VS_SERVER_DIR/start.sh ]; then + echo "INFO ! start.sh found ... moving on." +else + echo "WARNING ! start.sh missing ... downloading default file." + wget --no-cache --show-progress --progress=bar:force:noscroll $START_FILE -O $VS_SERVER_DIR/start.sh + chmod +x $VS_SERVER_DIR/start.sh +fi + # Run vintage-story server. -echo " " -echo "INFO ! Starting vintage-story Server $VS_VERSION" -.$VS_SERVER_DIR/server-$VS_VERSION.sh start +cd $VS_SERVER_DIR +exec ./start.sh -echo "Waiting for the server log file to be created..." -# Loop indefinitely until the log file actually exists on disk -until [ -f "$LOG_FILE" ]; do - sleep 1 -done +# echo " " +# echo "INFO ! Starting vintage-story Server $VS_VERSION" +# .$VS_SERVER_DIR/server-$VS_VERSION.sh start -echo "Log file found! Streaming server console now..." -# Hand off PID 1 to tail, keeping the container active permanently -exec tail -f "$LOG_FILE" +# echo "Waiting for the server log file to be created..." +# # Loop indefinitely until the log file actually exists on disk +# until [ -f "$LOG_FILE" ]; do +# sleep 1 +# done + +# echo "Log file found! Streaming server console now..." +# # Hand off PID 1 to tail, keeping the container active permanently +# exec tail -f "$LOG_FILE" exit \ No newline at end of file diff --git a/latest/start.sh b/latest/start.sh new file mode 100644 index 0000000..9b07a49 --- /dev/null +++ b/latest/start.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# Copyright (c) 2026 fithwum +# All rights reserved + +LOG_FILE=/vs_server/server/data/Logs/server-main.log +SESSION=server + +cd /vs_server/server + +echo "INFO ! A screen session for the Vintage-Story server is already running." +cleanup() { + echo "[INFO] Stopping Vintage-Story ..." + screen -S "$SESSION" -X $SESSION "stop$(printf '\r')" + # Wait up to 60 seconds + for i in {1..60}; do + if ! screen -list | grep -q "$SESSION"; then + break + fi + sleep 1 + done + # Kill it if it's still alive + screen -S "$SESSION" -X quit 2>/dev/null || true + exit 0 +} +trap cleanup SIGINT SIGTERM + +# Start the Minecraft server in a detached screen session +echo "INFO ! Starting Vintage-Story Server in a screen session." +touch "$LOG_FILE" +screen -L -Logfile "$LOG_FILE" -dmS "$SESSION" bash -c ./VintagestoryServer.dll +exec tail -F "$LOG_FILE" \ No newline at end of file