mirror of
https://github.com/pothi/mikrotik-scripts.git
synced 2025-06-26 07:58:37 +02:00
Introduce timeout for checking internet
This commit is contained in:
parent
fd35e525bc
commit
69023b21f8
1 changed files with 17 additions and 1 deletions
|
@ -1,23 +1,39 @@
|
||||||
# Initialize the router with default values, run backup scripts and check for updates!
|
# Initialize the router with default values, run backup scripts and check for updates!
|
||||||
|
|
||||||
|
# Version: 2
|
||||||
|
|
||||||
|
# changelog
|
||||||
|
# version: 2
|
||||||
|
# - date: 2022-11-18
|
||||||
|
# - introduction of timeout to check internet
|
||||||
|
|
||||||
:global adminEmail "noreply@example.com"
|
:global adminEmail "noreply@example.com"
|
||||||
:global cloudPass ""
|
:global cloudPass ""
|
||||||
|
|
||||||
|
:local isUP 0
|
||||||
|
:local timeout 5
|
||||||
|
|
||||||
/interface/detect-internet
|
/interface/detect-internet
|
||||||
set detect-interface-list=WAN
|
set detect-interface-list=WAN
|
||||||
state
|
state
|
||||||
|
|
||||||
:do {
|
:do {
|
||||||
:delay 60s
|
:delay 60s
|
||||||
:set $internetStatus ([:pick [print as-value] 0]->"state")
|
:set $internetStatus ([:pick [print as-value] 0]->"state")
|
||||||
# :log info "Waiting for internet..."
|
# :log info "Waiting for internet..."
|
||||||
|
|
||||||
|
:set isUP ($isUP+1)
|
||||||
|
:if ($isUP = $timeout) do={ :error "Internet timed out after $timeout minutes!" }
|
||||||
|
|
||||||
} while ($internetStatus != "internet")
|
} while ($internetStatus != "internet")
|
||||||
|
|
||||||
# :log info "Connected to internet."
|
# :log info "Connected to internet."
|
||||||
|
|
||||||
:log info "Init script started."
|
:log info "Init script started."
|
||||||
|
|
||||||
/system script
|
/system script
|
||||||
|
|
||||||
:local commonScripts {"backup-cron"; "backup-scripts"; "cloud-backup"; "firmware-check"}
|
:local commonScripts {"backup-buttons"; "backup-cron"; "backup-scripts"; "cloud-backup"; "firmware-check"}
|
||||||
:local initScripts ("enable-wifi", $commonScripts)
|
:local initScripts ("enable-wifi", $commonScripts)
|
||||||
|
|
||||||
:foreach scriptName in $initScripts do={
|
:foreach scriptName in $initScripts do={
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue