mirror of
https://github.com/pothi/mikrotik-scripts.git
synced 2025-06-24 23:18:38 +02:00
Improve docs, backup scripts and sms forward/email script
This commit is contained in:
parent
1e7b29e615
commit
37c9394986
4 changed files with 42 additions and 56 deletions
|
@ -1,7 +1,8 @@
|
||||||
# Backup cron (schedules).
|
# Backup cron (schedules).
|
||||||
|
|
||||||
# requirements:
|
# filename: backup-cron
|
||||||
# policy: ftp, read, write, policy, test
|
# policy: ftp, read, write, policy, test
|
||||||
|
|
||||||
:local adminEmailAddress pothi@duck.com
|
:local adminEmailAddress pothi@duck.com
|
||||||
:local deviceIdentity [/system identity get name]
|
:local deviceIdentity [/system identity get name]
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@
|
||||||
|
|
||||||
/tool e-mail send to="$adminEmailAddress" \
|
/tool e-mail send to="$adminEmailAddress" \
|
||||||
subject="[Mikrotik $deviceIdentity] Backup of Cron Entries" \
|
subject="[Mikrotik $deviceIdentity] Backup of Cron Entries" \
|
||||||
body="See subject and attachment" \
|
body="See the subject and the attachment." \
|
||||||
file=cron.rsc; :delay 10s
|
file=cron.rsc; :delay 10s
|
||||||
|
|
||||||
:log info "An email is probably sent to $adminEmailAddress."
|
:log info "An email is probably sent to $adminEmailAddress."
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
# Backup scripts.
|
# Backup scripts.
|
||||||
|
|
||||||
# requirements:
|
# filename: backup-scripts
|
||||||
# policy: ftp, read, write, policy, test
|
# policy: ftp, read, write, policy, test
|
||||||
|
|
||||||
:local adminEmailAddress "admin@example.com"
|
:local adminEmailAddress "admin@example.com"
|
||||||
:local deviceIdentity [/system identity get name]
|
:local deviceIdentity [/system identity get name]
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@
|
||||||
|
|
||||||
/tool e-mail send to="$adminEmailAddress" \
|
/tool e-mail send to="$adminEmailAddress" \
|
||||||
subject="[Mikrotik $deviceIdentity] Backup of Scripts" \
|
subject="[Mikrotik $deviceIdentity] Backup of Scripts" \
|
||||||
body="See subject and attachment" \
|
body="See the subject and the attachment." \
|
||||||
file=scripts.rsc; :delay 10s
|
file=scripts.rsc; :delay 10s
|
||||||
|
|
||||||
:log info "An email is probably sent to $adminEmailAddress."
|
:log info "An email is probably sent to $adminEmailAddress."
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
# Source: https://forum.mikrotik.com/viewtopic.php?f=9&t=61068#p312202
|
|
||||||
|
|
||||||
# Script to forward SMS from GSM Modem Inbox to Email #
|
|
||||||
# Note: The SMS is removed from the inbox after being sent to Email, #
|
|
||||||
# even if the Email fails to be sent #
|
|
||||||
# Remember to set up /Tools/SMS with the USB port of your #
|
|
||||||
# Modem and the info channel. Put anything in secret and #
|
|
||||||
# make sure Receive Enabled is ticked #
|
|
||||||
# Tested on Rb751U RouterOS v5.12 with Huawei E367 #
|
|
||||||
# Peter James 2012-04-04 #
|
|
||||||
|
|
||||||
|
|
||||||
:local EmailAddress "your_email_address";
|
|
||||||
:local smsPhone;
|
|
||||||
:local smsTimeStamp;
|
|
||||||
:local smsMessage;
|
|
||||||
:local smsContent;
|
|
||||||
|
|
||||||
# Get System Identity #
|
|
||||||
:local SystemID [/system identity get name];
|
|
||||||
|
|
||||||
:log info "SMS to Email script started";
|
|
||||||
|
|
||||||
# Set Receive Enabled, in case it was cleared by a router reboot #
|
|
||||||
/tool sms set receive-enabled=yes;
|
|
||||||
|
|
||||||
delay 2;
|
|
||||||
|
|
||||||
# loop through all the messages in the inbox #
|
|
||||||
:foreach i in=[/tool sms inbox find] do={
|
|
||||||
|
|
||||||
:set smsPhone [/tool sms inbox get $i phone];
|
|
||||||
:set smsTimeStamp [/tool sms inbox get $i timestamp];
|
|
||||||
:set smsMessage [/tool sms inbox get $i message];
|
|
||||||
|
|
||||||
:set smsContent "Router ID: $SystemID\nSMS Received from: $smsPhone\nDate&Time: $smsTimeStamp\nMessage: $smsMessage";
|
|
||||||
|
|
||||||
:log info $smsContent;
|
|
||||||
|
|
||||||
/tool e-mail send tls=yes subject="$SystemID GSM Modem SMS Received" to=$EmailAddress body="$smsContent";
|
|
||||||
|
|
||||||
# Now remove the SMS from the inbox #
|
|
||||||
/tool sms inbox remove $i;
|
|
||||||
|
|
||||||
delay 10;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# clear Receive Enabled, so info channel can be used by other scripts #
|
|
||||||
/tool sms set receive-enabled=no;
|
|
||||||
|
|
||||||
:log info "SMS to Email script complete";
|
|
36
sms-forward-email.rsc
Normal file
36
sms-forward-email.rsc
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# SMS Forward and Email
|
||||||
|
|
||||||
|
# ToDo: Shorten the timestamp.
|
||||||
|
|
||||||
|
# Source: https://forum.mikrotik.com/viewtopic.php?f=9&t=61068#p312202
|
||||||
|
|
||||||
|
# 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 smsPhone
|
||||||
|
:local smsMessage
|
||||||
|
:local smsTimeStamp
|
||||||
|
|
||||||
|
/tool sms inbox
|
||||||
|
|
||||||
|
:foreach i in=[find] do={
|
||||||
|
:set smsPhone [get $i phone]
|
||||||
|
:set smsMessage [get $i message]
|
||||||
|
:set smsTimeStamp [get $i timestamp]
|
||||||
|
|
||||||
|
: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";
|
||||||
|
:delay 2s
|
||||||
|
|
||||||
|
# Send Email to $adminEmailAddress
|
||||||
|
/tool e-mail send to="$adminEmailAddress" body="$smsMessage" \
|
||||||
|
subject="SMS from $smsPhone at $smsTimeStamp"
|
||||||
|
:delay 3s
|
||||||
|
|
||||||
|
remove $i
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue