add cron option and tweak ss
This commit is contained in:
1 parent
9d2b5779bd
commit
86f55e1563
4 files changed
+69
-3
No files matched your search
@@ -128,8 +128,12 @@ IMAGE="lloesche/valheim-server"
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
apt-get update
|
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
|
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.
|
# 2. Mount the Valheim volume.
|
||||||
@@ -167,6 +171,24 @@ fi
|
|||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
mkdir -p "$CONFIG_DIR" "$DATA_DIR"
|
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.
|
# 4. Start the Valheim server.
|
||||||
# --restart unless-stopped brings the server back after a reboot.
|
# --restart unless-stopped brings the server back after a reboot.
|
||||||
@@ -188,7 +210,7 @@ docker run -d \
|
|||||||
-e SERVER_PASS="$SERVER_PASS" \
|
-e SERVER_PASS="$SERVER_PASS" \
|
||||||
-e SERVER_PUBLIC="$SERVER_PUBLIC" \
|
-e SERVER_PUBLIC="$SERVER_PUBLIC" \
|
||||||
-e CROSSPLAY="$SERVER_CROSSPLAY" \
|
-e CROSSPLAY="$SERVER_CROSSPLAY" \
|
||||||
-e SERVER_ARGS="-modifier resources more" \
|
-e SERVER_ARGS="-modifier resources muchmore -modifier deathpenalty easy" \
|
||||||
"$IMAGE"
|
"$IMAGE"
|
||||||
|
|
||||||
echo "Valheim server started."
|
echo "Valheim server started."
|
||||||
|
|||||||
+21
-1
@@ -45,7 +45,13 @@ FIREWALL_ID="165767433"
|
|||||||
# v3, adds crossplay
|
# v3, adds crossplay
|
||||||
#STACKSCRIPT_ID="2226356"
|
#STACKSCRIPT_ID="2226356"
|
||||||
# v4 actually adds crossplay
|
# v4 actually adds crossplay
|
||||||
STACKSCRIPT_ID=2234943
|
#STACKSCRIPT_ID=2234943
|
||||||
|
|
||||||
|
# Stackscript 202611 changes:
|
||||||
|
# Crossplay on:
|
||||||
|
STACKSCRIPT_ID=2301158
|
||||||
|
# Crossplay off:
|
||||||
|
STACKSCRIPT_ID_CROSSPLAY_OFF=2301169
|
||||||
|
|
||||||
if [[ "$SCRIPT_ACTION" == "" || "$SCRIPT_ACTION" == "--help" || "$SCRIPT_ACTION" == "-?" ]]; then
|
if [[ "$SCRIPT_ACTION" == "" || "$SCRIPT_ACTION" == "--help" || "$SCRIPT_ACTION" == "-?" ]]; then
|
||||||
echo "Linode helper script: create-linode.sh <action> <label> [args]"
|
echo "Linode helper script: create-linode.sh <action> <label> [args]"
|
||||||
@@ -53,6 +59,9 @@ if [[ "$SCRIPT_ACTION" == "" || "$SCRIPT_ACTION" == "--help" || "$SCRIPT_ACTION"
|
|||||||
echo " (fixed size: 8GB shared, newest Debian image;"
|
echo " (fixed size: 8GB shared, newest Debian image;"
|
||||||
echo " attaches and mounts volume $VOLUME_NAME;"
|
echo " attaches and mounts volume $VOLUME_NAME;"
|
||||||
echo " also refreshes the valheim A record)"
|
echo " also refreshes the valheim A record)"
|
||||||
|
echo " create-linode.sh c <new label> crossplay-off"
|
||||||
|
echo " (same, but uses the crossplay-off StackScript"
|
||||||
|
echo " ID $STACKSCRIPT_ID_CROSSPLAY_OFF instead of $STACKSCRIPT_ID)"
|
||||||
echo "Destroy: create-linode.sh d <label>"
|
echo "Destroy: create-linode.sh d <label>"
|
||||||
echo "Connect: create-linode.sh x <label>"
|
echo "Connect: create-linode.sh x <label>"
|
||||||
echo " create-linode.sh x <label> get <remote source> <local dest>"
|
echo " create-linode.sh x <label> get <remote source> <local dest>"
|
||||||
@@ -88,6 +97,17 @@ if [[ "$SCRIPT_ACTION" == "c" && -n "$LINODE_LABEL" ]]; then
|
|||||||
INSTANCE_SIZE="g6-standard-4"
|
INSTANCE_SIZE="g6-standard-4"
|
||||||
INSTANCE_IMAGE="linode/debian13"
|
INSTANCE_IMAGE="linode/debian13"
|
||||||
|
|
||||||
|
# Optional third argument selects the crossplay-off StackScript instead of
|
||||||
|
# the default crossplay-on one. Anything else is rejected so that a typo
|
||||||
|
# cannot silently start a server with the wrong StackScript.
|
||||||
|
if [[ "$3" == "crossplay-off" ]]; then
|
||||||
|
STACKSCRIPT_ID=$STACKSCRIPT_ID_CROSSPLAY_OFF
|
||||||
|
echo "Using crossplay-off StackScript ID $STACKSCRIPT_ID."
|
||||||
|
elif [[ -n "$3" ]]; then
|
||||||
|
echo "ERROR: unknown create option '$3' (only 'crossplay-off' is supported)." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# The StackScript (see stackscript.md) runs as root on first boot and mounts
|
# The StackScript (see stackscript.md) runs as root on first boot and mounts
|
||||||
# the volume, so no SSH session is needed to configure it.
|
# the volume, so no SSH session is needed to configure it.
|
||||||
curl -s -H "Content-Type: application/json" \
|
curl -s -H "Content-Type: application/json" \
|
||||||
|
|||||||
Executable
+12
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Script location:
|
||||||
|
# /mnt/ValVol202609/valheim/every_fifteen.sh
|
||||||
|
#
|
||||||
|
# Script purpose:
|
||||||
|
# run periodically from crontab. Placeholder for now, just writes to log file.
|
||||||
|
|
||||||
|
# Create the log file if it does not exist yet
|
||||||
|
touch everyfifteen.log
|
||||||
|
|
||||||
|
tail -n9 everyfifteen.log >everyfifteen.log.tmp && mv everyfifteen.log.tmp everyfifteen.log && echo "$(date -Iseconds) everyfifteen run." >>everyfifteen.log
|
||||||
Executable
+12
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Script location:
|
||||||
|
# /mnt/ValVol202609/valheim/every_hour.sh
|
||||||
|
#
|
||||||
|
# Script purpose:
|
||||||
|
# run periodically from crontab. Placeholder for now, just writes to log file.
|
||||||
|
|
||||||
|
# Create the log file if it does not exist yet
|
||||||
|
touch everyhour.log
|
||||||
|
|
||||||
|
tail -n9 everyhour.log >everyhour.log.tmp && mv everyhour.log.tmp everyhour.log && echo "$(date -Iseconds) everyhour run." >>everyhour.log
|
||||||
Reference in new issue
Block a user