Add STARTUP_SCRIPT option to execute extra script during container start

This commit is contained in:
Dmitry Nezhevenko 2024-12-23 10:22:57 +01:00
parent 6b01356241
commit 40c644fc2c
2 changed files with 13 additions and 0 deletions

View file

@ -76,6 +76,7 @@ This section follows the Mikrotik Container documentation with additional steps
| UPDATE_TAILSCALE | Update tailscale on container startup | |
| TAILSCALE_ARGS | Additional arguments passed to tailscale | Optional. Note ```---accept-routes``` is required to accept the advertised routes of the other subnet routers |
| TAILSCALED_ARGS | Additional arguments passed to tailscaled | Optional |
| STARTUP_SCRIPT | Extra script to execute in container before tailscaled | Optional |
Example Tailscale control server configuration:
```
@ -105,6 +106,14 @@ Define the the mount as per below.
add name="tailscale" src="/tailscale" dst="/var/lib/tailscale"
```
It's possible to execute extra script during container startup. To do this, firstly make sure that script is accessible inside
container. For example put it to `/var/lib/tailscale` folder and then add `STARTUP_SCRIPT` environment variable:
```
/container/envs
add name="tailscale" key="STARTUP_SCRIPT" value="/var/lib/tailscale/startup.sh"
```
6. Create the container
The container can be created via the container registry (Step 6a) or using the `tailscale.tar` file generated by building the Docker image locally (Step 6b or 6c).

View file

@ -34,6 +34,10 @@ if [[ -z "$LOGIN_SERVER" ]]; then
LOGIN_SERVER=https://controlplane.tailscale.com
fi
if [[ -n "$STARTUP_SCRIPT" ]]; then
bash "$STARTUP_SCRIPT" || exit $?
fi
# Start tailscaled and bring tailscale up
/usr/local/bin/tailscaled ${TAILSCALED_ARGS} &
until /usr/local/bin/tailscale up \