mirror of
https://github.com/pothi/mikrotik-scripts.git
synced 2025-07-10 14:44:31 +02:00
Migrate LTE scripts to its dedicated repo and update docs
This commit is contained in:
parent
591ed2d662
commit
7c39017944
6 changed files with 17 additions and 197 deletions
18
README.md
18
README.md
|
@ -1,2 +1,18 @@
|
||||||
# mikrotik-scripts
|
# MikroTik Scripts
|
||||||
|
|
||||||
MikroTik RouterOS based Scripts, Schedules (aka cron jobs), Tips and Tricks
|
MikroTik RouterOS based Scripts, Schedules (aka cron jobs), Tips and Tricks
|
||||||
|
|
||||||
|
#### More MikroTik scripts by me...
|
||||||
|
|
||||||
|
- [MikroTik LTE Scripts](https://github.com/pothi/mikrotik-lte-scripts)
|
||||||
|
- Coming soon (MikroTik hAP Scripts).
|
||||||
|
- Coming soon (Mikrotik v7 scripts).
|
||||||
|
- Coming soon (Mikrotik v7 changes).
|
||||||
|
|
||||||
|
## ToDo
|
||||||
|
|
||||||
|
- plenty of stuff
|
||||||
|
|
||||||
|
# Contact
|
||||||
|
|
||||||
|
You may contact me by my first name (Github username) @riseup.net, @protonmail.com, @duck.com.
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
# 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 adminEmail "admin@example.com"
|
|
||||||
:local smsForwardPh 9876543210
|
|
||||||
|
|
||||||
: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
|
|
||||||
: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 $adminEmail
|
|
||||||
/tool e-mail send to="$adminEmail" body="$smsMessage" \
|
|
||||||
subject="SMS from $smsPhone at $smsTimeStamp"
|
|
||||||
:delay 3s
|
|
||||||
|
|
||||||
remove $i
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
# SMS to Email
|
|
||||||
|
|
||||||
# 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!
|
|
||||||
|
|
||||||
:global adminEmail
|
|
||||||
|
|
||||||
:local smsPhone
|
|
||||||
:local smsMessage
|
|
||||||
:local smsTimeStamp
|
|
||||||
|
|
||||||
/tool sms inbox
|
|
||||||
|
|
||||||
:foreach receivedSMS in=[find] do={
|
|
||||||
:set smsPhone [get $receivedSMS phone]
|
|
||||||
:set smsMessage [get $receivedSMS message]
|
|
||||||
:set smsTimeStamp [get $receivedSMS timestamp]
|
|
||||||
|
|
||||||
:log info "\nSMS Received From: $smsPhone on $smsTimeStamp Message: $smsMessage"
|
|
||||||
|
|
||||||
# Send Email to $adminEmail
|
|
||||||
:do {
|
|
||||||
/tool e-mail send to="$adminEmail" body="$smsMessage" \
|
|
||||||
subject="SMS from $smsPhone at $smsTimeStamp"
|
|
||||||
} on-error={ :log error "SMS to Email Failed." }
|
|
||||||
:delay 3s
|
|
||||||
|
|
||||||
# Let's remove the SMS!
|
|
||||||
remove $receivedSMS
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
# SMS to SMS
|
|
||||||
|
|
||||||
# Limitation: It just forwards the SMS. It doesn't forward the senderPhoneNumber or timestamp of received SMS.
|
|
||||||
|
|
||||||
# Source: https://forum.mikrotik.com/viewtopic.php?f=9&t=61068#p312202
|
|
||||||
|
|
||||||
:global adminPh
|
|
||||||
:local smsForwardPh $adminPh
|
|
||||||
|
|
||||||
:local smsPhone
|
|
||||||
:local smsMessage
|
|
||||||
:local smsTimeStamp
|
|
||||||
|
|
||||||
/tool sms inbox
|
|
||||||
|
|
||||||
:foreach receivedSMS in=[find] do={
|
|
||||||
:set smsPhone [get $receivedSMS phone]
|
|
||||||
:set smsMessage [get $receivedSMS message]
|
|
||||||
:set smsTimeStamp [get $receivedSMS timestamp]
|
|
||||||
|
|
||||||
:log info "\nSMS Received From: $smsPhone on $smsTimeStamp Message: $smsMessage"
|
|
||||||
|
|
||||||
# Forward the SMS to $smsForwardPh, without $smsPhone and smsTimeStamp
|
|
||||||
:do {
|
|
||||||
/tool sms send lte1 phone-number=$smsForwardPh message=$smsMessage
|
|
||||||
} on-error={ :log error "SMS to SMS Failed." }
|
|
||||||
:delay 2s
|
|
||||||
|
|
||||||
# Let's NOT remove the SMS!
|
|
||||||
# Let the other script (SMS to Email) remove it, after sending the message with full details.
|
|
||||||
# remove $receivedSMS
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
# Applicable for RouterOS above 6.45.1
|
|
||||||
# see https://wiki.mikrotik.com/wiki/Dual_SIM_Application#Initial_settings
|
|
||||||
|
|
||||||
:log "info" "SIM toggled by the script"
|
|
||||||
|
|
||||||
:local simSlot [/system routerboard modem get sim-slot]
|
|
||||||
|
|
||||||
:if ( $simSlot = "a" ) do={
|
|
||||||
/system routerboard modem set sim-slot=b
|
|
||||||
} else={
|
|
||||||
/system routerboard modem set sim-slot=a
|
|
||||||
}
|
|
|
@ -1,82 +0,0 @@
|
||||||
:global country "India";
|
|
||||||
:global identity "Mikrotik";
|
|
||||||
:global myPassword;
|
|
||||||
|
|
||||||
# override the default values here
|
|
||||||
:set identity "SXT LTE Kit";
|
|
||||||
:set myPassword [:pick ([/cert scep-server otp generate as-value minutes-valid=1]->"password") 0 20]
|
|
||||||
:put "Your new password is..."
|
|
||||||
:put $myPassword
|
|
||||||
|
|
||||||
# my subnet
|
|
||||||
:global mySubnetCIDR "10.88.50.0/24";
|
|
||||||
:global dhcpServerIP "10.88.50.1";
|
|
||||||
:global dhcpPoolRange "10.88.50.88-10.88.50.100";
|
|
||||||
:global dhcpName "my-dhcp";
|
|
||||||
:global myBridgeAddress "10.88.50.1/24";
|
|
||||||
|
|
||||||
# SSH
|
|
||||||
:global sshUserName "pothi";
|
|
||||||
|
|
||||||
### ------------------------------------------------------------------------------------ ###
|
|
||||||
# Generic Tweaks #
|
|
||||||
### ------------------------------------------------------------------------------------ ###
|
|
||||||
|
|
||||||
# Configure Identity
|
|
||||||
/system identity set name=$identity
|
|
||||||
|
|
||||||
# Minor Tweaks
|
|
||||||
/interface detect-internet
|
|
||||||
set detect-interface-list=WAN
|
|
||||||
set lan-interface-list=LAN
|
|
||||||
set wan-interface-list=all
|
|
||||||
set internet-interface-list=all
|
|
||||||
|
|
||||||
# Wireless tweaks
|
|
||||||
|
|
||||||
# install public SSH key
|
|
||||||
:put "Importing SSH key..."
|
|
||||||
{
|
|
||||||
:local result [ /tool fetch https://launchpad.net/~pothi/+sshkeys dst-path=pothi-ssh-key-rsa as-value];
|
|
||||||
:while ($result->"status" != "finished") do={ :delay 2s }
|
|
||||||
}
|
|
||||||
:delay 1s
|
|
||||||
/user ssh-keys import public-key-file=pothi-ssh-key-rsa;
|
|
||||||
:delay 1s
|
|
||||||
/file remove pothi-ssh-key-rsa;
|
|
||||||
:put "Done importing SSH key."
|
|
||||||
|
|
||||||
# Reduce disk activity
|
|
||||||
/ip dhcp-server config set store-leases-disk=never;
|
|
||||||
|
|
||||||
# Configure NTP Client
|
|
||||||
/system ntp client set primary-ntp=[ :resolve pool.ntp.org ];
|
|
||||||
/system ntp client set secondary-ntp=[ :resolve time.cloudflare.com ];
|
|
||||||
/system ntp client set enabled=yes;
|
|
||||||
|
|
||||||
### ------------------------------------------------------------------------------------ ###
|
|
||||||
# Specific to LTE Products #
|
|
||||||
### ------------------------------------------------------------------------------------ ###
|
|
||||||
# SMS Receive capability
|
|
||||||
/tool sms set auto-erase=yes receive-enabled=yes secret=0000 port=lte1;
|
|
||||||
|
|
||||||
:put "Changing the sim slot to 'b'."
|
|
||||||
/system routerboard modem set sim-slot=b
|
|
||||||
|
|
||||||
# Change subnet
|
|
||||||
#change static DNS entry for router.lan
|
|
||||||
/ip dns static set numbers=[find name=router.lan] address=$dhcpServerIP;
|
|
||||||
|
|
||||||
/ip pool add name=$dhcpName ranges=$dhcpPoolRange;
|
|
||||||
/ip dhcp-server network add address=$mySubnetCIDR gateway=$dhcpServerIP dns-server=$dhcpServerIP;
|
|
||||||
/ip address add address=$myBridgeAddress interface=bridge;
|
|
||||||
/ip dhcp-server set [find interface=bridge] address-pool=my-dhcp
|
|
||||||
:put "Subnet changed."
|
|
||||||
|
|
||||||
:put "Removing old subnet."
|
|
||||||
:put "This will make the current SSH session unresponsive."
|
|
||||||
:put "Renew or release the IP in DHCP client in the router or disble & enable DHCP client to make everything work again."
|
|
||||||
/ip pool remove default-dhcp;
|
|
||||||
/ip dhcp-server network remove [find gateway=192.168.88.1];
|
|
||||||
/ip address remove [find address="192.168.88.1/24"]
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue