Partition 0 considered "primary", partition 1 considered "safe-config". HW is a CCR-2116.
I want to switch to part1 if the router has booted, but the network appears to be down, ie if upgrade borks so it boots ok but an interface is lost / corrupted, which happened to me in a 7.2 upgrade.
Any thoughts on this concept of operation? Any best practices for deciding the current partition is healthy? Trying to keep it simple.
Code: Select all
{
:if( [/partitions get part1 active] ) do={
:log info "Safeboot Watchdog: Already on part1, exiting"
/quit
}
:log info "Safeboot Watchdog: Waiting 180s"
:delay 180s
# Maybe we probe a web page instead of ping
# :local fetchresult [/tool/fetch url="https://www.google.com" mode=https check-certificate=yes as-value output=user]
# :if($fetchresult->"status" = "finished") do={
:for i from=0 to=5 do={
:log error "Safeboot Watchdog: Pinging 8.8.8.8"
:if( [/tool/ping address=8.8.8.8 count=10] = 0) do={
:log error "Could not ping 8.8.8.8"
:delay 30s
} else={
:log info "Safeboot Watchdog: Ping ok"
/quit
}
}
# Maybe we probe another host, if the first one is down
:for i from=0 to=5 do={
:log error "Pinging 8.8.4.4"
:if( [/tool/ping address=8.8.4.4 count=10] = 0) do={
:log error "Safeboot Watchdog: Could not ping 8.8.4.4"
:delay 30s
} else={
:log info "Safeboot Watchdog: Ping ok"
/quit
}
}
:log error "Safeboot Watchdog: Network seems to be down!"
:log info "Safeboot Watchdog: Activating part1"
/partitions {
activate part1
}
:log info "Safeboot Watchdog: Rebooting"
/system reboot
}