+ split docker images successful

This commit is contained in:
Lucas Briese
2019-07-21 23:04:00 +02:00
parent 62ef6948a1
commit df253d53e1
24 changed files with 775 additions and 17 deletions

40
gmod/Dockerfile Normal file
View File

@ -0,0 +1,40 @@
FROM jusito/docker-ttt:lgsm_debian
EXPOSE 27015/udp 27015/tcp
# Const \\ Overwrite Env \\ Configs optional \\ Configs needed
ENV CSS_PATH="/home/steam/addons/css" \
HL2_PATH="/home/steam/addons/hl2" \
HLDM_PATH="/home/steam/addons/hldm" \
TF2_PATH="/home/steam/addons/tf2" \
\
\
SERVER_EXECUTABLE="gmodserver" \
SERVER_GAME="gmodserver" \
\
\
WORKSHOP_COLLECTION_ID= \
SERVER_NAME="" \
SERVER_PASSWORD="" \
SERVER_VOICE_ENABLE="1" \
\
INSTALL_CSS=false \
INSTALL_HL2=false \
INSTALL_HLDM=false \
INSTALL_TF2=false \
\
USE_MY_REPLACER_CONFIG=false \
\
\
SERVER_GAMEMODE=""
COPY ["prepareServer.sh", "initConfig.sh", "forceWorkshopDownload.sh", "installAndMountAddons.sh", "/home/"]
RUN chown "$DOCKER_USER:$DOCKER_USER" /home/prepareServer.sh && \
chown "$DOCKER_USER:$DOCKER_USER" /home/initConfig.sh && \
chown "$DOCKER_USER:$DOCKER_USER" /home/forceWorkshopDownload.sh && \
chown "$DOCKER_USER:$DOCKER_USER" /home/installAndMountAddons.sh && \
chmod a=rx /home/prepareServer.sh && \
chmod a=rx /home/initConfig.sh && \
chmod a=rx /home/forceWorkshopDownload.sh && \
chmod a=rx /home/installAndMountAddons.sh

View File

@ -0,0 +1,34 @@
#!/bin/bash
if [ "${DEBUGGING}" = "true" ]; then
set -o xtrace
fi
set -o errexit
set -o nounset
set -o pipefail
#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

60
gmod/initConfig.sh Normal file
View File

@ -0,0 +1,60 @@
#!/bin/bash
if [ "${DEBUGGING}" = "true" ]; then
set -o xtrace
fi
set -o errexit
set -o nounset
set -o pipefail
function configReplace() {
source="$1"
target="$source \"$2\""
count=$(grep -Poc "($source).+" "${SERVER_PATH}/garrysmod/cfg/server.cfg")
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 -oc '[^[:space:]]' "${SERVER_PATH}/garrysmod/cfg/server.cfg")" ]; then
mkdir -p "${SERVER_PATH}/garrysmod/cfg" || true
cp -f "/home/server.cfg.default" "${SERVER_PATH}/garrysmod/cfg/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
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

View File

@ -0,0 +1,54 @@
#!/bin/bash
if [ "${DEBUGGING}" = "true" ]; then
set -o xtrace
fi
set -o errexit
set -o nounset
set -o pipefail
cd "$STEAM_CMD"
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}$'}\n'
if [ ! -e "${SERVER_PATH}/garrysmod/cfg" ]; then
mkdir -p "${SERVER_PATH}/garrysmod/cfg"
fi
if [ -e "${SERVER_PATH}/garrysmod/cfg/mount.cfg" ]; then
rm "${SERVER_PATH}/garrysmod/cfg/mount.cfg"
fi
touch "${SERVER_PATH}/garrysmod/cfg/mount.cfg"
echo "$mount" > "${SERVER_PATH}/garrysmod/cfg/mount.cfg"

33
gmod/prepareServer.sh Normal file
View File

@ -0,0 +1,33 @@
#!/bin/sh
if [ "${DEBUGGING}" = "true" ]; then
set -o xtrace
fi
set -o errexit
set -o nounset
#./prepareServer.sh: 9: set: Illegal option -o pipefail
#set -o pipefail
cd "/home"
echo "check configurations"
./initConfig.sh
echo "force workshop download"
./forceWorkshopDownload.sh
echo "install & mount gamefiles"
./installAndMountAddons.sh
cd "$STEAM_PATH"
#docker args -> lgsm args
temp=""
temp=$(printf "%s " "$@") || true
export parms="-game garrysmod $SERVER_GAMEMODE $temp"
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"