mirror of
https://github.com/gbudny93/RouterOS_Useful_Scripts.git
synced 2025-06-21 01:25:49 +02:00
Initial Commit.
This commit is contained in:
parent
8cacc24150
commit
ff04ad34f2
4 changed files with 110 additions and 0 deletions
31
RouterOS_FTP_Backup.rsc
Normal file
31
RouterOS_FTP_Backup.rsc
Normal file
|
@ -0,0 +1,31 @@
|
|||
# RouterOS Function
|
||||
# Copyright (c) Grzegorz Budny
|
||||
# Version 1.0
|
||||
# Last update: 2/14/2020
|
||||
# Makes device backup and configuration backup, sends files to FTP server
|
||||
|
||||
:global FTPBackup do={
|
||||
|
||||
:local systemName [/system identity get value-name=name];
|
||||
|
||||
:log info "...:::FTP backup job started:::...";
|
||||
|
||||
/export file=$configName;
|
||||
/system backup save name=$backupName;
|
||||
|
||||
/tool fetch src-path=$configName mode=ftp dst-path=$destPath \
|
||||
user=$ftpUser password=$ftpPassword port=21 upload=yes \
|
||||
address=$ftpServer;
|
||||
|
||||
/tool fetch src-path=$backupName mode=ftp dst-path=$destPath \
|
||||
user=$ftpUser password=$ftpPassword port=21 upload=yes \
|
||||
address=$ftpServer;
|
||||
|
||||
/tool e-mail send server=$smtpServer port=$smtpPort from=($systemName.$domain) \
|
||||
to=$recipient subject=($systemName." FTP backup job completed") body=("FTP backup job completed to ".$ftpServer) \
|
||||
|
||||
:log info ("...:::Backup files sent to".$recipient.":::...");
|
||||
}
|
||||
|
||||
$FTPBackup configName=configName backupName=backupName smtpServer=smtpServer smtpPort=smtpPort domain=@example.com \
|
||||
recipient=recipient@example.com destPath=destPath ftpUser=user ftpPassword=password ftpServer=ftpserver;
|
37
RouterOS_Function_Template.rsc
Normal file
37
RouterOS_Function_Template.rsc
Normal file
|
@ -0,0 +1,37 @@
|
|||
# RouterOS Function/Script
|
||||
# Copyright (c) Grzegorz Budny
|
||||
# Version 1.0
|
||||
# Last update: 2/8/2020
|
||||
# Description of this what script/function does
|
||||
|
||||
# Function definition
|
||||
:global RouterOS_Function do={
|
||||
|
||||
# DEFINITIONS
|
||||
# Getters section
|
||||
# Global variables definition - split out defined and undefined variables during declaring
|
||||
:global globalDefinedVariable [/system identity get value-name=name];
|
||||
:global globalDefinedVariable2 [/system identity get value-name=name];
|
||||
|
||||
:global globalUndefinedVariable;
|
||||
:global globalUndefinedVariable2;
|
||||
|
||||
# Local variables definition - split out defined and undefined variables during declaring
|
||||
:local localDefinedVariable [/system identity get value-name=name];
|
||||
:local localDefinedVariable2 [/system identity get value-name=name];
|
||||
|
||||
:local localUndefinedVariable;
|
||||
:local localUndefinedVariable2;
|
||||
|
||||
# Setters section
|
||||
:set $globalUndefinedVariable [/system identity get value-name=name];
|
||||
:set $localUndefinedVariable [:toarray $localUndefinedVariable];
|
||||
|
||||
# MAIN SCRIPT
|
||||
:log info ("This is my script with ".$localDefinedVariable2."\n");
|
||||
/system reboot;
|
||||
|
||||
}
|
||||
|
||||
# Example
|
||||
RouterOS_Function functionParameter=parameterDefinition;
|
23
RouterOS_PPP_Disconnect_Active_Sessions.rsc
Normal file
23
RouterOS_PPP_Disconnect_Active_Sessions.rsc
Normal file
|
@ -0,0 +1,23 @@
|
|||
# RouterOS Function
|
||||
# Copyright (c) Grzegorz Budny
|
||||
# Version 1.0
|
||||
# Last update: 3/15/2020
|
||||
# Disconnects all active PPP sessions at once
|
||||
|
||||
:global DisconnectActivePPPSesssions do={
|
||||
|
||||
:local pppSessions [/ppp active print count-only];
|
||||
|
||||
:for i from=0 to=$pppSessions step=1 do= \
|
||||
{
|
||||
|
||||
/ppp active remove numbers=$i;
|
||||
:log info ("...:::Removing PPP Sesion no ".$i.":::...";
|
||||
|
||||
}
|
||||
|
||||
:log info ("...:::Removed PPP sessions: ".$pppSessions);
|
||||
|
||||
}
|
||||
|
||||
$DisconnectActivePPPSesssions;
|
19
RouterOS_Recreate_Bridge.rsc
Normal file
19
RouterOS_Recreate_Bridge.rsc
Normal file
|
@ -0,0 +1,19 @@
|
|||
# RouterOS Function
|
||||
# Copyright (c) Grzegorz Budny
|
||||
# Version 1.0
|
||||
# Last update: 2/12/2020
|
||||
# Recreates issued bridge in running config
|
||||
|
||||
|
||||
:global RecreateBridge do={
|
||||
|
||||
/interface bridge remove $bridgeName;
|
||||
|
||||
/interface bridge add name=$bridgeName mtu=auto actual-mtu=1500 l2mtu=1592 arp=enabled \
|
||||
arp-timeout=auto protocol-mode=none \
|
||||
fast-forward=yes igmp-snooping=no auto-mac=no \
|
||||
ageing-time=5m vlan-filtering=yes ether-type=0x8100 pvid=1 \
|
||||
frame-types=admit-all ingress-filtering=yes dhcp-snooping=yes \
|
||||
add-dhcp-option82=yes;
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue