mirror of
https://github.com/laspavel/mikrotik-scripts.git
synced 2025-07-30 23:54:27 +02:00
Init repo
This commit is contained in:
parent
4fb6ae4f61
commit
4705b8aa67
3 changed files with 73 additions and 0 deletions
48
AutoBackup.rsc
Normal file
48
AutoBackup.rsc
Normal file
|
@ -0,0 +1,48 @@
|
|||
:local toemail "laspavel@gmail.com"
|
||||
|
||||
:local sysname [/system identity get name]
|
||||
:local textfilename
|
||||
:local backupfilename
|
||||
:local time [/system clock get time]
|
||||
:local date [/system clock get date]
|
||||
:local uptime [/system resource get uptime]
|
||||
:local logMessages
|
||||
:local newdate "";
|
||||
:for i from=0 to=([:len $date]-1) do={ :local tmp [:pick $date $i];
|
||||
:if ($tmp !="/") do={ :set newdate "$newdate$tmp" }
|
||||
:if ($tmp ="/") do={}
|
||||
}
|
||||
#check for spaces in system identity to replace with underscores
|
||||
:if ([:find $sysname " "] !=0) do={
|
||||
:local name $sysname;
|
||||
:local newname "";
|
||||
:for i from=0 to=([:len $name]-1) do={ :local tmp [:pick $name $i];
|
||||
:if ($tmp !=" ") do={ :set newname "$newname$tmp" }
|
||||
:if ($tmp =" ") do={ :set newname "$newname_" }
|
||||
}
|
||||
:set sysname $newname;
|
||||
}
|
||||
:set logMessages ""
|
||||
:foreach i in=[/log find ] do={
|
||||
:set logMessages ($logMessages. [/log get $i time ]. " ");
|
||||
:set logMessages ($logMessages. [/log get $i message ]);
|
||||
:set logMessages ($logMessages. "\n")
|
||||
}
|
||||
:set textfilename ($"newdate" . "-" . $"sysname" . ".rsc")
|
||||
:set backupfilename ($"newdate" . "-" . $"sysname" . ".backup")
|
||||
:execute [/export file=$"textfilename"]
|
||||
:execute [/system backup save name=$"backupfilename"]
|
||||
#Allow time for export to complete
|
||||
:delay 2s
|
||||
|
||||
#email copies
|
||||
:log info "Emailing backups"
|
||||
/tool e-mail send to=$"toemail" subject="[HomeMikrotik Config Backup RSC] $sysname $time $date" file=$"textfilename" body="[Config Backup LOG] $logMessages"
|
||||
:local time [/system clock get time]
|
||||
/tool e-mail send to=$"toemail" subject="[HomeMikrotik Config Backup BAK] $sysname $time $date" file=$"backupfilename" body="[Config Backup Uptime:] $uptime"
|
||||
#Allow time to send
|
||||
:delay 10s
|
||||
|
||||
#delete copies
|
||||
/file remove $textfilename
|
||||
/file remove $backupfilename
|
12
AutoUpdate.rsc
Normal file
12
AutoUpdate.rsc
Normal file
|
@ -0,0 +1,12 @@
|
|||
|
||||
:do {
|
||||
:local versioninfo [/system package update check-for-updates as-value]
|
||||
:if (($versioninfo->"installed-version") != ($versioninfo->"latest-version")) do={
|
||||
/log error ("Found new version " . ($versioninfo->"latest-version") . " installing now!")
|
||||
/system package update download
|
||||
:delay 5s
|
||||
/system reboot
|
||||
}
|
||||
} on-error={
|
||||
/log error "***** AUTOUPDATE script finished with error ******"
|
||||
}
|
13
vpnscript.rsc
Normal file
13
vpnscript.rsc
Normal file
|
@ -0,0 +1,13 @@
|
|||
:global vpnhosts { "at.vpnunlimitedapp.com"; "be.vpnunlimitedapp.com"; "bg.vpnunlimitedapp.com"; "by.vpnunlimitedapp.com"; "cy.vpnunlimitedapp.com"; "cz.vpnunlimitedapp.com"; "dk.vpnunlimitedapp.com"; "ee.vpnunlimitedapp.com"; "de.vpnunlimitedapp.com"; "de-dus.vpnunlimitedapp.com"; "gr.vpnunlimitedapp.com"; "hu.vpnunlimitedapp.com"; "hr.vpnunlimitedapp.com"; "lv.vpnunlimitedapp.com"; "md.vpnunlimitedapp.com"; "nl.vpnunlimitedapp.com"; "pl.vpnunlimitedapp.com"; "ro.vpnunlimitedapp.com"; "si.vpnunlimitedapp.com"; "ch.vpnunlimitedapp.com"; "tr.vpnunlimitedapp.com" }
|
||||
:global randnum [:tostr ([/tool fetch mode=https http-method=get url="https://www.random.org/integers/\?num=1&min=1&max=21&col=1&base=10&format=plain&rnd=new" as-value output=user ]->"data")]
|
||||
:global idxx [:tonum [:pick $randnum 0 [:find $randnum " "]]];
|
||||
:global vpnhost [:pick $vpnhosts $idxx ];
|
||||
/interface l2tp-client disable VPN1
|
||||
/interface l2tp-client set [find Name=VPN1] connect-to=$vpnhost
|
||||
/interface l2tp-client enable VPN1
|
||||
beep length=300ms;
|
||||
:set randnum
|
||||
:set idxx
|
||||
:set vpnhosts
|
||||
:set vpnhost
|
||||
:log info "*** Interface l2tp-client modified ***"
|
Loading…
Add table
Add a link
Reference in a new issue