ground-zero-conflict-config.../scripts/update.sh
2025-07-01 00:17:42 -04:00

48 lines
1.7 KiB
Bash
Executable file

#!/bin/sh
set -e
server_root_path="/home/speccon18/Documents/code/test/reforger"
config_path="$server_root_path/Configs"
start_script_path="$server_root_path/start.sh"
steamcmd_script_path="./reforger_update"
# Step 1: Download updater script if missing
if [ ! -f "$steamcmd_script_path" ]; then
echo "Downloading reforger_update script..."
curl -L -o "$steamcmd_script_path" "https://git.skdevstudios.com/SK-Development-Studios/Ground-Zero-Conflict-Configuration/raw/branch/main/scripts/reforger_update"
chmod +x "$steamcmd_script_path"
fi
# Step 2: Missing files — download, run steamcmd, move into root
if [ ! -d "$config_path" ] || [ ! -f "$start_script_path" ]; then
echo "Missing Configs/ or start.sh in server root."
# Download locally
curl -L -o ./start.sh "https://git.skdevstudios.com/SK-Development-Studios/Ground-Zero-Conflict-Configuration/raw/branch/main/scripts/start.sh"
chmod +x ./start.sh
mkdir -p ./Configs
curl -L -o ./Configs/default.json "https://git.skdevstudios.com/SK-Development-Studios/Ground-Zero-Conflict-Configuration/raw/branch/main/Configs/default.json"
# Run steamcmd (creates root if needed)
echo "Running steamcmd to initialize server files..."
steamcmd +runscript "$(pwd)/reforger_update"
# Then move into root
echo "Moving downloaded files into server root..."
mv ./start.sh "$server_root_path/"
mv ./Configs "$server_root_path/"
# Step 3: Files already exist — move out, update, move back in
else
echo "Found existing Configs/ and start.sh. Backing them up..."
mv "$start_script_path" ./start.sh
mv "$config_path" ./Configs
steamcmd +runscript "$(pwd)/reforger_update"
mv ./start.sh "$server_root_path/"
mv ./Configs "$server_root_path/"
fi