+ initial files, + force workshop support, + auto mount support

This commit is contained in:
Lucas Briese 2018-09-19 21:16:51 +02:00
parent 7254563886
commit f22fe7a1ce
8 changed files with 309 additions and 1 deletions

11
.project Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>docker-ttt</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

8
.travis.yml Normal file
View File

@ -0,0 +1,8 @@
services:
- docker
script:
- docker build -t "jusito/docker-ttt:develop" .
- docker volume create TTT
- docker run -ti --name "TTT" -p 27015:27015/tcp -p 27015:27015/udp -v "TTT:/home/steam/server:rw" \
"jusito/docker-ttt:develop" -port 27015 -maxplayers 16 +map ttt_rooftops_2016_v1 -usercon +rcon_password "testing" -debug

40
Dockerfile Normal file
View File

@ -0,0 +1,40 @@
FROM ubuntu:16.04
EXPOSE 27015/udp 27015/tcp
ENV STEAM_PATH="/home/steam" \
SERVER_PATH="/home/steam/server" \
GROUP_ID=10000 \
USER_ID=10000 \
DOCKER_USER=steam \
\
WORKSHOP_COLLECTION_ID= \
INSTALL_CSS=false \
INSTALL_HL2=false \
INSTALL_HLDM=false \
INSTALL_TF2=false \
\
CSS_PATH="/home/steam/addons/css" \
HL2_PATH="/home/steam/addons/hl2" \
HLDM_PATH="/home/steam/addons/hldm" \
TF2_PATH="/home/steam/addons/tf2"
USER "$USER_ID:$GROUP_ID"
VOLUME "$SERVER_PATH"
ENTRYPOINT ["./home/entrypoint.sh"]
COPY ["entrypoint.sh", "installAndMountAddons.sh", "forceWorkshopDownload.sh", "/home/" ]
# removed dep. lib32gcc1 libtcmalloc-minimal4:i386 gdb
RUN dpkg --add-architecture i386 && \
apt-get update -y && \lib32stdc++6
apt-get install -y wget tar gzip ca-certificates lib32stdc++6 lib32tinfo5 && \
groupadd -g $GROUP_ID $DOCKER_USER && \
useradd -d /home/steam/ -g $GROUP_ID -u $USER_ID -m $DOCKER_USER && \
chown "$DOCKER_USER:$DOCKER_USER" /home/entrypoint.sh && \
chmod a=rx /home/entrypoint.sh && \
chmod a=rx /home/installAndMountAddons.sh && \
chmod a=rx /home/forceWorkshopDownload.sh && \
ulimit -n 2048

View File

