mirror of
https://github.com/pothi/mikrotik-lte-scripts.git
synced 2025-06-20 21:35:46 +02:00
Introduce timeout for checking internet
This commit is contained in:
parent
4648323431
commit
6e4c947eb1
1 changed files with 23 additions and 8 deletions
|
@ -1,29 +1,44 @@
|
||||||
# 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 adminPh 9894998949
|
:global adminPh 9894998949
|
||||||
:global genericLogFileName "genericLog"
|
:global genericLogFileName "genericLog"
|
||||||
:global cloudPass ""
|
:global cloudPass ""
|
||||||
|
|
||||||
:local waitForDNS do={
|
:global waitForDNS do={
|
||||||
:local pingIP 1
|
:local pingIP 1
|
||||||
:while ( $pingIP = 1 ) do={ :do { :set pingIP [:resolve g.co] } on-error={ :delay 60s } }
|
:local isUP 0
|
||||||
|
:local timeout 5
|
||||||
|
|
||||||
|
:while ( $pingIP = 1 ) do={
|
||||||
|
:do { :set $pingIP [:resolve g.co] } on-error={
|
||||||
|
:delay 60s
|
||||||
|
:set isUP ($isUP+1)
|
||||||
|
:if ($isUP = $timeout) do={ :error "Internet timed out after $timeout minutes!" }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$waitForDNS
|
$waitForDNS
|
||||||
|
|
||||||
# /system ntp client set enabled=yes
|
# /system ntp client set enabled=yes; :delay 3s
|
||||||
:delay 3s
|
|
||||||
|
|
||||||
:log info "\nInit script has started..."
|
:log info "Init script has started..."
|
||||||
|
|
||||||
/system script
|
/system script
|
||||||
|
|
||||||
:local commonScripts {"backup-cron"; "backup-scripts"; "cloud-backup"; "firmware-check-rb"; "firmware-check-ros";}
|
:local commonScripts {"backup-cron"; "backup-scripts"; "cloud-backup"; "firmware-check-rb"; "firmware-check-ros";}
|
||||||
:local initScripts ($commonScripts, "firmware-check-lte")
|
:local initScripts ($commonScripts, "firmware-check-lte")
|
||||||
|
|
||||||
:foreach scriptName in $initScripts do={
|
:foreach scriptName in $initScripts do={
|
||||||
:do { run $scriptName } on-error={ :log error "Error running the script $scriptName\n" }
|
:do { run $scriptName } on-error={ :log error "Error running the script $scriptName\n" }
|
||||||
:delay 30s
|
:delay 30s
|
||||||
}
|
}
|
||||||
|
|
||||||
:log info "Init script finished execution!\n"
|
:log info "Init script finished execution!"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue