- Add automatic tcmalloc disable in start scripts to prevent 'large alloc' segfaults - Add warnings and documentation about workshop COLLECTION vs addon IDs - Expand troubleshooting section with solutions for common crashes - Document that -authkey deprecation warning can be safely ignored Fixes: - tcmalloc: large alloc XXXXXXX bytes == (nil) followed by Segmentation fault - Item is not a collection! error when using addon ID instead of collection ID - Missing 32-bit libraries warning with installation instructions
88 lines
3.3 KiB
Bash
Executable File
88 lines
3.3 KiB
Bash
Executable File
#!/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
|
|
# NOTE: Make sure WORKSHOP_COLLECTION is a COLLECTION ID, not an individual item ID!
|
|
# You can verify at: https://steamcommunity.com/sharedfiles/filedetails/?id=YOUR_ID
|
|
# If it says "Collection" it's valid. If it says "Addon" it will fail with "Item is not a collection!"
|
|
if [[ -n "$WORKSHOP_COLLECTION" ]]; then
|
|
ARGS="$ARGS +host_workshop_collection $WORKSHOP_COLLECTION"
|
|
echo -e "${BLUE}[INFO]${NC} Workshop collection: $WORKSHOP_COLLECTION"
|
|
echo -e "${YELLOW}[WARNING]${NC} Ensure this is a Collection ID, not an individual addon ID!"
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${BLUE}[INFO]${NC} Server Configuration:"
|
|
echo " • Map: $MAP"
|
|
echo " • Max Players: $MAX_PLAYERS"
|
|
echo " • Port: $PORT"
|
|
echo " • Gamemode: $GAMEMODE"
|
|
echo ""
|
|
|
|
# Disable tcmalloc which causes segfaults with large memory allocations
|
|
# The error "tcmalloc: large alloc XXXXXXX bytes == (nil)" indicates memory allocation failure
|
|
if [[ -f "$SERVER_DIR/bin/libtcmalloc_minimal.so.4" ]]; then
|
|
echo -e "${BLUE}[INFO]${NC} Disabling tcmalloc to prevent memory allocation crashes..."
|
|
mv "$SERVER_DIR/bin/libtcmalloc_minimal.so.4" "$SERVER_DIR/bin/libtcmalloc_minimal.so.4.disabled" 2>/dev/null || true
|
|
fi
|
|
|
|
echo -e "${GREEN}Starting server...${NC}"
|
|
|
|
# Start the server
|
|
./srcds_run $ARGS
|