@ -1,2 +1,33 @@
# docker-ttt
[not working] GMOD TTT server image, https://hub.docker.com/r/jusito/
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"
```
-d exit if entrypoint exits
tcp port for rcon
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=
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
## server config
http://ttt.badking.net/config-and-commands/convars
Path in container is:
docker cp "your server.cfg path" CONTAINER:/home/steam/server/garrysmod/cfg/server.cfg

48
entrypoint.sh Normal file
View File

@ -0,0 +1,48 @@
#!/bin/bash
echo "starting entrypoint.sh"
set -e
echo "installing / updating steamcmd"
cd "$STEAM_PATH"
wget -q -O - "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar -zxvf -
if [ -e "${STEAM_PATH}/server/steam_cache" ]; then
echo "clearing steam cache"
rm -rf "${STEAM_PATH}/server/steam_cache/"
fi
if [ -e "${STEAM_PATH}/server/garrysmod/cache" ]; then
echo "clearing cache"
rm -rf "${STEAM_PATH}/server/garrysmod/cache/*"
fi
echo "testing steamcmd"
./steamcmd.sh +login anonymous +quit
echo "installing / validating ttt"
cd "$STEAM_PATH"
./steamcmd.sh +login anonymous +force_install_dir "$STEAM_PATH/server/" +app_update 4020 validate +quit || \
(echo '[error][1] catched => printing stderr.txt:' && \
cat "Steam/logs/stderr.txt" && \
echo '[error][1] <= printed' && \
./steamcmd.sh +login anonymous +force_install_dir "$STEAM_PATH/server/" +app_update 4020 validate +quit) || \
(echo '[error][2] catched => printing stderr.txt:' && \
cat "Steam/logs/stderr.txt" && \
echo '[error][2] <= printed' && \
./steamcmd.sh +login anonymous +force_install_dir "$STEAM_PATH/server/" +app_update 4020 validate +quit)
bash installAndMountAddons.sh
bash forceWorkshopDownload.sh
echo "processing scripts before start"
if [ -e "$SERVER_PATH/custom.sh" ]; then
echo "existing: $SERVER_PATH/custom.sh"
bash "$SERVER_PATH/custom.sh"
else
echo "not existing: $SERVER_PATH/custom.sh"
fi
# todo catch => send killserver / quit
cd "$STEAM_PATH/server/"
trap 'pkill -15 srcds_run' SIGTERM
./srcds_run -console -game garrysmod +gamemode terrortown "$@" &
wait "$!"

28
forceWorkshopDownload.sh Normal file
View File

@ -0,0 +1,28 @@
#!/bin/bash
set -e
#using WORKSHOP_COLLECTION_ID
LUA_PATH="${SERVER_PATH}/garrysmod/lua/autorun/server"
LUA_FILE="${LUA_PATH}/workshop_autoload.lua"
#remove old file
if [ -e "$LUA_FILE" ]; then
rm "$LUA_FILE"
else
mkdir -p "$LUA_PATH"
fi
if [ "$WORKSHOP_COLLECTION_ID" = "0" ] || [ "$WORKSHOP_COLLECTION_ID" = "" ]; then
echo "given ID is default, no workshop download"
else
touch "$LUA_FILE"
arr="$(wget -q -O - https://steamcommunity.com/sharedfiles/filedetails/?id=${WORKSHOP_COLLECTION_ID} | tr '\n' ' ' | grep -Po '"workshopItem"[^"]+"https://steamcommunity.com/sharedfiles/filedetails/\?id=(\d+)' | grep -Po '\d\d\d+' )"
str=""
for i in ${arr[@]}
do
str=${str}"resource.AddWorkshop( \"${i}\" )"$'\n'
done
echo "$str" > "$LUA_FILE"
fi

48
installAndMountAddons.sh Normal file
View File

@ -0,0 +1,48 @@
#!/bin/bash
set -e
mount='"mountcfg"'$'\n{\n'
if [ "$INSTALL_CSS" = "true" ]; then
echo "installing & mounting css"
./steamcmd.sh +login anonymous +force_install_dir "$CSS_PATH" +app_update 232330 validate +quit
mount=${mount}' "cstrike" "'"${CSS_PATH}/cstrike"'"\n'
if [ "$INSTALL_HL2" != "true" ]; then
mount=${mount}' "hl2" "'"${CSS_PATH}/hl2"'"\n'
fi
fi
if [ "$INSTALL_HL2" = "true" ]; then
echo "installing & mounting hl2"
./steamcmd.sh +login anonymous +force_install_dir "$HL2_PATH" +app_update 232370 validate +quit
mount=${mount}' "hl2" "'"${HL2_PATH}/hl2"'"\n'
mount=${mount}' "hl2mp" "'"${HL2_PATH}/hl2mp"'"\n'
fi
if [ "$INSTALL_TF2" = "true" ]; then
echo "installing & mounting tf2"
./steamcmd.sh +login anonymous +force_install_dir "$TF2_PATH" +app_update 232250 validate +quit
mount=${mount}' "tf2" "'"${TF2_PATH}/tf"'"\n'
if [ "$INSTALL_CSS" != "true" ] && [ "$INSTALL_HL2" != "true" ]; then
mount=${mount}' "hl2" "'"${TF2_PATH}/hl2"'"\n'
fi
fi
if [ "$INSTALL_HLDM" = "true" ]; then
echo "installing & mounting hldm"
./steamcmd.sh +login anonymous +force_install_dir "$HLDM_PATH" +app_update 255470 validate +quit
mount=${mount}' "hl1" "'"${HLDM_PATH}/hl1"'"\n'
mount=${mount}' "hldm" "'"${HLDM_PATH}/hldm"'"\n'
if [ "$INSTALL_CSS" != "true" ] && [ "$INSTALL_HL2" != "true" ] && [ "$INSTALL_TF2" != "true" ]; then
mount=${mount}' "hl2" "'"${HLDM_PATH}/hl2"'"\n'
fi
fi
mount=${mount}$'}'
if [ ! -e "${SERVER_PATH}/garrysmod/cfg" ]; then
mkdir -p "${SERVER_PATH}/garrysmod/cfg"
fi
if [ -e "${SERVER_PATH}/garrysmod/cfg" ]; then
rm "${SERVER_PATH}/garrysmod/cfg"
fi
touch "${SERVER_PATH}/garrysmod/cfg"
echo "$mount" > "${SERVER_PATH}/garrysmod/cfg/mount.cfg"

94
server.cfg Normal file
View File

@ -0,0 +1,94 @@
// rcon passsword
sv_rcon_banpenalty 5
sv_rcon_maxfailures 3
//DNA
ttt_killer_dna_range 300
ttt_killer_dna_basetime 100
//Prep
ttt_firstpreptime 60
ttt_preptime_seconds 30
ttt_posttime_seconds 3
//Round length
ttt_haste 0
// ttt_haste_starting_minutes 5
// ttt_haste_minutes_per_death 0.5
ttt_roundtime_minutes 10
//Map Switching
ttt_round_limit 10
ttt_time_limit_minutes 75
//ttt_always_use_mapcycle 0
//Player Counts
ttt_minimum_players 2
ttt_traitor_pct 0.4
ttt_traitor_max 32
ttt_detective_pct 0.1
ttt_detective_max 32
ttt_detective_min_players 6
ttt_detective_karma_min 600
//Karma
ttt_karma 1
ttt_karma_strict 1
ttt_karma_starting 1000
ttt_karma_max 1000
ttt_karma_ratio 0.001
ttt_karma_kill_penalty 50
ttt_karma_round_increment 5
ttt_karma_clean_bonus 30
ttt_karma_traitordmg_ratio 0.0003
ttt_karma_traitorkill_bonus 100
ttt_karma_low_autokick 1
ttt_karma_low_amount 300
ttt_karma_low_ban 0
ttt_karma_low_ban_minutes 60
ttt_karma_persist 1
ttt_karma_clean_half 0.25
//Other
ttt_postround_dm 0
ttt_no_nade_throw_during_prep 0
ttt_weapon_carrying 1
ttt_weapon_carrying_range 50
ttt_teleport_telefrags 1
ttt_ragdoll_pinning 1
ttt_ragdoll_pinning_innocents 1
ttt_use_weapon_spawn_scripts 1
ttt_spawn_wave_interval 2
ttt_allow_discomb_jump 1
ttt_debug_preventwin 0
// server logging
log on
sv_logbans 1
sv_logecho 1
sv_logfile 0
sv_log_onefile 0
// operation
sv_lan 0
sv_region 3 //Europa
// traitor
ttt_credits_detectivekill 2
ttt_credits_award_repeat 0.5
// fastdl
sv_allowdownload 1
sv_allowupload 0
// sv_downloadurl "your url"
exec banned_user.cfg
exec banned_ip.cfg