Initial PropHunt server setup
- Complete bare metal installer with SteamCMD, MetaMod, SourceMod, ULX - Docker installer with one-liner support - Server configuration files (server.cfg, autoexec.cfg, mount.cfg) - Update script for easy maintenance - Backup script for server data - Workshop collection documentation - SourceMod admin configuration template
This commit is contained in:
153
scripts/update.sh
Executable file
153
scripts/update.sh
Executable file
@@ -0,0 +1,153 @@
|
||||
#!/bin/bash
|
||||
#===============================================================================
|
||||
# Garry's Mod PropHunt Server - Update Script
|
||||
#===============================================================================
|
||||
|
||||
INSTALL_DIR="${GMOD_INSTALL_DIR:-/home/gmod}"
|
||||
SERVER_DIR="${INSTALL_DIR}/serverfiles"
|
||||
STEAMCMD_DIR="${INSTALL_DIR}/steamcmd"
|
||||
REPO_DIR="${INSTALL_DIR}/gmod-prophunt-server"
|
||||
REPO_URL="https://git.vish.gg/Vish/gmod-prophunt-server.git"
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
||||
log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
|
||||
log_warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
|
||||
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
echo -e "${GREEN}"
|
||||
echo "╔═══════════════════════════════════════════════════════════════╗"
|
||||
echo "║ 🔄 Garry's Mod PropHunt Update Script 🔄 ║"
|
||||
echo "╚═══════════════════════════════════════════════════════════════╝"
|
||||
echo -e "${NC}"
|
||||
|
||||
# Check for running server
|
||||
if pgrep -f "srcds_linux.*garrysmod" > /dev/null; then
|
||||
log_warning "Server appears to be running. Stop it before updating."
|
||||
read -p "Stop server and continue? (y/N): " confirm
|
||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
||||
pkill -f "srcds_linux.*garrysmod"
|
||||
sleep 5
|
||||
else
|
||||
log_info "Update cancelled."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Update Garry's Mod Server
|
||||
log_info "Updating Garry's Mod server..."
|
||||
cd "$STEAMCMD_DIR"
|
||||
./steamcmd.sh +force_install_dir "$SERVER_DIR" \
|
||||
+login anonymous \
|
||||
+app_update 4020 validate \
|
||||
+quit
|
||||
|
||||
if [[ $? -eq 0 ]]; then
|
||||
log_success "Garry's Mod server updated."
|
||||
else
|
||||
log_error "Failed to update Garry's Mod server."
|
||||
fi
|
||||
|
||||
# Update configuration repository
|
||||
log_info "Updating configuration repository..."
|
||||
if [[ -d "$REPO_DIR/.git" ]]; then
|
||||
cd "$REPO_DIR"
|
||||
git pull
|
||||
else
|
||||
rm -rf "$REPO_DIR"
|
||||
git clone "$REPO_URL" "$REPO_DIR"
|
||||
fi
|
||||
log_success "Configuration repository updated."
|
||||
|
||||
# Update MetaMod
|
||||
log_info "Checking for MetaMod updates..."
|
||||
cd /tmp
|
||||
METAMOD_LATEST=$(curl -s "https://mms.alliedmods.net/mmsdrop/1.11/" | grep -oP 'mmsource-[\d.]+-git\d+-linux\.tar\.gz' | tail -1)
|
||||
if [[ -n "$METAMOD_LATEST" ]]; then
|
||||
wget -q "https://mms.alliedmods.net/mmsdrop/1.11/${METAMOD_LATEST}" -O metamod.tar.gz
|
||||
if [[ -f metamod.tar.gz ]]; then
|
||||
tar -xzf metamod.tar.gz -C "$SERVER_DIR/garrysmod/"
|
||||
rm metamod.tar.gz
|
||||
log_success "MetaMod updated: $METAMOD_LATEST"
|
||||
fi
|
||||
else
|
||||
log_warning "Could not determine latest MetaMod version."
|
||||
fi
|
||||
|
||||
# Update SourceMod
|
||||
log_info "Checking for SourceMod updates..."
|
||||
SOURCEMOD_LATEST=$(curl -s "https://sm.alliedmods.net/smdrop/1.11/" | grep -oP 'sourcemod-[\d.]+-git\d+-linux\.tar\.gz' | tail -1)
|
||||
if [[ -n "$SOURCEMOD_LATEST" ]]; then
|
||||
wget -q "https://sm.alliedmods.net/smdrop/1.11/${SOURCEMOD_LATEST}" -O sourcemod.tar.gz
|
||||
if [[ -f sourcemod.tar.gz ]]; then
|
||||
tar -xzf sourcemod.tar.gz -C "$SERVER_DIR/garrysmod/"
|
||||
rm sourcemod.tar.gz
|
||||
log_success "SourceMod updated: $SOURCEMOD_LATEST"
|
||||
fi
|
||||
else
|
||||
log_warning "Could not determine latest SourceMod version."
|
||||
fi
|
||||
|
||||
# Update ULib and ULX
|
||||
log_info "Updating ULX Admin System..."
|
||||
cd /tmp
|
||||
|
||||
# Backup existing ULX data
|
||||
if [[ -d "$SERVER_DIR/garrysmod/addons/ulx/data" ]]; then
|
||||
cp -r "$SERVER_DIR/garrysmod/addons/ulx/data" /tmp/ulx_data_backup
|
||||
fi
|
||||
if [[ -d "$SERVER_DIR/garrysmod/addons/ulib/data" ]]; then
|
||||
cp -r "$SERVER_DIR/garrysmod/addons/ulib/data" /tmp/ulib_data_backup
|
||||
fi
|
||||
|
||||
# Update ULib
|
||||
rm -rf "$SERVER_DIR/garrysmod/addons/ulib"
|
||||
wget -q "https://github.com/TeamUlysses/ulib/archive/refs/heads/master.zip" -O ulib.zip
|
||||
if [[ -f ulib.zip ]]; then
|
||||
unzip -q ulib.zip -d "$SERVER_DIR/garrysmod/addons/"
|
||||
mv "$SERVER_DIR/garrysmod/addons/ulib-master" "$SERVER_DIR/garrysmod/addons/ulib"
|
||||
rm ulib.zip
|
||||
fi
|
||||
|
||||
# Update ULX
|
||||
rm -rf "$SERVER_DIR/garrysmod/addons/ulx"
|
||||
wget -q "https://github.com/TeamUlysses/ulx/archive/refs/heads/master.zip" -O ulx.zip
|
||||
if [[ -f ulx.zip ]]; then
|
||||
unzip -q ulx.zip -d "$SERVER_DIR/garrysmod/addons/"
|
||||
mv "$SERVER_DIR/garrysmod/addons/ulx-master" "$SERVER_DIR/garrysmod/addons/ulx"
|
||||
rm ulx.zip
|
||||
fi
|
||||
|
||||
# Restore ULX data
|
||||
if [[ -d /tmp/ulx_data_backup ]]; then
|
||||
cp -r /tmp/ulx_data_backup/* "$SERVER_DIR/garrysmod/addons/ulx/data/" 2>/dev/null || true
|
||||
rm -rf /tmp/ulx_data_backup
|
||||
fi
|
||||
if [[ -d /tmp/ulib_data_backup ]]; then
|
||||
cp -r /tmp/ulib_data_backup/* "$SERVER_DIR/garrysmod/addons/ulib/data/" 2>/dev/null || true
|
||||
rm -rf /tmp/ulib_data_backup
|
||||
fi
|
||||
|
||||
log_success "ULX Admin System updated."
|
||||
|
||||
# Apply updated configs (optional - commented to preserve user changes)
|
||||
# log_info "Applying configuration updates..."
|
||||
# if [[ -d "$REPO_DIR/cfg" ]]; then
|
||||
# cp -r "$REPO_DIR/cfg/"* "$SERVER_DIR/garrysmod/cfg/"
|
||||
# fi
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}"
|
||||
echo "╔═══════════════════════════════════════════════════════════════╗"
|
||||
echo "║ ✅ Update Complete! ✅ ║"
|
||||
echo "╚═══════════════════════════════════════════════════════════════╝"
|
||||
echo -e "${NC}"
|
||||
echo ""
|
||||
echo "Restart the server to apply changes:"
|
||||
echo " $INSTALL_DIR/start.sh"
|
||||
echo ""
|
||||
Reference in New Issue
Block a user