Copy env to bashrc and use -l with cron (#77)

* Copy env to bashrc and use -l with cron

* Create LICENSE (#80)

* Avoid compiling odin twice in dockerfile (#78)

Co-authored-by: Michael <12646562+mbround18@users.noreply.github.com>

* Copy env to bashrc and use -l with cron

* Odin placed in system usr/local

* Remove passing into bashrc

Co-authored-by: LovecraftianHorror <LovecraftianHorror@pm.me>
This commit is contained in:
Michael
2021-02-14 00:40:45 -08:00
committed by GitHub
parent 7260f7df2b
commit 2e3f1b2717
6 changed files with 30 additions and 19 deletions

View File

@@ -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 \

View File

@@ -68,6 +68,7 @@ This repo has a CLI tool called [Odin] in it! It is used for managing the server
- [#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.
- [#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):

View File

@@ -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

View File

@@ -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

View File

@@ -20,8 +20,6 @@ initialize () {
}
initialize "Installing Valheim via Odin..."
export PATH="/home/steam/.odin:$PATH"
log "Variables loaded....."
log "

View File

@@ -1,5 +1,3 @@
#!/usr/bin/env bash
export PATH="/home/steam/.odin:$PATH"
# Load Valheim base directory,
cd /home/steam/valheim || exit 1