From 5cfac94956ba4754195b152a15593b15be2d9c34 Mon Sep 17 00:00:00 2001 From: Pothi Kalimuthu <1254302+pothi@users.noreply.github.com> Date: Mon, 21 Feb 2022 06:57:29 +0530 Subject: [PATCH] Minor fixes and documentation updates --- hap-ac2-init.rsc | 8 ++++++++ scripts/alert-on-new-ros-version.rsc | 16 ++++++---------- .../sms-forward-email.rsc | 12 +++++++----- 3 files changed, 21 insertions(+), 15 deletions(-) rename sms-forward-email.rsc => scripts/sms-forward-email.rsc (63%) diff --git a/hap-ac2-init.rsc b/hap-ac2-init.rsc index 4db442e..599b4fa 100644 --- a/hap-ac2-init.rsc +++ b/hap-ac2-init.rsc @@ -40,6 +40,14 @@ # Configure Identity /system identity set name=$myIdentity; +# Minor Tweaks +/system routerboard settings set init-delay=3 +/interface detect-internet + set detect-interface-list=WAN + set lan-interface-list=LAN + set wan-interface-list=all + set internet-interface-list=all + # Change subnet /ip pool add name=$dhcpName ranges=$dhcpPoolRange; /ip pool remove default-dhcp; diff --git a/scripts/alert-on-new-ros-version.rsc b/scripts/alert-on-new-ros-version.rsc index aa8beaa..1281f09 100644 --- a/scripts/alert-on-new-ros-version.rsc +++ b/scripts/alert-on-new-ros-version.rsc @@ -1,14 +1,14 @@ -# Alert upon new version +# Alert upon new Router OS Version # requirement/s: # policy: read, write, policy, test -:local adminEmailAddress "admin@example.com" -:local startDelay "100s" +:local adminEmail "admin@example.com" +:local startDelay "90s" # if you run this script at "startup", # the following indicates the time for the internet to go "up" # ToDo: Find it out dynamically -:delay $startDelay +# :delay $startDelay :log info "Checking for new version of RouterOS..." @@ -27,18 +27,14 @@ check-for-updates once # :set $versionStatus ([print as-value]->"status") } while=( $versionStatus = "finding out latest version..." ) -# for debugging -# :put $versionStatus -# :put $adminEmailAddress - :local installedVersion [get installed-version] :local latestVersion [get latest-version] :if ( $versionStatus = "New version is available" ) do={ # alternative method # :if ( installedVersion != $latestVersion ) do={ - :log info "A new update is available for Router OS and an email is probably sent to $adminEmailAddress." - /tool e-mail send to="$adminEmailAddress" \ + :log info "A new update is available for Router OS and an email is probably sent to $adminEmail." + /tool e-mail send to="$adminEmail" \ subject="[Mikrotik $deviceIdentity] Software Update is Available" \ body="A new update is available for your MikroTik device: \"$deviceIdentity\" ... diff --git a/sms-forward-email.rsc b/scripts/sms-forward-email.rsc similarity index 63% rename from sms-forward-email.rsc rename to scripts/sms-forward-email.rsc index 5790f32..4e89dd6 100644 --- a/sms-forward-email.rsc +++ b/scripts/sms-forward-email.rsc @@ -7,8 +7,8 @@ # Note: The SMS is removed from the inbox after sent by Email and forwarded # even if email and forward fail! So, test it often! -:local adminEmailAddress "pothi@duck.com" -:local smsForwardPh 9952697255 +:local adminEmail "admin@example.com" +:local smsForwardPh 9876543210 :local smsPhone :local smsMessage @@ -24,11 +24,13 @@ :log info "SMS Received From: $smsPhone at $smsTimeStamp Message: $smsMessage" # Forward the SMS to $smsForwardPh - /tool sms send lte1 phone-number=$smsForwardPh message="From: $smsPhone on $smsTimeStamp Msg: $smsMessage"; + :do { + /tool sms send lte1 phone-number=$smsForwardPh message="From: $smsPhone Date:$smsTimeStamp Msg: $smsMessage" + } on-error={ /tool e-mail send to="$adminEmail" subject="Sending SMS Failed" body="Check the log" } :delay 2s - # Send Email to $adminEmailAddress - /tool e-mail send to="$adminEmailAddress" body="$smsMessage" \ + # Send Email to $adminEmail + /tool e-mail send to="$adminEmail" body="$smsMessage" \ subject="SMS from $smsPhone at $smsTimeStamp" :delay 3s