- 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
89 lines
2.9 KiB
Bash
Executable File
89 lines
2.9 KiB
Bash
Executable File
#!/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
|