diff --git a/Dockerfile b/Dockerfile index 8924343..5be750c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,13 +20,14 @@ RUN apk add dos2unix --update-cache --repository http://dl-3.alpinelinux.org/al # --------------- # FROM cm2network/steamcmd:root -RUN apt-get update \ - && apt-get install -y \ - htop net-tools nano \ - netcat curl wget \ - cron sudo gosu dos2unix \ - libsdl2-dev \ - && gosu nobody true \ +RUN apt-get update \ + && apt-get install -y \ + htop net-tools nano \ + netcat curl wget \ + cron sudo gosu dos2unix \ + libsdl2-2.0-0 \ + && rm -rf /var/lib/apt/lists/* \ + && gosu nobody true \ && dos2unix # Set up timezone information @@ -46,14 +47,15 @@ ENV AUTO_UPDATE_SCHEDULE "0 1 * * *" COPY --chmod=755 ./src/scripts/*.sh /home/steam/scripts/ COPY --chmod=755 ./src/scripts/entrypoint.sh /entrypoint.sh -COPY --from=RustBuilder --chmod=755 /data/odin/target/release /home/steam/.odin +COPY --from=RustBuilder --chmod=755 /data/odin/target/release /usr/local/odin COPY --chown=steam:steam ./src/scripts/steam_bashrc.sh /home/steam/.bashrc ENV PUID=1000 ENV PGID=1000 RUN usermod -u ${PUID} steam \ && groupmod -g ${PGID} steam \ - && chsh -s /bin/bash steam + && chsh -s /bin/bash steam \ + && ln -s /usr/local/odin/odin /usr/local/bin/odin HEALTHCHECK --interval=1m --timeout=3s \ diff --git a/README.md b/README.md index afefa34..c383678 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,8 @@ This repo has a CLI tool called [Odin] in it! It is used for managing the server - [#11] Added check for length of password and fail on odin install or odin stop failures. - [#24] Added public variable to dockerfile and odin - [#35] Fix for the server to now utilizing SIGINT `YOU WILL HAVE TO MANUALLY STOP YOUR SERVER;` use `pidof valheim_server.x86_64` to get the pid and then `kill -2 $pid` but replace pid with the pid from `pidof` - - [#53] Formatted scripts to be more useful and added timezone scheduling. + - [#53] Formatted scripts to be more useful and added timezone scheduling. + - [#77] Fix auto update not acknowledging variables and added odin to system bin. - 1.1.1 (Stable): - Includes PR [#10] to fix the double world argument. - 1.1.0 (Stable): diff --git a/src/scripts/auto_update.sh b/src/scripts/auto_update.sh index 3330832..a5a6aba 100644 --- a/src/scripts/auto_update.sh +++ b/src/scripts/auto_update.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash -export PATH="/home/steam/.odin:$PATH" +# Cron uses blank env and does not pick up /usr/local/bin files. +export PATH="/usr/local/bin:$PATH" log() { PREFIX="[Valheim][steam]" @@ -10,7 +11,18 @@ line () { } line -log "Auto Updater is running...." +log "Valheim Server - $(date)" +log "Starting auto update..." +log " +Port: ${PORT} +Name: ${NAME} +World: ${WORLD} +Public: ${PUBLIC} +Password: (REDACTED) +" +line + + cd /home/steam/valheim || exit 1 log "Stopping server..." odin stop || exit 1 diff --git a/src/scripts/entrypoint.sh b/src/scripts/entrypoint.sh index f6993b6..5a8469b 100644 --- a/src/scripts/entrypoint.sh +++ b/src/scripts/entrypoint.sh @@ -1,4 +1,6 @@ #!/usr/bin/env bash + +# Set up timezone ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone # shellcheck disable=SC2039 @@ -30,12 +32,10 @@ setup_cron() { log "Auto Update Enabled..." log "Schedule: ${AUTO_UPDATE_SCHEDULE}" AUTO_UPDATE_SCHEDULE=$(echo "$AUTO_UPDATE_SCHEDULE" | tr -d '"') - printf "%s /usr/sbin/gosu steam /bin/bash /home/steam/scripts/auto_update.sh 2>&1 | tee -a /home/steam/valheim/output.log" "${AUTO_UPDATE_SCHEDULE}" > /etc/cron.d/auto-update + printf "%s NAME=$NAME WORLD=$WORLD PORT=$PORT PASSWORD=$PASSWORD PUBLIC=$PUBLIC /usr/sbin/gosu steam /bin/bash /home/steam/scripts/auto_update.sh 2>&1 | tee -a /home/steam/valheim/output.log" "${AUTO_UPDATE_SCHEDULE}" > /etc/cron.d/auto-update echo "" >> /etc/cron.d/auto-update - # Give execution rights on the cron job chmod 0644 /etc/cron.d/auto-update - # Apply cron job crontab /etc/cron.d/auto-update set +f diff --git a/src/scripts/start_valheim.sh b/src/scripts/start_valheim.sh index caa1c7d..18487ac 100644 --- a/src/scripts/start_valheim.sh +++ b/src/scripts/start_valheim.sh @@ -20,8 +20,6 @@ initialize () { } initialize "Installing Valheim via Odin..." -export PATH="/home/steam/.odin:$PATH" - log "Variables loaded....." log " diff --git a/src/scripts/steam_bashrc.sh b/src/scripts/steam_bashrc.sh index e56beb8..14eef44 100644 --- a/src/scripts/steam_bashrc.sh +++ b/src/scripts/steam_bashrc.sh @@ -1,5 +1,3 @@ #!/usr/bin/env bash - -export PATH="/home/steam/.odin:$PATH" # Load Valheim base directory, cd /home/steam/valheim || exit 1