+ improved readme, added whats missing
This commit is contained in:
parent
62ef6948a1
commit
cb7d83749c
51
Dockerfile
51
Dockerfile
@ -1,15 +1,11 @@
|
||||
FROM ubuntu:16.04
|
||||
FROM jusito/lgsm:latest
|
||||
|
||||
EXPOSE 27015/udp 27015/tcp
|
||||
|
||||
ENV STEAM_PATH="/home/steam" \
|
||||
SERVER_PATH="/home/steam/serverfiles" \
|
||||
STEAM_CMD="/home/steam/steamcmd" \
|
||||
GROUP_ID=10000 \
|
||||
USER_ID=10000 \
|
||||
DOCKER_USER=steam \
|
||||
ENV LGSM_GAMESERVER="gmodserver" \
|
||||
LGSM_EXECUTABLE="gmodserver" \
|
||||
LGSM_STOP_SCRIPT="/home/stop.sh" \
|
||||
GAMECONFIG_SCRIPT="/home/config.sh" \
|
||||
\
|
||||
WORKSHOP_COLLECTION_ID= \
|
||||
WORKSHOP_COLLECTION_ID="" \
|
||||
SERVER_NAME="" \
|
||||
SERVER_PASSWORD="" \
|
||||
SERVER_VOICE_ENABLE="1" \
|
||||
@ -24,36 +20,19 @@ ENV STEAM_PATH="/home/steam" \
|
||||
HLDM_PATH="/home/steam/addons/hldm" \
|
||||
TF2_PATH="/home/steam/addons/tf2" \
|
||||
\
|
||||
USE_MY_REPLACER_CONFIG=false \
|
||||
DEBIAN_FRONTEND=noninteractive
|
||||
USE_MY_REPLACER_CONFIG=false
|
||||
|
||||
ENTRYPOINT ["./home/entrypoint.sh"]
|
||||
COPY ["config.sh", "stop.sh", "forceWorkshopDownload.sh", "installAndMountAddons.sh", "/home/"]
|
||||
|
||||
COPY ["entrypoint.sh", "experimental.sh", "forceWorkshopDownload.sh", "installAndMountAddons.sh", "/home/"]
|
||||
|
||||
# removed dep. lib32gcc1 libtcmalloc-minimal4:i386 gdb
|
||||
RUN dpkg --add-architecture i386 && \
|
||||
apt-get update -y && \
|
||||
apt-get install -y mailutils postfix curl wget file bzip2 gzip unzip bsdmainutils python util-linux ca-certificates \
|
||||
binutils bc jq tmux lib32gcc1 libstdc++6 libstdc++6:i386 lib32tinfo5 \
|
||||
locales sudo cron && \
|
||||
RUN chown "$DOCKER_USER:$DOCKER_USER" "/home/config.sh" && \
|
||||
chown "$DOCKER_USER:$DOCKER_USER" "/home/stop.sh" && \
|
||||
chown "$DOCKER_USER:$DOCKER_USER" "/home/forceWorkshopDownload.sh" && \
|
||||
chown "$DOCKER_USER:$DOCKER_USER" "/home/installAndMountAddons.sh" && \
|
||||
\
|
||||
groupadd -g $GROUP_ID $DOCKER_USER && \
|
||||
useradd -d "$STEAM_PATH" -g $GROUP_ID -u $USER_ID -m $DOCKER_USER && \
|
||||
chown "$DOCKER_USER:$DOCKER_USER" /home/entrypoint.sh && \
|
||||
sudo -u "$DOCKER_USER" mkdir -p "$SERVER_PATH" && \
|
||||
chown -R "$DOCKER_USER:$DOCKER_USER" "$STEAM_PATH" && \
|
||||
chmod a=rx /home/entrypoint.sh && \
|
||||
chmod a=rx /home/experimental.sh && \
|
||||
chmod a=rx /home/config.sh && \
|
||||
chmod a=rx /home/stop.sh && \
|
||||
chmod a=rx /home/forceWorkshopDownload.sh && \
|
||||
chmod a=rx /home/installAndMountAddons.sh && \
|
||||
\
|
||||
ulimit -n 2048 && \
|
||||
locale-gen en_US.UTF-8 && \
|
||||
\
|
||||
wget -O "$STEAM_PATH/linuxgsm.sh" "https://linuxgsm.sh" && \
|
||||
chown "$DOCKER_USER:$DOCKER_USER" "$STEAM_PATH/linuxgsm.sh" && \
|
||||
chmod +x "$STEAM_PATH/linuxgsm.sh"
|
||||
chmod a=rx /home/installAndMountAddons.sh
|
||||
|
||||
USER "$USER_ID:$GROUP_ID"
|
||||
|
||||
|
69
README.md
69
README.md
@ -1,40 +1,53 @@
|
||||
# docker-ttt
|
||||
GMOD TTT server image, https://hub.docker.com/r/jusito/
|
||||
Garry's mod, gamemode TTT as docker image: https://hub.docker.com/r/jusito/
|
||||
|
||||
## TODO
|
||||
- use readme template
|
||||
- force cleanup of downloaded elements => removed workshop elements are otherwise used
|
||||
## Getting Started
|
||||
1. Create 2 workshop collections. One containing Maps and a subcollection. Subcollection containing all non-map elements.
|
||||
2. Do you want forced auto download? If no go 3., if yes use `-e WORKSHOP_COLLECTION_ID=*SubCollectionID*`.
|
||||
3. Let Gmod server know which collection should be used. `[...]jusito/docker-ttt:beta +host_workshop_collection *MainCollectionID* [...]`
|
||||
4. Do you want CSS or other game content installed and mounted(CSS recommended)? If no go 5., if yes `-e INSTALL_CSS=true` or see environment variables.
|
||||
5. Choose your ports. Default is 27015. `docker run [...] -p 27015:27015/tcp jusito/docker-ttt:beta -port 27015 [...]`
|
||||
|
||||
## run example
|
||||
### 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
|
||||
docker run -dit -p 27015:27015/tcp -p 27015:27015/udp -e WORKSHOP_COLLECTION_ID=123456 -e INSTALL_CSS=true "jusito/docker-ttt:beta" -port 27015 +host_workshop_collection 123456 +map ttt_rooftops_2016_v1 -maxplayers 16
|
||||
```
|
||||
-d exit if entrypoint exits
|
||||
tcp port for rcon, if you want to use it start with -usercon +rcon_password "yourPW"
|
||||
udp port for game traffic
|
||||
* _-it_ needed for seeing all output if attached
|
||||
* _27015/tcp_(optional) - rcon port, you will need this too: -usercon +rcon_password "yourPW"
|
||||
* _27015/udp_ - udp port for game traffic
|
||||
* _-port 27015_ - only needed if you want to use non-default port, docker -p 27016:27015 will _not_ work.
|
||||
* _-e WORKSHOP_COLLECTION_ID_(optional) - add every element to forced
|
||||
* _-e INSTALL_CSS_(optional) - download CSS and mount it
|
||||
* _+host_workshop_collection_ - Garry's Mod will load this collection
|
||||
* _+map_(optional) - default map to start
|
||||
* _-maxplayers_(optional) - max count of players
|
||||
|
||||
## access console
|
||||
docker exec -it CONTAINER ./home/steam/gmodserver console
|
||||
### whats missing, why tag beta:
|
||||
1. cron service needs to be started otherwise the server will get only updates on restart
|
||||
2. force cleanup of downloaded elements => removed workshop elements are otherwise used
|
||||
3. I failed to create a proper volume, mount /home/steam/serverfiles.
|
||||
|
||||
## 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
|
||||
INSTALL_HLDM=false
|
||||
INSTALL_TF2=false
|
||||
| Variable | Default | Description | Example |
|
||||
|----------|---------|-------------|---------|
|
||||
|WORKSHOP_COLLECTION_ID|""(empty)|Every element on this list is set to forced download. The users don't need to subscribe to your collection. Don't add maps here, they are already forced by default.|1358835428|
|
||||
|||||
|
||||
|SERVER_NAME|""(empty)|overwrite server.cfg value|"[TTT] dockerized"|
|
||||
|SERVER_PASSWORD|""(empty)|overwrite server.cfg value|"SecurePW"|
|
||||
|SERVER_VOICE_ENABLE|1|overwrite server.cfg value|0 (disabling ingame voice)|
|
||||
|||||
|
||||
|INSTALL_CSS|false|Install & Mount CSS. Most of the time you will set this to true.|true|
|
||||
|INSTALL_HL2|false|Install & Mount HL2.|true|
|
||||
|INSTALL_HLDM|false|Install & Mount HLDM.|true|
|
||||
|INSTALL_TF2|false|Install & Mount TF2.|true|
|
||||
|
||||
## server config
|
||||
http://ttt.badking.net/config-and-commands/convars
|
||||
https://wiki.garrysmod.de/server.cfg
|
||||
* [TTT config variables](http://ttt.badking.net/config-and-commands/convars)
|
||||
* [Server.cfg variables](https://wiki.garrysmod.de/server.cfg)
|
||||
|
||||
|
||||
## Additional
|
||||
* Attach to console after start, `docker exec -it _CONTAINER_ /home/steam/gmodserver console`
|
||||
* Copy your server.cfg in, `docker cp "your server.cfg path" CONTAINER:/home/steam/serverfiles/garrysmod/cfg/server.cfg`
|
||||
|
||||
Path in container is:
|
||||
docker cp "your server.cfg path" CONTAINER:/home/steam/serverfiles/garrysmod/cfg/server.cfg
|
||||
|
||||
|
@ -2,6 +2,15 @@
|
||||
|
||||
set -e
|
||||
|
||||
#create default server.config
|
||||
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
|
||||
function configReplace() {
|
||||
source="$1"
|
||||
target="$source \"$2\""
|
||||
@ -20,17 +29,6 @@ function configReplace() {
|
||||
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
|
||||
@ -41,19 +39,26 @@ if [ -n "${SERVER_VOICE_ENABLE}" ]; then
|
||||
configReplace "sv_voiceenable" "$SERVER_VOICE_ENABLE"
|
||||
fi
|
||||
|
||||
#set up cronjob
|
||||
crontab -r | true
|
||||
rm -f "$STEAM_PATH/lgsm-cronjobs" | true
|
||||
touch "$STEAM_PATH/lgsm-cronjobs"
|
||||
echo "*/5 * * * * su - '$DOCKER_USER' -c '$STEAM_PATH/gmodserver monitor' > /dev/null 2>&1" >> "$STEAM_PATH/lgsm-cronjobs"
|
||||
echo "*/30 * * * * su - '$DOCKER_USER' -c '$STEAM_PATH/gmodserver update' > /dev/null 2>&1" >> "$STEAM_PATH/lgsm-cronjobs"
|
||||
echo "0 10 * * 0 su - '$DOCKER_USER' -c '$STEAM_PATH/gmodserver force-update' > /dev/null 2>&1" >> "$STEAM_PATH/lgsm-cronjobs"
|
||||
echo "" >> "$STEAM_PATH/lgsm-cronjobs"
|
||||
crontab "$STEAM_PATH/lgsm-cronjobs"
|
||||
|
||||
#this is a simple option for myself, but you can use it too
|
||||
#this is a simple option for one of my mods, but you can use it too
|
||||
if [ "$USE_MY_REPLACER_CONFIG" = "true" ] && [ ! -e "${SERVER_PATH}/garrysmod/data/jusito_ttt_entity_replace" ]; then
|
||||
mkdir -p "${SERVER_PATH}/garrysmod/data/jusito_ttt_entity_replace"
|
||||
wget -O "${SERVER_PATH}/garrysmod/data/jusito_ttt_entity_replace/config.txt" "https://raw.githubusercontent.com/jusito/ttt_entity_replace/master/config.txt.example_fas2"
|
||||
fi
|
||||
|
||||
echo "force workshop download"
|
||||
./home/forceWorkshopDownload.sh
|
||||
echo "install & mount gamefiles"
|
||||
./home/installAndMountAddons.sh
|
||||
cd "$STEAM_PATH"
|
||||
|
||||
#docker args -> lgsm args
|
||||
export parms="-game garrysmod +gamemode terrortown "$(printf "%s " "$@")
|
||||
if [ -e "${STEAM_PATH}/lgsm/config-lgsm/gmodserver/gmodserver.cfg" ]; then
|
||||
rm -f "${STEAM_PATH}/lgsm/config-lgsm/gmodserver/gmodserver.cfg"
|
||||
fi
|
||||
mkdir -p "${STEAM_PATH}/lgsm/config-lgsm/gmodserver/"
|
||||
touch "${STEAM_PATH}/lgsm/config-lgsm/gmodserver/gmodserver.cfg"
|
||||
echo "fn_parms(){" > "${STEAM_PATH}/lgsm/config-lgsm/gmodserver/gmodserver.cfg"
|
||||
echo "parms="'"'"$parms"'"' >> "${STEAM_PATH}/lgsm/config-lgsm/gmodserver/gmodserver.cfg"
|
||||
echo "}" >> "${STEAM_PATH}/lgsm/config-lgsm/gmodserver/gmodserver.cfg"
|
||||
echo "starting with $parms"
|
@ -1,66 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
sleep 2s
|
||||
echo "starting entrypoint.sh"
|
||||
set -e
|
||||
|
||||
cd "$STEAM_PATH"
|
||||
#suggested -disableluarefresh -tickrate 66 +host_workshop_collection -port 27015
|
||||
|
||||
if [ -e "${STEAM_PATH}/gmodserver" ]; then
|
||||
./gmodserver update-lgsm
|
||||
./gmodserver update
|
||||
else
|
||||
bash linuxgsm.sh gmodserver
|
||||
./gmodserver auto-install
|
||||
fi
|
||||
|
||||
cd "/home"
|
||||
echo "check various options"
|
||||
./experimental.sh
|
||||
echo "force workshop download"
|
||||
./forceWorkshopDownload.sh
|
||||
echo "install & mount gamefiles"
|
||||
./installAndMountAddons.sh
|
||||
cd "$STEAM_PATH"
|
||||
|
||||
#docker args -> lgsm args
|
||||
export parms="-game garrysmod +gamemode terrortown "$(printf "%s " "$@")
|
||||
if [ -e "${STEAM_PATH}/lgsm/config-lgsm/gmodserver/gmodserver.cfg" ]; then
|
||||
rm -f "${STEAM_PATH}/lgsm/config-lgsm/gmodserver/gmodserver.cfg"
|
||||
fi
|
||||
mkdir -p "${STEAM_PATH}/lgsm/config-lgsm/gmodserver/"
|
||||
touch "${STEAM_PATH}/lgsm/config-lgsm/gmodserver/gmodserver.cfg"
|
||||
echo "fn_parms(){" > "${STEAM_PATH}/lgsm/config-lgsm/gmodserver/gmodserver.cfg"
|
||||
echo "parms="'"'"$parms"'"' >> "${STEAM_PATH}/lgsm/config-lgsm/gmodserver/gmodserver.cfg"
|
||||
echo "}" >> "${STEAM_PATH}/lgsm/config-lgsm/gmodserver/gmodserver.cfg"
|
||||
echo "starting with $parms"
|
||||
|
||||
#force fetch of command_console.sh
|
||||
if [ ! -e "${STEAM_PATH}/lgsm/functions/command_console.sh" ]; then
|
||||
wget -O "${STEAM_PATH}/lgsm/functions/command_console.sh" "https://raw.githubusercontent.com/GameServerManagers/LinuxGSM/master/lgsm/functions/command_console.sh"
|
||||
chmod +x "${STEAM_PATH}/lgsm/functions/command_console.sh"
|
||||
fi
|
||||
#skip confirmation
|
||||
sed -i 's/! fn_prompt_yn "Continue?" Y/[ "1" != "1" ]/' "${STEAM_PATH}/lgsm/functions/command_console.sh"
|
||||
|
||||
#start server
|
||||
IS_RUNNING="true"
|
||||
function stopServer() {
|
||||
echo "stopping server..."
|
||||
cd "${STEAM_PATH}"
|
||||
pkill -2 srcds_linux
|
||||
pkill -2 srcds_run
|
||||
echo "server stopped!"
|
||||
echo "stopping entrypoint..."
|
||||
IS_RUNNING="false"
|
||||
}
|
||||
./gmodserver start
|
||||
trap stopServer SIGTERM
|
||||
echo "Server is running, waiting for SIGTERM"
|
||||
while [ "$IS_RUNNING" = "true" ]
|
||||
do
|
||||
sleep 1s
|
||||
done
|
||||
echo "entrypoint stopped"
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user