add cron option and tweak ss

This commit is contained in:
finn committed 2026-11-13 10:43:16 -07:00
1 parent 9d2b5779bd
commit 86f55e1563
4 files changed
+69 -3

No files matched your search

+24 -2
View File
@@ -128,8 +128,12 @@ IMAGE="lloesche/valheim-server"
# ---------------------------------------------------------------------------
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y --no-install-recommends docker.io ca-certificates docker-cli
apt-get install -y --no-install-recommends docker.io ca-certificates docker-cli cron
systemctl enable --now docker
# cron is not started automatically by the docker.io package, and the
# manually maintained scripts on the volume (every_fifteen.sh, every_hour.sh)
# rely on it.
systemctl enable --now cron
# ---------------------------------------------------------------------------
# 2. Mount the Valheim volume.
@@ -167,6 +171,24 @@ fi
# ---------------------------------------------------------------------------
mkdir -p "$CONFIG_DIR" "$DATA_DIR"
# Install the root crontab that drives the manually maintained scripts on the
# volume. cron runs jobs from $HOME with a minimal environment, so the scripts
# are called by absolute path and the scripts themselves write their logs next
# to their own location. /etc/cron.d is used instead of `crontab -` because the
# file is overwritten on every deploy, so re-runs cannot accumulate duplicate
# entries, and the instance always matches this definition.
cat > /etc/cron.d/valheim-maintenance <<EOF
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
*/15 * * * * root ${VALHEIM_DIR}/every_fifteen.sh
0 * * * * root ${VALHEIM_DIR}/every_hour.sh
EOF
# cron ignores files that are not owned by root or that are group/world
# writable, and the heredoc above inherits root's umask.
chown root:root /etc/cron.d/valheim-maintenance
chmod 644 /etc/cron.d/valheim-maintenance
# ---------------------------------------------------------------------------
# 4. Start the Valheim server.
# --restart unless-stopped brings the server back after a reboot.
@@ -188,7 +210,7 @@ docker run -d \
-e SERVER_PASS="$SERVER_PASS" \
-e SERVER_PUBLIC="$SERVER_PUBLIC" \
-e CROSSPLAY="$SERVER_CROSSPLAY" \
-e SERVER_ARGS="-modifier resources more" \
-e SERVER_ARGS="-modifier resources muchmore -modifier deathpenalty easy" \
"$IMAGE"
echo "Valheim server started."