diff --git a/AutoBackup.rsc b/AutoBackup.rsc new file mode 100644 index 0000000..33f2ea3 --- /dev/null +++ b/AutoBackup.rsc @@ -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 \ No newline at end of file diff --git a/AutoUpdate.rsc b/AutoUpdate.rsc new file mode 100644 index 0000000..734ac51 --- /dev/null +++ b/AutoUpdate.rsc @@ -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 ******" +} \ No newline at end of file diff --git a/vpnscript.rsc b/vpnscript.rsc new file mode 100644 index 0000000..f7e311b --- /dev/null +++ b/vpnscript.rsc @@ -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 ***" \ No newline at end of file