Add test scripts and backup-buttons script

This commit is contained in:
Pothi Kalimuthu 2022-11-10 12:35:50 +05:30
parent bf07a55ca5
commit a1a0489377
No known key found for this signature in database
GPG key ID: 08202A469C2D0E06
6 changed files with 79 additions and 0 deletions

3
test-snippets/README.md Normal file
View 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!

View 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."

View 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!"

View 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
View 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