#!/bin/bash # Wait for the container to fully initialize sleep 1 # Default the TZ environment variable to UTC. TZ=${TZ:-UTC} export TZ # Set environment variable that holds the Internal Docker IP INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}') export INTERNAL_IP # Switch to the container's working directory cd /home/container || exit 1 # Default steam user if [ "${STEAM_USER}" == "" ]; then echo -e "steam user is not set.\n" echo -e "Using anonymous user.\n" STEAM_USER=anonymous STEAM_PASS="" STEAM_AUTH="" else echo -e "user set to ${STEAM_USER}" fi # Auto update if [ -z ${AUTO_UPDATE} ] || [ "${AUTO_UPDATE}" == "1" ]; then if [ ! -z ${SRCDS_APPID} ]; then /usr/games/steamcmd/steamcmd.sh +force_install_dir /home/container +login ${STEAM_USER} ${STEAM_PASS} ${STEAM_AUTH} +app_update 1007 +app_update ${SRCDS_APPID} $( [[ -z ${SRCDS_BETAID} ]] || printf %s "-beta ${SRCDS_BETAID}" ) $( [[ -z ${SRCDS_BETAPASS} ]] || printf %s "-betapassword ${SRCDS_BETAPASS}" ) $( [[ -z ${HLDS_GAME} ]] || printf %s "+app_set_config 90 mod ${HLDS_GAME}" ) $( [[ -z ${VALIDATE} ]] || printf %s "validate" ) +quit else echo -e "No appid set. Starting Server" fi else echo -e "Not updating game server as auto update was set to 0. Starting Server" fi # Create Steam SDK symlinks mkdir -p .steam/sdk64 ln -sf /usr/games/steamcmd/linux64/steamclient.so .steam/sdk64/steamclient.so ln -sf /usr/games/steamcmd/linux32/steamclient.so .steam/sdk32/steamclient.so # Clone Git addons if GIT_REPOS is set if [ ! -z "${GIT_REPOS}" ]; then IFS=',' read -ra REPOS <<< "$GIT_REPOS" for repo in "${REPOS[@]}"; do repo=$(echo "$repo" | xargs) if [ ! -z "$repo" ]; then REPO_NAME=$(basename "$repo" .git) ADDON_DIR="garrysmod/addons/${REPO_NAME}" if [ -d "$ADDON_DIR/.git" ]; then echo "Updating Git addon: ${REPO_NAME}..." cd "$ADDON_DIR" && git pull && cd /home/container else echo "Cloning Git addon: ${REPO_NAME}..." git clone "$repo" "$ADDON_DIR" fi fi done fi # Load Workshop collection if [ ! -z "${SRCDS_WORKSHOP_COLLECTION}" ]; then echo "Workshop collection ${SRCDS_WORKSHOP_COLLECTION} will be loaded on first start." fi # Replace Startup Variables MODIFIED_STARTUP=$(echo ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g') echo -e ":/home/container$ ${MODIFIED_STARTUP}" # Run the Server eval ${MODIFIED_STARTUP}