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:
76
scripts/backup.sh
Executable file
76
scripts/backup.sh
Executable file
@@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
#===============================================================================
|
||||
# Garry's Mod PropHunt Server - Backup Script
|
||||
#===============================================================================
|
||||
|
||||
INSTALL_DIR="${GMOD_INSTALL_DIR:-/home/gmod}"
|
||||
SERVER_DIR="${INSTALL_DIR}/serverfiles"
|
||||
BACKUP_DIR="${BACKUP_DIR:-/home/gmod/backups}"
|
||||
DATE=$(date +%Y%m%d_%H%M%S)
|
||||
BACKUP_NAME="gmod_prophunt_backup_${DATE}.tar.gz"
|
||||
|
||||
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"; }
|
||||
|
||||
echo -e "${GREEN}"
|
||||
echo "╔═══════════════════════════════════════════════════════════════╗"
|
||||
echo "║ 💾 Garry's Mod PropHunt Backup Script 💾 ║"
|
||||
echo "╚═══════════════════════════════════════════════════════════════╝"
|
||||
echo -e "${NC}"
|
||||
|
||||
# Create backup directory
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
|
||||
log_info "Creating backup..."
|
||||
|
||||
# Items to backup
|
||||
BACKUP_ITEMS=(
|
||||
"$SERVER_DIR/garrysmod/cfg"
|
||||
"$SERVER_DIR/garrysmod/data"
|
||||
"$SERVER_DIR/garrysmod/addons/ulib"
|
||||
"$SERVER_DIR/garrysmod/addons/ulx"
|
||||
"$SERVER_DIR/garrysmod/addons/sourcemod/configs"
|
||||
"$SERVER_DIR/garrysmod/addons/sourcemod/data"
|
||||
)
|
||||
|
||||
# Create temporary directory for backup
|
||||
TEMP_BACKUP="/tmp/gmod_backup_${DATE}"
|
||||
mkdir -p "$TEMP_BACKUP"
|
||||
|
||||
# Copy files to temp directory
|
||||
for item in "${BACKUP_ITEMS[@]}"; do
|
||||
if [[ -e "$item" ]]; then
|
||||
cp -r "$item" "$TEMP_BACKUP/" 2>/dev/null
|
||||
fi
|
||||
done
|
||||
|
||||
# Create compressed archive
|
||||
cd /tmp
|
||||
tar -czf "$BACKUP_DIR/$BACKUP_NAME" "gmod_backup_${DATE}"
|
||||
|
||||
# Cleanup temp directory
|
||||
rm -rf "$TEMP_BACKUP"
|
||||
|
||||
# Keep only last 7 backups
|
||||
cd "$BACKUP_DIR"
|
||||
ls -t gmod_prophunt_backup_*.tar.gz | tail -n +8 | xargs -r rm
|
||||
|
||||
log_success "Backup created: $BACKUP_DIR/$BACKUP_NAME"
|
||||
|
||||
# Show backup size
|
||||
BACKUP_SIZE=$(du -h "$BACKUP_DIR/$BACKUP_NAME" | cut -f1)
|
||||
echo ""
|
||||
echo -e "${BLUE}Backup Details:${NC}"
|
||||
echo " • Location: $BACKUP_DIR/$BACKUP_NAME"
|
||||
echo " • Size: $BACKUP_SIZE"
|
||||
echo ""
|
||||
|
||||
# List recent backups
|
||||
echo -e "${BLUE}Recent Backups:${NC}"
|
||||
ls -lh "$BACKUP_DIR"/*.tar.gz 2>/dev/null | tail -5
|
||||
88
scripts/docker-entrypoint.sh
Executable file
88
scripts/docker-entrypoint.sh
Executable file
@@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
#===============================================================================
|
||||
# Garry's Mod PropHunt Server - Docker Entrypoint
|
||||
#===============================================================================
|
||||
|
||||
SERVER_DIR="${GMOD_INSTALL_DIR:-/home/gmod}/serverfiles"
|
||||
STEAMCMD_DIR="${GMOD_INSTALL_DIR:-/home/gmod}/steamcmd"
|
||||
|
||||
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"; }
|
||||
|
||||
echo -e "${GREEN}"
|
||||
echo "╔═══════════════════════════════════════════════════════════════╗"
|
||||
echo "║ 🎮 Garry's Mod PropHunt Server Starting 🎮 ║"
|
||||
echo "╚═══════════════════════════════════════════════════════════════╝"
|
||||
echo -e "${NC}"
|
||||
|
||||
# Update server if AUTO_UPDATE is set
|
||||
if [[ "${AUTO_UPDATE:-false}" == "true" ]]; then
|
||||
log_info "Checking for server updates..."
|
||||
cd "$STEAMCMD_DIR"
|
||||
./steamcmd.sh +force_install_dir "$SERVER_DIR" \
|
||||
+login anonymous \
|
||||
+app_update 4020 \
|
||||
+quit
|
||||
fi
|
||||
|
||||
cd "$SERVER_DIR"
|
||||
|
||||
# Build command line arguments
|
||||
ARGS="-game garrysmod"
|
||||
ARGS="$ARGS -console"
|
||||
ARGS="$ARGS -port ${PORT:-27015}"
|
||||
ARGS="$ARGS +maxplayers ${MAX_PLAYERS:-24}"
|
||||
ARGS="$ARGS +map ${MAP:-gm_construct}"
|
||||
ARGS="$ARGS +gamemode ${GAMEMODE:-prop_hunt}"
|
||||
ARGS="$ARGS -tickrate ${TICKRATE:-66}"
|
||||
ARGS="$ARGS +hostname \"${SERVER_NAME:-PropHunt Server}\""
|
||||
|
||||
# Add Steam token if provided
|
||||
if [[ -n "$SRCDS_TOKEN" ]]; then
|
||||
ARGS="$ARGS +sv_setsteamaccount $SRCDS_TOKEN"
|
||||
log_success "Steam token configured."
|
||||
else
|
||||
log_warning "No SRCDS_TOKEN set. Server won't be listed publicly."
|
||||
log_warning "Get a token at: https://steamcommunity.com/dev/managegameservers"
|
||||
fi
|
||||
|
||||
# Add RCON password
|
||||
if [[ -n "$RCON_PASSWORD" && "$RCON_PASSWORD" != "changeme" ]]; then
|
||||
ARGS="$ARGS +rcon_password \"$RCON_PASSWORD\""
|
||||
fi
|
||||
|
||||
# Add workshop collection if provided
|
||||
if [[ -n "$WORKSHOP_COLLECTION" ]]; then
|
||||
ARGS="$ARGS +host_workshop_collection $WORKSHOP_COLLECTION"
|
||||
log_info "Workshop collection: $WORKSHOP_COLLECTION"
|
||||
fi
|
||||
|
||||
# Display configuration
|
||||
echo ""
|
||||
log_info "Server Configuration:"
|
||||
echo " • Server Name: ${SERVER_NAME:-PropHunt Server}"
|
||||
echo " • Map: ${MAP:-gm_construct}"
|
||||
echo " • Max Players: ${MAX_PLAYERS:-24}"
|
||||
echo " • Port: ${PORT:-27015}"
|
||||
echo " • Gamemode: ${GAMEMODE:-prop_hunt}"
|
||||
echo " • Tickrate: ${TICKRATE:-66}"
|
||||
echo ""
|
||||
|
||||
log_info "Starting server..."
|
||||
|
||||
# Handle shutdown signals
|
||||
trap 'log_info "Shutting down server..."; kill -SIGTERM $SERVER_PID; wait $SERVER_PID' SIGTERM SIGINT
|
||||
|
||||
# Start the server
|
||||
exec ./srcds_run $ARGS &
|
||||
SERVER_PID=$!
|
||||
|
||||
# Wait for the server process
|
||||
wait $SERVER_PID
|
||||
76
scripts/start.sh
Executable file
76
scripts/start.sh
Executable file
@@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
#===============================================================================
|
||||
# Garry's Mod PropHunt Server - Start Script
|
||||
#===============================================================================
|
||||
|
||||
INSTALL_DIR="${GMOD_INSTALL_DIR:-/home/gmod}"
|
||||
SERVER_DIR="${INSTALL_DIR}/serverfiles"
|
||||
|
||||
# Configuration (can be overridden with environment variables)
|
||||
SRCDS_TOKEN="${SRCDS_TOKEN:-}"
|
||||
SERVER_NAME="${SERVER_NAME:-PropHunt Server}"
|
||||
MAP="${MAP:-gm_construct}"
|
||||
MAX_PLAYERS="${MAX_PLAYERS:-24}"
|
||||
PORT="${PORT:-27015}"
|
||||
GAMEMODE="${GAMEMODE:-prop_hunt}"
|
||||
WORKSHOP_COLLECTION="${WORKSHOP_COLLECTION:-}"
|
||||
TICKRATE="${TICKRATE:-66}"
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
echo -e "${GREEN}"
|
||||
echo "╔═══════════════════════════════════════════════════════════════╗"
|
||||
echo "║ 🎮 Garry's Mod PropHunt Server Starting 🎮 ║"
|
||||
echo "╚═══════════════════════════════════════════════════════════════╝"
|
||||
echo -e "${NC}"
|
||||
|
||||
cd "$SERVER_DIR"
|
||||
|
||||
# Check if server files exist
|
||||
if [[ ! -f "srcds_run" ]]; then
|
||||
echo -e "${RED}[ERROR]${NC} Server files not found. Run install.sh first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build command line arguments
|
||||
ARGS="-game garrysmod"
|
||||
ARGS="$ARGS -console"
|
||||
ARGS="$ARGS -port $PORT"
|
||||
ARGS="$ARGS +maxplayers $MAX_PLAYERS"
|
||||
ARGS="$ARGS +map $MAP"
|
||||
ARGS="$ARGS +gamemode $GAMEMODE"
|
||||
ARGS="$ARGS -tickrate $TICKRATE"
|
||||
ARGS="$ARGS +hostname \"$SERVER_NAME\""
|
||||
|
||||
# Add Steam token if provided
|
||||
if [[ -n "$SRCDS_TOKEN" ]]; then
|
||||
ARGS="$ARGS +sv_setsteamaccount $SRCDS_TOKEN"
|
||||
echo -e "${GREEN}[OK]${NC} Steam token configured."
|
||||
else
|
||||
echo -e "${YELLOW}[WARNING]${NC} No SRCDS_TOKEN set. Server won't be listed publicly."
|
||||
echo "Get a token at: https://steamcommunity.com/dev/managegameservers"
|
||||
fi
|
||||
|
||||
# Add workshop collection if provided
|
||||
if [[ -n "$WORKSHOP_COLLECTION" ]]; then
|
||||
ARGS="$ARGS +host_workshop_collection $WORKSHOP_COLLECTION"
|
||||
echo -e "${BLUE}[INFO]${NC} Workshop collection: $WORKSHOP_COLLECTION"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${BLUE}[INFO]${NC} Server Configuration:"
|
||||
echo " • Map: $MAP"
|
||||
echo " • Max Players: $MAX_PLAYERS"
|
||||
echo " • Port: $PORT"
|
||||
echo " • Gamemode: $GAMEMODE"
|
||||
echo ""
|
||||
|
||||
echo -e "${GREEN}Starting server...${NC}"
|
||||
|
||||
# Start the server
|
||||
./srcds_run $ARGS
|
||||
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