Add restart policy #24

Merged
Lumpiasty merged 1 commits from feat/restart-policy into main 2026-06-12 01:11:38 +00:00
2 changed files with 17 additions and 4 deletions
+6 -2
View File
@@ -9,7 +9,7 @@ reasoning behind these choices, see [DESIGN.md](DESIGN.md).
## Deploy on MikroTik (RouterOS) ## Deploy on MikroTik (RouterOS)
Verified on RouterOS 7.21.2 (arm64, CRS418). Commands are grouped into Verified on RouterOS 7.23 (arm64, CRS418). Commands are grouped into
copy-paste blocks, defaults should fit most configurations. copy-paste blocks, defaults should fit most configurations.
> Because the image has no built-in updater (the `clientupdate` feature is > Because the image has no built-in updater (the `clientupdate` feature is
@@ -19,7 +19,9 @@ copy-paste blocks, defaults should fit most configurations.
### 0. Prerequisites ### 0. Prerequisites
- RouterOS >7.13 with the **container** package installed. - RouterOS >= 7.23 with the **container** package installed
(7.23 is needed for container `restart-policy`; the deploy itself works on
>= 7.13 if you drop the restart options).
- Container mode enabled ([documentation](https://manual.mikrotik.com/docs/System%20Information%20and%20Utilities/device-mode/#changing-mode-of-device-mode)): - Container mode enabled ([documentation](https://manual.mikrotik.com/docs/System%20Information%20and%20Utilities/device-mode/#changing-mode-of-device-mode)):
``` ```
@@ -80,6 +82,8 @@ just that directory:
mountlists=tailscale_state \ mountlists=tailscale_state \
logging=yes \ logging=yes \
start-on-boot=yes \ start-on-boot=yes \
restart-policy=on-failure \
restart-interval=10s \
name=tailscale name=tailscale
``` ```
+11 -2
View File
@@ -3,8 +3,9 @@
# ============================================================================= # =============================================================================
# Checks the Gitea registry for a new :stable image and, only if the published # Checks the Gitea registry for a new :stable image and, only if the published
# image actually changed, recreates the container. Designed for RouterOS 7.x # image actually changed, recreates the container. Designed for RouterOS 7.x
# (tested target: 7.21.2, arm64). Requires RouterOS >= 7.13 for the :deserialize # (tested target: 7.23, arm64). Requires RouterOS >= 7.23 for the container
# command used to parse the registry token JSON. # restart-policy properties (and >= 7.13 for the :deserialize command used to
# parse the registry token JSON).
# #
# HOW IT DECIDES "something changed": # HOW IT DECIDES "something changed":
# It fetches the manifest digest of the :stable tag from the registry and # It fetches the manifest digest of the :stable tag from the registry and
@@ -59,6 +60,12 @@
:local cInterface "veth-tailscale" :local cInterface "veth-tailscale"
:local cLogging yes :local cLogging yes
:local cStartOnBoot yes :local cStartOnBoot yes
# Restart the container automatically if tailscaled crashes (tailscaled is
# PID 1; if it dies the container stops). on-failure restarts only on abnormal
# exit (a manual /container/stop stays stopped); 10s is a gentle backoff.
# Requires RouterOS >= 7.23.
:local cRestartPolicy "on-failure"
:local cRestartInterval "10s"
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
:log info "$scriptName: checking for image updates" :log info "$scriptName: checking for image updates"
@@ -174,6 +181,8 @@
mountlists=$cMountList \ mountlists=$cMountList \
logging=$cLogging \ logging=$cLogging \
start-on-boot=$cStartOnBoot \ start-on-boot=$cStartOnBoot \
restart-policy=$cRestartPolicy \
restart-interval=$cRestartInterval \
name=$cName name=$cName
} do={ } do={
:log error "$scriptName: container add failed: $e" :log error "$scriptName: container add failed: $e"