diff --git a/RouterOS_FTP_Backup.rsc b/RouterOS_FTP_Backup.rsc new file mode 100644 index 0000000..fbd407d --- /dev/null +++ b/RouterOS_FTP_Backup.rsc @@ -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; \ No newline at end of file diff --git a/RouterOS_Function_Template.rsc b/RouterOS_Function_Template.rsc new file mode 100644 index 0000000..876dbc5 --- /dev/null +++ b/RouterOS_Function_Template.rsc @@ -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; \ No newline at end of file diff --git a/RouterOS_PPP_Disconnect_Active_Sessions.rsc b/RouterOS_PPP_Disconnect_Active_Sessions.rsc new file mode 100644 index 0000000..22372af --- /dev/null +++ b/RouterOS_PPP_Disconnect_Active_Sessions.rsc @@ -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; \ No newline at end of file diff --git a/RouterOS_Recreate_Bridge.rsc b/RouterOS_Recreate_Bridge.rsc new file mode 100644 index 0000000..c395df2 --- /dev/null +++ b/RouterOS_Recreate_Bridge.rsc @@ -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; + +}