diff --git a/README.md b/README.md index fea6f9d..46ba3d4 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ The container exposes a SSH server for management purposes using root credential ## Upgrading +### Manual To upgrade, first stop and remove the container. ``` @@ -131,6 +132,40 @@ Create a new container as per Step 6. The tailscale.sh script detects if the tai In the Tailscale console, check the router is authenticated and enable the subnet routes. +### Via Script +The script **upgrade.rsc** automates the upgrade process. To use the script, edit the *hostname* variable to match your container +and import the script - note the script assumes the container repository is being used. + +``` +/system script add name=upgrade source=[ /file get upgrade.rsc contents]; +``` + +Run the script: +``` +/system script +run [find name="upgrade"]; + +Stopping the container... +Waiting for the container to stop... +Waiting for the container to stop... +Waiting for the container to stop... +Stopped. +Removing the container... +Waiting for the container to be removed... +Removed. +Adding the container... +Waiting for the container to be added... +Waiting for the container to be added... +Waiting for the container to be added... +Waiting for the container to be added... +Waiting for the container to be added... +Waiting for the container to be added... +Added. +Starting the container. +``` + +Note the script will continue to run if you are connecting over the tailnet. When completed, check the router is authenticated and enable the subnet routes in the Tailscale console. + ## Contributing We welcome suggestions and feedback from people interested in integrating Tailscale on the RouterOS platform. Please send a PR or create an issue if you're having any problems. diff --git a/upgrade.rsc b/upgrade.rsc new file mode 100644 index 0000000..972be0b --- /dev/null +++ b/upgrade.rsc @@ -0,0 +1,49 @@ +# Container identifier +:global hostname "mikrotik-west-1"; + +/container +:global id [find where hostname=$hostname]; +:global rootdir [get $id root-dir]; +:global dns [get $id dns]; +:global logging [get $id logging]; +:global status [get $id status]; + +# Stop the container +stop $id +:put "Stopping the container..."; +:while ($status != "stopped") do={ + :put "Waiting for the container to stop..."; + :delay 5; + :set status [get $id status]; +} +:put "Stopped."; + +# Remove the container +remove $id +:put "Removing the container..."; +:while ($status = "stopped") do={ + :put "Waiting for the container to be removed..."; + :delay 5; + :set status [get $id status]; +} +:put "Removed."; + +# Add the container +:delay 5; +:put "Adding the container..."; +add remote-image=fluent-networks/tailscale-mikrotik:latest \ + interface=veth1 envlist=tailscale root-dir=$rootdir \ + start-on-boot=yes hostname=$hostname dns=$dns logging=$logging +:do { + :set status [get [find where hostname=$hostname] status]; + :if ($status != "stopped") do={ + :put "Waiting for the container to be added..."; + :delay 5; + } +} while ($status != "stopped") +:put "Added." + +# Start the container +:put "Starting the container."; +:set id [find where hostname=$hostname]; +start $id