From 26b0c08c8da554c825b4d573103ea037e1a0ca10 Mon Sep 17 00:00:00 2001 From: Ethorbit Date: Wed, 27 Dec 2023 06:31:30 -0800 Subject: [PATCH] Improve for new servers --- Dockerfile | 23 ++++++--- Makefile | 4 +- README.md | 24 ++++++---- servers/gmod-server/Dockerfile | 2 +- servers/gmod-server/start.sh | 4 +- servers/hldm-server/Dockerfile | 9 ++-- servers/hldm-server/start.sh | 2 +- servers/hldm-server/steam_update_append.txt | 7 +++ servers/svencoop-server-with-dlc/Dockerfile | 22 +++++++++ servers/svencoop-server-with-dlc/paid.sh | 23 +++++++++ servers/svencoop-server-with-dlc/start.sh | 3 ++ .../steam_update_append.txt | 7 +++ servers/svencoop-server/Dockerfile | 2 +- servers/svencoop-server/start.sh | 3 +- servers/synergy-server-with-dlc/Dockerfile | 16 +++++++ servers/synergy-server-with-dlc/start.sh | 2 + .../steam_update_append.txt | 11 +++++ .../synergy/synergy/cfg/server.cfg | 1 + .../synergy/synergy/mount.cache | 1 + servers/synergy-server/Dockerfile | 15 ++++++ servers/synergy-server/start.sh | 2 + .../synergy-server/steam_update_append.txt | 5 ++ start.sh | 48 +++++++++++-------- 23 files changed, 186 insertions(+), 50 deletions(-) create mode 100644 servers/hldm-server/steam_update_append.txt create mode 100644 servers/svencoop-server-with-dlc/Dockerfile create mode 100644 servers/svencoop-server-with-dlc/paid.sh create mode 100644 servers/svencoop-server-with-dlc/start.sh create mode 100644 servers/svencoop-server-with-dlc/steam_update_append.txt create mode 100644 servers/synergy-server-with-dlc/Dockerfile create mode 100644 servers/synergy-server-with-dlc/start.sh create mode 100644 servers/synergy-server-with-dlc/steam_update_append.txt create mode 100644 servers/synergy-server-with-dlc/synergy/synergy/cfg/server.cfg create mode 100644 servers/synergy-server-with-dlc/synergy/synergy/mount.cache create mode 100644 servers/synergy-server/Dockerfile create mode 100644 servers/synergy-server/start.sh create mode 100644 servers/synergy-server/steam_update_append.txt diff --git a/Dockerfile b/Dockerfile index cab698d..6a3f62d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,23 +2,30 @@ FROM cm2network/steamcmd USER root ARG PUID=1000 ARG PGID=1000 + +# Some games will require a login which can only be done interactively thanks to things like 2FA codes. +# If a username is needed, you will need to start the image interactively the first time to login for the install. +ENV STEAMCMD_LOGIN_USERNAME="anonymous" + # Umask for files created by steamcmd during server installs # It will NOT cover files that are created by server executables! ENV UMASK=027 ENV HOME_DIR=${HOMEDIR} ENV STEAMCMD_DIR=${STEAMCMDDIR} -ENV SERVER_DIR="${HOMEDIR}/server" -# IMAGE_DIR are files that are moved into SERVER_DIR at runtime +ENV SERVERS_DIR="${HOMEDIR}/Steam/steamapps/common" +# IMAGE_DIR are files that are moved into SERVERS_DIR at runtime # The purpose of it is for baking custom start/update scripts into your # images and having them still appear in the server/ volume. ENV IMAGE_DIR="/image" -# For referencing inside server scripts in conjunction with IMAGE_DIR / SERVER_DIR. +# For referencing inside server scripts in conjunction with IMAGE_DIR / SERVERS_DIR. # This just allows us to give them different names in the future. ENV STEAMCMD_UPDATE_SCRIPT="steam_update.txt" +ENV STEAMCMD_APPEND_SCRIPT="steam_update_append.txt" ENV UPDATE_SCRIPT="update.sh" ENV START_SCRIPT="start.sh" # You need to integrate these in your server images ENV APP_ID= +ENV SERVER_DIR= ENV START_ARGS= COPY /start.sh /start.sh RUN usermod -u ${PUID} ${USER} &&\ @@ -26,9 +33,11 @@ RUN usermod -u ${PUID} ${USER} &&\ chown ${USER}:${USER} /start.sh &&\ chmod +x /start.sh &&\ mkdir "${IMAGE_DIR}" &&\ - mkdir "${SERVER_DIR}" &&\ - chown ${USER}:${USER} "${IMAGE_DIR}" &&\ - chown ${USER}:${USER} "${SERVER_DIR}" -WORKDIR "${SERVER_DIR}" + mkdir -p "${SERVERS_DIR}" &&\ + chown -R ${USER}:${USER} "${HOME_DIR}/" &&\ + chown ${USER}:${USER} "${IMAGE_DIR}" +WORKDIR "${SERVERS_DIR}" +VOLUME "${SERVERS_DIR}" +VOLUME /server USER ${USER} CMD ["/start.sh"] diff --git a/Makefile b/Makefile index fd43831..81fb860 100644 --- a/Makefile +++ b/Makefile @@ -6,13 +6,13 @@ git_hash := $(shell git rev-parse --short HEAD) build: docker build -t steamcmd-server ./ - find $(files) -maxdepth 1 -type d -exec \ + find $(files) -maxdepth 0 -type d -exec \ /bin/sh -c 'dirname=$$(basename {}) &&\ docker build -t $$dirname -t $(docker_user)/$$dirname:latest -t $(docker_user)/$$dirname:$(git_hash) {} &&\ docker volume rm -f $$dirname' \; test: - docker run -it --rm -p 27015/udp $(options) -v $(image):/home/steam/server --name $(image) $(image) $(command) + docker run -it --rm -p 27015/udp -p 27015/tcp $(options) -v $(image):/server --name $(image) $(image) $(command) push: find $(files) -maxdepth 1 -type d -exec \ diff --git a/README.md b/README.md index e810fbb..79c9b49 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,9 @@ See the [existing implementations](servers) ## Creating container from [existing server image](servers) `make build` -`docker run -it --rm -e START_ARGS="" -p 27015:27015/udp -v myserver:/home/steam/server ` +`docker run -it --rm -e START_ARGS="" -p 27015:27015/tcp -p 27015:27015/udp -v myserver:/home/steam/Steam/steamapps/common ` + +Add `-e STEAMCMD_LOGIN_USERNAME=username-here` and interactively login on first run if you get a susbcription or owner error. You can also look for pre-built images [here](https://hub.docker.com/u/ethorbit). @@ -19,6 +21,7 @@ You can also look for pre-built images [here](https://hub.docker.com/u/ethorbit) * Create a new game directory inside servers/ (this doubles as the image name) * Build everything: `make build` * Test it: `image= make test` +* If a login error is received during testing, test using a Steam account that owns the content: `image= options='-e STEAMCMD_LOGIN_USERNAME=yoursteamname' make test` * Upload changes by changing the Makefile's docker\_user to match your DockerHub username and running: `make push` * [Create a pull request](https://github.com/Ethorbit/steamcmd-server-docker/pulls) to add the image to this repo. @@ -26,11 +29,14 @@ You can also look for pre-built images [here](https://hub.docker.com/u/ethorbit) These variables should be used whereever possible. * `USER` * `HOME_DIR` -* `STEAMCMD_DIR` - where steamcmd binaries are -* `SERVER_DIR` - where the server installs -* `IMAGE_DIR` - where files baked into the server image are (like a start or update script), they are copied to SERVER\_DIR on container start -* `STEAMCMD_UPDATE_SCRIPT` - txt update file using steamcmd update syntax -* `UPDATE_SCRIPT` - shell script that executes STEAMCMD\_UPDATE\_SCRIPT -* `START_SCRIPT` - shell script to start the game server -* `START_ARGS` - arguments of the server executable which would be read in START\_SCRIPT -* `APP_ID` - game server's appid +* `STEAMCMD_DIR` - where steamcmd binaries are +* `SERVERS_DIR` - where the server(s) that are installed go +* `SERVER_DIR` - the server that is going to run +* `IMAGE_DIR` - where files baked into the server image are (like a start or update script), they are copied to SERVER\_DIR on container start +* `STEAMCMD_LOGIN_USERNAME` - the steam username of the account that owns the game +* `STEAMCMD_UPDATE_SCRIPT` - txt update file using steamcmd update syntax +* `STEAMCMD_APPEND_SCRIPT` - txt update file that is appended to the default txt file (instructions are run after login) +* `UPDATE_SCRIPT` - shell script that executes STEAMCMD\_UPDATE\_SCRIPT +* `START_SCRIPT` - shell script to start the game server +* `START_ARGS` - arguments of the server executable which would be read in START\_SCRIPT +* `APP_ID` - game server's appid diff --git a/servers/gmod-server/Dockerfile b/servers/gmod-server/Dockerfile index d15ba44..6b80124 100644 --- a/servers/gmod-server/Dockerfile +++ b/servers/gmod-server/Dockerfile @@ -1,6 +1,7 @@ FROM steamcmd-server USER root ENV APP_ID=4020 +ENV SERVER_DIR="${SERVERS_DIR}/GarrysModDS" COPY ./start.sh "${IMAGE_DIR}/${START_SCRIPT}" RUN chown ${USER}:${USER} "${IMAGE_DIR}/${START_SCRIPT}" &&\ chmod +x "${IMAGE_DIR}/${START_SCRIPT}" &&\ @@ -11,5 +12,4 @@ RUN chown ${USER}:${USER} "${IMAGE_DIR}/${START_SCRIPT}" &&\ libncurses5:i386 &&\ apt-get remove --purge --auto-remove -y &&\ rm -rf /var/lib/apt/lists/* -VOLUME "${SERVER_DIR}" USER ${USER} diff --git a/servers/gmod-server/start.sh b/servers/gmod-server/start.sh index 946d71f..c945066 100644 --- a/servers/gmod-server/start.sh +++ b/servers/gmod-server/start.sh @@ -1,3 +1,3 @@ -#!/bin/bash -"${SERVER_DIR}/srcds_run" -autoupdate -steam_dir "${STEAMCMD_DIR}" -steamcmd_script "${SERVER_DIR}/${STEAMCMD_UPDATE_SCRIPT}" "${START_ARGS}" +#!/bin/bash +"${SERVER_DIR}/srcds_run" -autoupdate -steam_dir "${STEAMCMD_DIR}" -steamcmd_script "${SERVERS_DIR}/${STEAMCMD_UPDATE_SCRIPT}" "${START_ARGS}" diff --git a/servers/hldm-server/Dockerfile b/servers/hldm-server/Dockerfile index d80267e..8f826d3 100644 --- a/servers/hldm-server/Dockerfile +++ b/servers/hldm-server/Dockerfile @@ -1,12 +1,9 @@ FROM steamcmd-server USER root ENV APP_ID=90 +ENV SERVER_DIR="${SERVERS_DIR}/Half-Life" COPY ./start.sh "${IMAGE_DIR}/${START_SCRIPT}" +COPY ./steam_update_append.txt "${IMAGE_DIR}/${STEAMCMD_APPEND_SCRIPT}" RUN chown ${USER}:${USER} "${IMAGE_DIR}/${START_SCRIPT}" &&\ - chmod +x "${IMAGE_DIR}/${START_SCRIPT}" &&\ - echo "Like with all Valve products, HLDS is broken! (It will not download all the files.)" &&\ - echo "We will now override the default install script with one that does literally the same thing, except multiple times, to ensure that ALL files are (hopefully) downloaded!" &&\ - printf '@NoPromptForPassword 1\nforce_install_dir "%s"\nlogin anonymous\napp_update %i\napp_update %i validate\napp_update %i validate\nquit' \ - "$SERVER_DIR" "$APP_ID" "$APP_ID" "$APP_ID" >> "$IMAGE_DIR/$STEAMCMD_UPDATE_SCRIPT" -VOLUME "${SERVER_DIR}" + chmod +x "${IMAGE_DIR}/${START_SCRIPT}" USER ${USER} diff --git a/servers/hldm-server/start.sh b/servers/hldm-server/start.sh index 2c532c9..04bb2c1 100644 --- a/servers/hldm-server/start.sh +++ b/servers/hldm-server/start.sh @@ -1,2 +1,2 @@ #!/bin/bash -"${SERVER_DIR}/hlds_run" -autoupdate -steam_dir "${STEAMCMD_DIR}" -steamcmd_script "${SERVER_DIR}/${STEAMCMD_UPDATE_SCRIPT}" "${START_ARGS}" +"${SERVER_DIR}/hlds_run" -autoupdate -steam_dir "${STEAMCMD_DIR}" -steamcmd_script "${SERVERS_DIR}/${STEAMCMD_UPDATE_SCRIPT}" +map crossfire "${START_ARGS}" diff --git a/servers/hldm-server/steam_update_append.txt b/servers/hldm-server/steam_update_append.txt new file mode 100644 index 0000000..42f1498 --- /dev/null +++ b/servers/hldm-server/steam_update_append.txt @@ -0,0 +1,7 @@ +app_update 90 +app_update 90 +app_update 90 +app_update validate 90 +app_update validate 90 +app_update validate 90 +quit diff --git a/servers/svencoop-server-with-dlc/Dockerfile b/servers/svencoop-server-with-dlc/Dockerfile new file mode 100644 index 0000000..98ed20c --- /dev/null +++ b/servers/svencoop-server-with-dlc/Dockerfile @@ -0,0 +1,22 @@ +FROM steamcmd-server +USER root +ENV APP_ID=276060 +ENV SERVER_DIR="${SERVERS_DIR}/Sven Co-op Dedicated Server" +ENV PAID_SCRIPT="paid.sh" +COPY ./paid.sh "${IMAGE_DIR}/${PAID_SCRIPT}" +COPY ./start.sh "${IMAGE_DIR}/${START_SCRIPT}" +COPY ./steam_update_append.txt "${IMAGE_DIR}/${STEAMCMD_APPEND_SCRIPT}" +RUN chown ${USER}:${USER} "${IMAGE_DIR}/${START_SCRIPT}" &&\ + chmod +x "${IMAGE_DIR}/${START_SCRIPT}" &&\ + chmod +x "${IMAGE_DIR}/${PAID_SCRIPT}" &&\ + export DEBIAN_FRONTEND=noninteractive &&\ + dpkg --add-architecture i386 &&\ + apt update &&\ + apt-get install -y --no-install-recommends --no-install-suggests \ + wget \ + libssl-dev libssl-dev:i386 \ + zlib1g:i386 \ + unzip &&\ + apt-get remove --purge --auto-remove -y &&\ + rm -rf /var/lib/apt/lists/* +USER ${USER} diff --git a/servers/svencoop-server-with-dlc/paid.sh b/servers/svencoop-server-with-dlc/paid.sh new file mode 100644 index 0000000..ce16df9 --- /dev/null +++ b/servers/svencoop-server-with-dlc/paid.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +if [ ! -f "${SERVERS_DIR}/.server_installed_dlc_successfully.txt" ]; then + echo "Installing DLC..." + cd "${SERVER_DIR}/svencoop" + + install_opposing_force() + { + echo "Installing Opposing Force.." + ./Install_OpFor_Support.sh + } + + install_blueshift() + { + echo "Installing Blue Shift.." + ./Install_bshift_Support.sh + } + + install_opposing_force + install_blueshift + touch "${SERVERS_DIR}/.server_installed_dlc_successfully.txt" + cd "${SERVER_DIR}" +fi diff --git a/servers/svencoop-server-with-dlc/start.sh b/servers/svencoop-server-with-dlc/start.sh new file mode 100644 index 0000000..adbb3a3 --- /dev/null +++ b/servers/svencoop-server-with-dlc/start.sh @@ -0,0 +1,3 @@ +#!/bin/bash +"${SERVERS_DIR}/${PAID_SCRIPT}" +"${SERVER_DIR}/svends_run" -autoupdate -steam_dir "${STEAMCMD_DIR}" -steamcmd_script "${SERVERS_DIR}/${STEAMCMD_UPDATE_SCRIPT}" "${START_ARGS}" diff --git a/servers/svencoop-server-with-dlc/steam_update_append.txt b/servers/svencoop-server-with-dlc/steam_update_append.txt new file mode 100644 index 0000000..7d66991 --- /dev/null +++ b/servers/svencoop-server-with-dlc/steam_update_append.txt @@ -0,0 +1,7 @@ +app_update 276060 +app_update 50 +app_update 130 +app_update validate 276060 +app_update validate 50 +app_update validate 130 +quit diff --git a/servers/svencoop-server/Dockerfile b/servers/svencoop-server/Dockerfile index 7091baf..44d326c 100644 --- a/servers/svencoop-server/Dockerfile +++ b/servers/svencoop-server/Dockerfile @@ -1,6 +1,7 @@ FROM steamcmd-server USER root ENV APP_ID=276060 +ENV SERVER_DIR="${SERVERS_DIR}/Sven Co-op Dedicated Server" COPY ./start.sh "${IMAGE_DIR}/${START_SCRIPT}" RUN chown ${USER}:${USER} "${IMAGE_DIR}/${START_SCRIPT}" &&\ chmod +x "${IMAGE_DIR}/${START_SCRIPT}" &&\ @@ -13,5 +14,4 @@ RUN chown ${USER}:${USER} "${IMAGE_DIR}/${START_SCRIPT}" &&\ zlib1g:i386 &&\ apt-get remove --purge --auto-remove -y &&\ rm -rf /var/lib/apt/lists/* -VOLUME "${SERVER_DIR}" USER ${USER} diff --git a/servers/svencoop-server/start.sh b/servers/svencoop-server/start.sh index 41e33fe..ca45abb 100644 --- a/servers/svencoop-server/start.sh +++ b/servers/svencoop-server/start.sh @@ -1,3 +1,2 @@ #!/bin/bash -"${SERVER_DIR}/svends_run" -autoupdate -steam_dir "${STEAMCMD_DIR}" -steamcmd_script "${SERVER_DIR}/${STEAMCMD_UPDATE_SCRIPT}" "${START_ARGS}" - +"${SERVER_DIR}/svends_run" -autoupdate -steam_dir "${STEAMCMD_DIR}" -steamcmd_script "${SERVERS_DIR}/${STEAMCMD_UPDATE_SCRIPT}" "${START_ARGS}" diff --git a/servers/synergy-server-with-dlc/Dockerfile b/servers/synergy-server-with-dlc/Dockerfile new file mode 100644 index 0000000..168ba8f --- /dev/null +++ b/servers/synergy-server-with-dlc/Dockerfile @@ -0,0 +1,16 @@ +FROM steamcmd-server +USER root +ENV APP_ID=17520 +ENV SERVER_DIR="${SERVERS_DIR}/synergy" +COPY ./synergy "${IMAGE_DIR}/synergy" +COPY ./start.sh "${IMAGE_DIR}/${START_SCRIPT}" +COPY ./steam_update_append.txt "${IMAGE_DIR}/${STEAMCMD_APPEND_SCRIPT}" +RUN chown ${USER}:${USER} "${IMAGE_DIR}/${START_SCRIPT}" &&\ + chmod +x "${IMAGE_DIR}/${START_SCRIPT}" &&\ + dpkg --add-architecture i386 &&\ + apt update &&\ + apt-get install -y --no-install-suggests --no-install-recommends \ + libtinfo5:i386 &&\ + apt-get remove --purge --auto-remove -y &&\ + rm -rf /var/lib/apt/lists/* +USER ${USER} diff --git a/servers/synergy-server-with-dlc/start.sh b/servers/synergy-server-with-dlc/start.sh new file mode 100644 index 0000000..74ae99e --- /dev/null +++ b/servers/synergy-server-with-dlc/start.sh @@ -0,0 +1,2 @@ +#!/bin/bash +"${SERVER_DIR}/srcds_run" -game synergy -autoupdate -steam_dir "${STEAMCMD_DIR}" -steamcmd_script "${SERVERS_DIR}/${STEAMCMD_UPDATE_SCRIPT}" +map d1_trainstation_01 "${START_ARGS}" diff --git a/servers/synergy-server-with-dlc/steam_update_append.txt b/servers/synergy-server-with-dlc/steam_update_append.txt new file mode 100644 index 0000000..84d00b0 --- /dev/null +++ b/servers/synergy-server-with-dlc/steam_update_append.txt @@ -0,0 +1,11 @@ +app_update 17520 +app_update 220 +app_update 380 +app_update 420 +app_update 340 +app_update 17520 validate +app_update 220 validate +app_update 380 validate +app_update 420 validate +app_update 340 validate +quit diff --git a/servers/synergy-server-with-dlc/synergy/synergy/cfg/server.cfg b/servers/synergy-server-with-dlc/synergy/synergy/cfg/server.cfg new file mode 100644 index 0000000..5ef2eee --- /dev/null +++ b/servers/synergy-server-with-dlc/synergy/synergy/cfg/server.cfg @@ -0,0 +1 @@ +sv_content_optional "hl2 ep1 ep2 lost" diff --git a/servers/synergy-server-with-dlc/synergy/synergy/mount.cache b/servers/synergy-server-with-dlc/synergy/synergy/mount.cache new file mode 100644 index 0000000..09a48dc --- /dev/null +++ b/servers/synergy-server-with-dlc/synergy/synergy/mount.cache @@ -0,0 +1 @@ +hl2 ep1 ep2 lost diff --git a/servers/synergy-server/Dockerfile b/servers/synergy-server/Dockerfile new file mode 100644 index 0000000..d92570b --- /dev/null +++ b/servers/synergy-server/Dockerfile @@ -0,0 +1,15 @@ +FROM steamcmd-server +USER root +ENV APP_ID=17520 +ENV SERVER_DIR="${SERVERS_DIR}/Synergy" +COPY ./start.sh "${IMAGE_DIR}/${START_SCRIPT}" +COPY ./steam_update_append.txt "${IMAGE_DIR}/${STEAMCMD_APPEND_SCRIPT}" +RUN chown ${USER}:${USER} "${IMAGE_DIR}/${START_SCRIPT}" &&\ + chmod +x "${IMAGE_DIR}/${START_SCRIPT}" &&\ + dpkg --add-architecture i386 &&\ + apt update &&\ + apt-get install -y --no-install-suggests --no-install-recommends \ + libtinfo5:i386 &&\ + apt-get remove --purge --auto-remove -y &&\ + rm -rf /var/lib/apt/lists/* +USER ${USER} diff --git a/servers/synergy-server/start.sh b/servers/synergy-server/start.sh new file mode 100644 index 0000000..74ae99e --- /dev/null +++ b/servers/synergy-server/start.sh @@ -0,0 +1,2 @@ +#!/bin/bash +"${SERVER_DIR}/srcds_run" -game synergy -autoupdate -steam_dir "${STEAMCMD_DIR}" -steamcmd_script "${SERVERS_DIR}/${STEAMCMD_UPDATE_SCRIPT}" +map d1_trainstation_01 "${START_ARGS}" diff --git a/servers/synergy-server/steam_update_append.txt b/servers/synergy-server/steam_update_append.txt new file mode 100644 index 0000000..f8f16c4 --- /dev/null +++ b/servers/synergy-server/steam_update_append.txt @@ -0,0 +1,5 @@ +app_update 17520 +app_update 220 +app_update 17520 validate +app_update 220 validate +quit diff --git a/start.sh b/start.sh index 22ffbc1..8ef813d 100644 --- a/start.sh +++ b/start.sh @@ -3,50 +3,60 @@ umask "$UMASK" # Copy all files/dirs baked inside the server image into the server volume # If the file/dir already exists, it won't make its way to the volume. -find "$IMAGE_DIR/" -mindepth 1 -maxdepth 1 -exec /bin/bash -c "cp -nar {} '$SERVER_DIR/'" \; +find "$IMAGE_DIR/" -mindepth 1 -maxdepth 1 -exec /bin/bash -c "cp -nar {} '$SERVERS_DIR/'" \; # Create defaults for scripts that are not baked into the server image -if [[ ! -f "$SERVER_DIR/$STEAMCMD_UPDATE_SCRIPT" ]]; then - if [[ -z "$APP_ID" ]]; then +if [ ! -f "$SERVERS_DIR/$STEAMCMD_UPDATE_SCRIPT" ]; then + if [ -z "$APP_ID" ]; then echo "Can't install! No App ID specified!" exit fi - printf '@NoPromptForPassword 1\nforce_install_dir "%s"\nlogin anonymous\napp_update %i validate\nquit' \ - "$SERVER_DIR" "$APP_ID" >> "$SERVER_DIR/$STEAMCMD_UPDATE_SCRIPT" - chmod +x "$SERVER_DIR/$STEAMCMD_UPDATE_SCRIPT" + if [ -z "$STEAMCMD_LOGIN_USERNAME" ] || [ "$STEAMCMD_LOGIN_USERNAME" = "anonymous" ]; then + printf '@NoPromptForPassword\nlogin anonymous\n' >> "$SERVERS_DIR/$STEAMCMD_UPDATE_SCRIPT" + else + printf 'login %s\n' "$STEAMCMD_LOGIN_USERNAME" >> "$SERVERS_DIR/$STEAMCMD_UPDATE_SCRIPT" + fi + + if [ ! -f "$STEAMCMD_APPEND_SCRIPT" ]; then + printf 'app_update %i\napp_update %i validate\nquit' "$APP_ID" "$APP_ID" >> "$SERVERS_DIR/$STEAMCMD_UPDATE_SCRIPT" + else + cat "$STEAMCMD_APPEND_SCRIPT" >> "$SERVERS_DIR/$STEAMCMD_UPDATE_SCRIPT" + rm "$STEAMCMD_APPEND_SCRIPT" # Not needed anymore, users will edit steam_update.txt if they wanna make changes + fi + + chmod +x "$SERVERS_DIR/$STEAMCMD_UPDATE_SCRIPT" fi -if [[ ! -f "$SERVER_DIR/$UPDATE_SCRIPT" ]]; then +if [ ! -f "$SERVERS_DIR/$UPDATE_SCRIPT" ]; then printf '#!/bin/bash\n"%s" +runscript "%s"' \ - "$STEAMCMD_DIR/steamcmd.sh" "$SERVER_DIR/$STEAMCMD_UPDATE_SCRIPT" >> "$SERVER_DIR/$UPDATE_SCRIPT" - chmod +x "$SERVER_DIR/$UPDATE_SCRIPT" + "$STEAMCMD_DIR/steamcmd.sh" "$SERVERS_DIR/$STEAMCMD_UPDATE_SCRIPT" >> "$SERVERS_DIR/$UPDATE_SCRIPT" + chmod +x "$SERVERS_DIR/$UPDATE_SCRIPT" fi -if [[ ! -f "$SERVER_DIR/$START_SCRIPT" ]]; then - printf '#!/bin/bash\n# Your server start command here' >> "$SERVER_DIR/$START_SCRIPT" - chmod +x "$SERVER_DIR/$START_SCRIPT" +if [ ! -f "$SERVERS_DIR/$START_SCRIPT" ]; then + printf '#!/bin/bash\n# Your server start command here' >> "$SERVERS_DIR/$START_SCRIPT" + chmod +x "$SERVERS_DIR/$START_SCRIPT" fi function start_server { + cd "$SERVER_DIR/" echo "Starting server..." - "$SERVER_DIR/$START_SCRIPT" + "$SERVERS_DIR/$START_SCRIPT" } function install_server { echo "Installing server..." - "$SERVER_DIR/$UPDATE_SCRIPT" + "$SERVERS_DIR/$UPDATE_SCRIPT" } -cd "$SERVER_DIR/" - # There's probably a MUCH better way to check if a server installed successfully. # Feel free to improve this. -if [[ ! -f "${SERVER_DIR}/.server_installed_successfully" ]]; then +if [ ! -f "${SERVERS_DIR}/.server_installed_successfully" ]; then install_server - if [[ $? -eq 0 ]]; then - touch "${SERVER_DIR}/.server_installed_successfully" + if [ $? -eq 0 ]; then + touch "${SERVERS_DIR}/.server_installed_successfully" else echo "Server failed to install ($?)" exit $?