mirror of
https://github.com/mbround18/valheim-docker.git
synced 2021-10-22 21:53:54 +03:00
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:
20
Dockerfile
20
Dockerfile
@@ -20,13 +20,14 @@ RUN apk add dos2unix --update-cache --repository http://dl-3.alpinelinux.org/al
|
|||||||
# --------------- #
|
# --------------- #
|
||||||
FROM cm2network/steamcmd:root
|
FROM cm2network/steamcmd:root
|
||||||
|
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y \
|
&& apt-get install -y \
|
||||||
htop net-tools nano \
|
htop net-tools nano \
|
||||||
netcat curl wget \
|
netcat curl wget \
|
||||||
cron sudo gosu dos2unix \
|
cron sudo gosu dos2unix \
|
||||||
libsdl2-dev \
|
libsdl2-2.0-0 \
|
||||||
&& gosu nobody true \
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
|
&& gosu nobody true \
|
||||||
&& dos2unix
|
&& dos2unix
|
||||||
|
|
||||||
# Set up timezone information
|
# 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/*.sh /home/steam/scripts/
|
||||||
COPY --chmod=755 ./src/scripts/entrypoint.sh /entrypoint.sh
|
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
|
COPY --chown=steam:steam ./src/scripts/steam_bashrc.sh /home/steam/.bashrc
|
||||||
|
|
||||||
ENV PUID=1000
|
ENV PUID=1000
|
||||||
ENV PGID=1000
|
ENV PGID=1000
|
||||||
RUN usermod -u ${PUID} steam \
|
RUN usermod -u ${PUID} steam \
|
||||||
&& groupmod -g ${PGID} 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 \
|
HEALTHCHECK --interval=1m --timeout=3s \
|
||||||
|
|||||||
@@ -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.
|
- [#11] Added check for length of password and fail on odin install or odin stop failures.
|
||||||
- [#24] Added public variable to dockerfile and odin
|
- [#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`
|
- [#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):
|
- 1.1.1 (Stable):
|
||||||
- Includes PR [#10] to fix the double world argument.
|
- Includes PR [#10] to fix the double world argument.
|
||||||
- 1.1.0 (Stable):
|
- 1.1.0 (Stable):
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/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() {
|
log() {
|
||||||
PREFIX="[Valheim][steam]"
|
PREFIX="[Valheim][steam]"
|
||||||
@@ -10,7 +11,18 @@ line () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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
|
cd /home/steam/valheim || exit 1
|
||||||
log "Stopping server..."
|
log "Stopping server..."
|
||||||
odin stop || exit 1
|
odin stop || exit 1
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Set up timezone
|
||||||
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone
|
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone
|
||||||
|
|
||||||
# shellcheck disable=SC2039
|
# shellcheck disable=SC2039
|
||||||
@@ -30,12 +32,10 @@ setup_cron() {
|
|||||||
log "Auto Update Enabled..."
|
log "Auto Update Enabled..."
|
||||||
log "Schedule: ${AUTO_UPDATE_SCHEDULE}"
|
log "Schedule: ${AUTO_UPDATE_SCHEDULE}"
|
||||||
AUTO_UPDATE_SCHEDULE=$(echo "$AUTO_UPDATE_SCHEDULE" | tr -d '"')
|
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
|
echo "" >> /etc/cron.d/auto-update
|
||||||
|
|
||||||
# Give execution rights on the cron job
|
# Give execution rights on the cron job
|
||||||
chmod 0644 /etc/cron.d/auto-update
|
chmod 0644 /etc/cron.d/auto-update
|
||||||
|
|
||||||
# Apply cron job
|
# Apply cron job
|
||||||
crontab /etc/cron.d/auto-update
|
crontab /etc/cron.d/auto-update
|
||||||
set +f
|
set +f
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ initialize () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initialize "Installing Valheim via Odin..."
|
initialize "Installing Valheim via Odin..."
|
||||||
export PATH="/home/steam/.odin:$PATH"
|
|
||||||
|
|
||||||
|
|
||||||
log "Variables loaded....."
|
log "Variables loaded....."
|
||||||
log "
|
log "
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
export PATH="/home/steam/.odin:$PATH"
|
|
||||||
# Load Valheim base directory,
|
# Load Valheim base directory,
|
||||||
cd /home/steam/valheim || exit 1
|
cd /home/steam/valheim || exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user