mirror of
https://github.com/pothi/mikrotik-scripts.git
synced 2025-06-22 22:23:31 +02:00
Add test scripts and backup-buttons script
This commit is contained in:
parent
bf07a55ca5
commit
a1a0489377
6 changed files with 79 additions and 0 deletions
3
test-snippets/README.md
Normal file
3
test-snippets/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Test Snippets
|
||||
|
||||
These are not full-fledged scripts. Just snippets to test a single unit of action such as detecting internet or detecting DNS. I hope someone finds it useful!
|
13
test-snippets/test-detect-internet.rsc
Normal file
13
test-snippets/test-detect-internet.rsc
Normal file
|
@ -0,0 +1,13 @@
|
|||
# requirement: /interface detect-internet set detect-interface-list=WAN
|
||||
|
||||
/interface detect-internet
|
||||
# set detect-interface-list=WAN
|
||||
state
|
||||
|
||||
:do {
|
||||
:log info "Waiting for internet..."
|
||||
:set $internetStatus ([:pick [print as-value] 0]->"state")
|
||||
:delay 3s
|
||||
} while ($internetStatus != "internet")
|
||||
|
||||
:log info "Connected to internet."
|
7
test-snippets/test-empty-env-var
Normal file
7
test-snippets/test-empty-env-var
Normal file
|
@ -0,0 +1,7 @@
|
|||
:global adminEmail
|
||||
|
||||
:if ([:typeof $adminEmail] = "nothing" || $adminEmail = "") do={ :log error "Admin Email is not defined or nil."; :error "Admin Email is not defined or nil."; } else={ :put "We are good to proceed!" }
|
||||
|
||||
# :if ($adminEmail = "") do={ :log error "Admin Email is nil."; :error "Admin Email is nil."; }
|
||||
|
||||
:put "This should not be visible if admin email is not defined or nil!"
|
5
test-snippets/test-generate-password
Normal file
5
test-snippets/test-generate-password
Normal file
|
@ -0,0 +1,5 @@
|
|||
:global myPassword;
|
||||
|
||||
:set myPassword [:pick ([/cert scep-server otp generate as-value minutes-valid=1]->"password") 0 20]
|
||||
:put "Your new password is..."
|
||||
:put $myPassword
|
12
test-snippets/test-log
Normal file
12
test-snippets/test-log
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Email the generic-log when it reaches the threshold!
|
||||
|
||||
:global adminEmail
|
||||
:local emailStatus
|
||||
:local logFile "genericLog.1.txt"
|
||||
:local fileContent "temp"
|
||||
|
||||
:do {
|
||||
if ( [/file get "flash/$logFile" ] != "no such item" ) do={ :log info "Log file found!" }
|
||||
} on-error={ :log warning "Log file isn't big enough!" }
|
||||
|
||||
:put $fileContent
|
Loading…
Add table
Add a link
Reference in a new issue