Egg Repository

Pterodactyl Community Egg Repository

Counter Strike 1.6 - ReHLDS

CS 1.6 ReHLDS binaries egg. ReHLDS is a reverse-engineered, optimized version of HLDS. Developed by third-party modders to improve stability, performance, and security. Fully compatible with MetaMod, AMX Mod X, and other plugins. Included modules are rehlds, reunion, amxmodx, metamod-r, reapi and ReGameDLL_CS

Read Me

Counter-Strike 1.6 ReHLDS

Description

Counter-Strike 1.6 ReHLDS (Reverse Engineered Half-Life Dedicated Server) is an optimized and updated version of the original HLDS, designed for stability, performance, and security. It provides a modern platform for hosting Counter-Strike 1.6 servers with improved support for custom plugins and modules.

This egg offers everything you need to set up a Counter-Strike 1.6 server using ReHLDS, MetaMod-R, AMX Mod X, and other popular tools.

System Requirements

Component Minimum Recommended
Processor - -
RAM 1 GB 2 GB
Storage 2 GB 5 GB

Server Ports

Ports required to run the server in a table format.

Port default
Game 27015
Source TV 27020
Client 27005
Steam 26900

27015 is the default port, but any port can be used. The only required port is the Game port, server can run perfectly fine without other allocations.

Modules

  • ReHLDS: Improved performance, crash protection, and extended features.
  • MetaMod-R: Plugin loader for custom server modifications.
  • AMX Mod X: Advanced scripting platform for server plugins.
  • ReAPI: Enhances plugin capabilities with new native functions.
  • ReGameDLL: Updated game library for improved functionality.
  • Reunion: A Metamod plugin that allows protocol 47 and 48 non-steam clients to connect to ReHLDS servers

Notes

  • The server installation includes default configuration files such as server.cfg, listip.cfg, and banned.cfg.

For further configuration or plugin information, refer to the official AMX Mod X documentation or the ReHLDS GitHub repository.

Yolks
NameTag
ghcr.io/ptero-eggs/games:sourceghcr.io/ptero-eggs/games:source
Variables
NameDescriptionEnvironment VariableDefault ValueUser ViewableUser Editable
ReHLDS VersionThe version of ReHLDS to install, or 'latest' for the latest release.VERSIONlatestNoNo
Available ModulesAvailable Modules: rehlds, reunion, amxmodx, metamod-r, reapi and ReGameDLL_CSINSTALL_MODULESrehlds,reunion,amxmodx,metamod-r,reapi,ReGameDLL_CSYesYes
Server HostnameThis sets the hostname of the server. Example: "My Custom CS 1.6 Server"HOSTNAMECounter-Strike 1.6 ServerYesYes
MapThe default map for the server.SRCDS_MAPde_dust2YesYes
Auto updateAuto update on restartAUTO_UPDATE0NoNo
Game IDThe ID corresponding to the game to download and run using HLDS. The HLDS server ID is 90. This should not be changed.SRCDS_APPID90NoNo
Game NameThe name corresponding to the game to download and run using HLDSHLDS_GAMEcstrikeNoNo
Beta branchLeave empty for the public branch, for the legacy version select steam_legacy.SRCDS_BETAIDsteam_legacyNoNo
VAC portSpecifies the VAC port the server should use. Default is 26900.VAC_PORT26900NoNo
ValidateValidate game files on update. Keep it disabled with ReHLDS due to SteamCMD overwriting its changesVALIDATE0NoNo
Steam UsernameUsername associated wanted to be used. Not needed.STEAM_USERNoNo
Steam PasswordSteam Password for account.STEAM_PASSNoNo
Steam AuthSteam authenticator code for the accountSTEAM_AUTHNoNo
Install Script
#!/bin/bash
# Server Files: /mnt/server

# Ensure Steam credentials are set
if [[ -z "${STEAM_USER}" ]] || [[ -z "${STEAM_PASS}" ]]; then
    echo -e "Steam user is not set."
    echo -e "Using anonymous login."
    STEAM_USER=anonymous
    STEAM_PASS=""
    STEAM_AUTH=""
else
    echo -e "User set to ${STEAM_USER}"
fi

# Install SteamCMD
echo "Downloading and installing SteamCMD..."
mkdir -p /mnt/server/steamcmd
cd /tmp
curl -sSL -o steamcmd.tar.gz https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
tar -xzvf steamcmd.tar.gz -C /mnt/server/steamcmd
mkdir -p /mnt/server/steamapps
cd /mnt/server/steamcmd

# Set ownership
chown -R root:root /mnt
export HOME=/mnt/server

# Run SteamCMD to install the game
echo "Installing the game via SteamCMD..."
STEAMCMD_ARGS=(
    "+force_install_dir /mnt/server"
    "+login ${STEAM_USER} ${STEAM_PASS} ${STEAM_AUTH}"
    "+app_set_config 90 mod ${HLDS_GAME}"
    "+app_update ${SRCDS_APPID} ${INSTALL_FLAGS} validate"
    "+quit"
)

[[ -n "${SRCDS_BETAID}" ]] && STEAMCMD_ARGS+=("-beta ${SRCDS_BETAID}")
[[ -n "${SRCDS_BETAPASS}" ]] && STEAMCMD_ARGS+=("-betapassword ${SRCDS_BETAPASS}")

./steamcmd.sh "${STEAMCMD_ARGS[@]}"

# Set up Steam libraries
mkdir -p /mnt/server/.steam/sdk32
cp -v linux32/steamclient.so ../.steam/sdk32/steamclient.so
mkdir -p /mnt/server/.steam/sdk64
cp -v linux64/steamclient.so ../.steam/sdk64/steamclient.so

cd /mnt/server

# Download and install default server files from your repository
echo "Downloading the latest server files..."
REPO_OWNER="Red-Banana-Official"
REPO_NAME="cstrike1.6_rehlds"
RELEASE_DATA=$(curl -s https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases/latest)

TAG_NAME=$(echo "$RELEASE_DATA" | jq -r '.tag_name')
[[ "$TAG_NAME" == "null" ]] && TAG_NAME="1.0.0"  # Fallback in case of GitHub API failure

DOWNLOAD_URL=$(echo "$RELEASE_DATA" | jq -r '.zipball_url')
OUTPUT_FILE="$REPO_NAME-$TAG_NAME.zip"

# Clean unused files
rm -rf ${REPO_OWNER}-*

echo "Downloading $OUTPUT_FILE..."
curl -L -o $OUTPUT_FILE $DOWNLOAD_URL

if [ $? -eq 0 ]; then
    echo "Download successful!"
else
    echo "Download failed!"
    exit 1
fi

# Extract files
unzip -q -o "$OUTPUT_FILE"
rm -rf "$OUTPUT_FILE"
cd ${REPO_OWNER}-*

# Update SteamIdHashSalt function
update_steamid_salt() {
    local CONFIG_FILE="/mnt/server/cstrike/reunion.cfg"
    
    if [[ -f "$CONFIG_FILE" ]]; then
        local NEW_SALT=$(tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 50)
        if grep -q "^SteamIdHashSalt" "$CONFIG_FILE"; then
            sed -i "s/^SteamIdHashSalt.*/SteamIdHashSalt = $NEW_SALT/" "$CONFIG_FILE"
        else
            echo "SteamIdHashSalt = $NEW_SALT" >> "$CONFIG_FILE"
        fi
        echo "Updated SteamIdHashSalt in $CONFIG_FILE."
    else
        echo "Warning: $CONFIG_FILE not found. Skipping SteamIdHashSalt update."
    fi
}

# Module Installation
install_module() {
    local MODULE_NAME=$1
    local MODULE_DIR=$2
    local MODULE_ZIP=""

    MODULE_ZIP=$(find modules/$MODULE_DIR/ -type f -name '*.zip' | sort -V | tail -n 1)
    
    if [[ -z "$MODULE_ZIP" ]]; then
        echo "Error: No ZIP file found for $MODULE_NAME!"
        return 1
    fi

    echo "Installing $MODULE_NAME from $MODULE_ZIP..."
    
    local INSTALL_DIR="${MODULE_NAME}-install"
    mkdir -p "$INSTALL_DIR"
    cp -r "$MODULE_ZIP" "$INSTALL_DIR"

    cd "$INSTALL_DIR" || return 1
    unzip -q -o *.zip &
    wait

    case "$MODULE_NAME" in
        "rehlds") 
            cp -r bin/linux32/* ../server 
            ;;
        
        "amxmodx" | "reapi") 
            cp -r addons ../server/cstrike 
            ;;
        
        "ReGameDLL_CS") 
            cp -r bin/linux32/* ../server 
            ;;
        
        "metamod-r")
            cp -r addons ../server/cstrike
            touch ../server/cstrike/addons/metamod/plugins.ini
            grep -qxF "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" ../server/cstrike/addons/metamod/plugins.ini || echo "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" >> ../server/cstrike/addons/metamod/plugins.ini
            sed -i 's|^gamedll_linux.*|gamedll_linux "addons/metamod/metamod_i386.so"|' ../server/cstrike/liblist.gam || echo 'gamedll_linux "addons/metamod/metamod_i386.so"' >> ../server/cstrike/liblist.gam
            ;;
        
        "reunion")
            mkdir -p ../server/cstrike/addons/metamod/reunion/
            cp -r bin/Linux/* ../server/cstrike/addons/metamod/reunion/
            grep -qxF "linux addons/metamod/reunion/reunion_mm_i386.so" ../server/cstrike/addons/metamod/plugins.ini || echo "linux addons/metamod/reunion/reunion_mm_i386.so" >> ../server/cstrike/addons/metamod/plugins.ini
            
            # Ensure /mnt/server/cstrike is a directory
            if [[ ! -d "/mnt/server/cstrike" ]]; then
                echo "Warning: /mnt/server/cstrike was not a directory. Fixing..."
                rm -f /mnt/server/cstrike  # Remove it if it's a file
                mkdir -p /mnt/server/cstrike  # Recreate as a directory
            fi

            # Ensure reunion.cfg is copied correctly
            if [[ -f "reunion.cfg" ]]; then
                cp -v reunion.cfg /mnt/server/cstrike/reunion.cfg
                echo "Successfully copied reunion.cfg to /mnt/server/cstrike/"

                # Update SteamIdHashSalt
                update_steamid_salt
            else
                echo "Error: reunion.cfg not found! SteamIdHashSalt update skipped."
            fi
            ;;
    esac

    cd ..
    rm -rf "$INSTALL_DIR"
    
    echo "-----------------------------------------"
    echo "$MODULE_NAME successfully installed!"
    echo "-----------------------------------------"
}

# List of modules to be installed
declare -A MODULES
MODULES["rehlds"]="rehlds"
MODULES["amxmodx"]="amxmodx"
MODULES["ReGameDLL_CS"]="ReGameDLL_CS"
MODULES["reapi"]="reapi"
MODULES["metamod-r"]="metamod-r"
MODULES["reunion"]="reunion"

# Parse the user's selected modules
IFS=',' read -r -a MODULES_TO_INSTALL <<< "${INSTALL_MODULES}"

# Install only the selected modules
for MODULE in "${MODULES_TO_INSTALL[@]}"; do
    if [[ -n "${MODULES[$MODULE]}" ]]; then
        echo "Installing module: $MODULE"
        install_module "$MODULE" "${MODULES[$MODULE]}"
    else
        echo "Skipping unknown module: $MODULE"
    fi
done

# Move server files
cd /mnt/server/${REPO_OWNER}-*
cp -r server/* /mnt/server
chmod -R 777 /mnt/server
rm -rf ${REPO_OWNER}-*

# Ensure cstrike directory exists and is a directory
if [[ ! -d "/mnt/server/cstrike" ]]; then
    echo "Warning: /mnt/server/cstrike was not a directory. Fixing..."
    rm -f /mnt/server/cstrike  # Remove it if it's a file
    mkdir -p /mnt/server/cstrike  # Recreate as a directory
fi

# Ensure listip.cfg exists
if [[ ! -f "/mnt/server/cstrike/listip.cfg" ]]; then
    echo "// This file stores banned IPs" > /mnt/server/cstrike/listip.cfg
    echo "Created listip.cfg..."
else
    echo "listip.cfg already exists."
fi

# Ensure banned.cfg exists
if [[ ! -f "/mnt/server/cstrike/banned.cfg" ]]; then
    echo "// This file stores banned Steam IDs and IPs" > /mnt/server/cstrike/banned.cfg
    echo "Created banned.cfg..."
else
    echo "banned.cfg already exists."
fi

# Ensure server.cfg hostname is up-to-date
SERVER_CFG_PATH="/mnt/server/cstrike/server.cfg"
if [[ -f "$SERVER_CFG_PATH" ]]; then
    sed -i "s/^hostname .*/hostname \"${HOSTNAME}\"/" "$SERVER_CFG_PATH"
fi

# Ensure csstats.dat exists to avoid CSX warnings
CSSTATS_PATH="/mnt/server/cstrike/addons/amxmodx/data/csstats.dat"

# Ensure the data directory exists
mkdir -p /mnt/server/cstrike/addons/amxmodx/data

# To avoid errors relating to the csstats.dat file
if [[ ! -f "$CSSTATS_PATH" ]]; then
    touch "$CSSTATS_PATH"
    echo "Created csstats.dat to prevent CSX errors."
else
    echo "csstats.dat already exists."
fi

# Ensure correct file permissions
chmod 644 /mnt/server/cstrike/listip.cfg /mnt/server/cstrike/banned.cfg /mnt/server/cstrike/addons/amxmodx/data/csstats.dat

# Cleanup unused installation files
cd /mnt/server
rm -rf ${REPO_OWNER}-*  # Remove the leftover source directory
rm -f /mnt/server/.gitattributes
rm -f /mnt/server/.gitignore
rm -f /mnt/server/LICENSE
rm -f /mnt/server/README.md

echo "-----------------------------------------"
echo "Installation Complete!"
echo "-----------------------------------------"