diff --git a/Dockerfile b/Dockerfile index 7f4dc91..e9c7f51 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,10 @@ ENV STEAM_PATH="/home/steam" \ DOCKER_USER=steam \ \ WORKSHOP_COLLECTION_ID= \ + SERVER_NAME="" \ + SERVER_PASSWORD="" \ + SERVER_VOICE_ENABLE="1" \ + \ INSTALL_CSS=false \ INSTALL_HL2=false \ INSTALL_HLDM=false \ @@ -22,7 +26,7 @@ ENV STEAM_PATH="/home/steam" \ \ USE_MY_REPLACER_CONFIG=false \ DEBIAN_FRONTEND=noninteractive - + ENTRYPOINT ["./home/entrypoint.sh"] COPY ["entrypoint.sh", "experimental.sh", "forceWorkshopDownload.sh", "installAndMountAddons.sh", "/home/"] diff --git a/README.md b/README.md index b2ef4d1..28fc946 100644 --- a/README.md +++ b/README.md @@ -3,22 +3,25 @@ GMOD TTT server image, https://hub.docker.com/r/jusito/ ## TODO - use readme template -- create script which adds all workshop donwloads to lua (arg host_workshop_collection) - - \lua\autorun\server\workshop.lua, resource.AddWorkshop( "943738100" ) - force cleanup of downloaded elements => removed workshop elements are otherwise used ## run example ``` -docker run -d -p 27015:27015/tcp -p 27015:27015/udp -e WORKSHOP_COLLECTION_ID=123456 -e INSTALL_CSS=true "jusito/docker-ttt" +host_workshop_collection 123456 +map ttt_rooftops_2016_v1 -maxplayers 16 -hostname "New Server" +docker run -d -p 27015:27015/tcp -p 27015:27015/udp -e WORKSHOP_COLLECTION_ID=123456 -e INSTALL_CSS=true "jusito/docker-ttt" +host_workshop_collection 123456 +map ttt_rooftops_2016_v1 -maxplayers ``` -d exit if entrypoint exits -tcp port for rcon +tcp port for rcon, if you want to use it start with -usercon +rcon_password "yourPW" udp port for game traffic ## environment variables If set every workshop item at the collection is added as forced, that means its automatically downloaded on connecting. Don't add collections with maps here just like weapons aso. WORKSHOP_COLLECTION_ID= +This variables are used to write the value to the server.cfg: +SERVER_NAME="" +SERVER_PASSWORD="" +SERVER_VOICE_ENABLE="1" + If set to "true" the game is installed and mounted, most of the time you want to add the css content. INSTALL_CSS=false INSTALL_HL2=false @@ -27,7 +30,8 @@ INSTALL_TF2=false ## server config http://ttt.badking.net/config-and-commands/convars +https://wiki.garrysmod.de/server.cfg Path in container is: -docker cp "your server.cfg path" CONTAINER:/home/steam/server/garrysmod/cfg/server.cfg +docker cp "your server.cfg path" CONTAINER:/home/steam/serverfiles/garrysmod/cfg/server.cfg diff --git a/experimental.sh b/experimental.sh index c92b7ea..eee43c8 100644 --- a/experimental.sh +++ b/experimental.sh @@ -2,13 +2,43 @@ set -e - +function configReplace() { + source="$1" + target="$source \"$2\"" + count=$(grep -Po "($source).+" "${SERVER_PATH}/garrysmod/cfg/server.cfg" | wc -l) + + echo "Request for replacing $source to $target, source is found $count times" + + if [ "$count" == "1" ]; then + source=$(grep -Po "($source).+" "${SERVER_PATH}/garrysmod/cfg/server.cfg" | sed 's/\\/\\\\/g' | sed 's/\//\\\//g') + target=$(echo "$target" | sed 's/\\/\\\\/g' | sed 's/\//\\\//g') + sed -i "s/$source/$target/g" "${SERVER_PATH}/garrysmod/cfg/server.cfg" + elif [ "$count" == "0" ]; then + echo "" >> "${SERVER_PATH}/garrysmod/cfg/server.cfg" + echo "$target" >> "${SERVER_PATH}/garrysmod/cfg/server.cfg" + else + echo "can't set $1 because there are multiple in" + fi +} #create default server.config # not empty: grep -q '[^[:space:]]' < 'server.cfg' && echo "not empty" if [ ! -e "${SERVER_PATH}/garrysmod/cfg/server.cfg" ] || [ "0" = "$(grep -o '[^[:space:]]' "${SERVER_PATH}/garrysmod/cfg/server.cfg" | wc -l)" ]; then mkdir -p "${SERVER_PATH}/garrysmod/cfg" wget -O "${SERVER_PATH}/garrysmod/cfg/server.cfg" "https://raw.githubusercontent.com/jusito/docker-ttt/master/server.cfg" + chown "$USER_ID:$GROUP_ID" "${SERVER_PATH}/garrysmod/cfg/server.cfg" + chmod u+rw "${SERVER_PATH}/garrysmod/cfg/server.cfg" +fi + +#set hostname & password, working if only one entry is in +if [ -n "${SERVER_NAME}" ]; then + configReplace "hostname" "$SERVER_NAME" +fi +if [ -n "${SERVER_PASSWORD}" ]; then + configReplace "sv_password" "$SERVER_PASSWORD" +fi +if [ -n "${SERVER_VOICE_ENABLE}" ]; then + configReplace "sv_voiceenable" "$SERVER_VOICE_ENABLE" fi #this is a simple option for myself, but you can use it too diff --git a/server.cfg b/server.cfg index 0c5a0a0..d868572 100644 --- a/server.cfg +++ b/server.cfg @@ -1,7 +1,10 @@ -// server name -hostname "New Server" +hostname "" +sv_password "" +sv_voiceenable 0 + sv_contact "unknown" + // rcon passsword sv_rcon_banpenalty 5 sv_rcon_maxfailures 3