-
Notifications
You must be signed in to change notification settings - Fork 2
/
CAPsMAN_CAP_Package_Auto_Download.rsc
50 lines (34 loc) · 2.07 KB
/
CAPsMAN_CAP_Package_Auto_Download.rsc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# RouterOS Fucntion
# Copyright (c) Grzegorz Budny
# Version 1.0
# Last update: 2/8/2020
# Checks if latest package is available. Downloads it to specified location and send email notification
:global PackageAutoDownload do={
/system package update check-for-updates;
:local packageCurrent [/system package update get installed-version];
:local packageLatest [/system package update get latest-version];
:local packageName [/system package get value-name=name number=0];
:local systemName [/system identity get value-name=name];
:if ($packageCurrent != $packageLatest) do={
:log info ("...:::New cAP package available - ".$packageLatest." Downloading:::...");
/system package update download;
:log info ("...:::".$packageName." ".$packageLatest." downloaded. Moving to specified container:::...");
:delay 2;
/tool fetch address=$capsmanIP src-path=($packageName."-".$packageLatest.".npk") user=$userName password=$password dst-path=($packagePath."/".($packageName."-".$packageLatest.".npk")) mode=ftp port=21;
:log info ("...:::Package moved to ".$capsmanIP."\n Ready to deploy:::...");
/tool e-mail send server=$smtpServer port=$smtpPort from=($systemName.$domain) \
to=$recipient subject=("cAP update available on ".$systemName) \
body=($systemName." downloaded latest package ".$packageLatest.". \
\nPackage ready to deploy.");
/file remove ($packageName."-".$packageLatest.".npk");
}\
else={
:log info ("...:::No cAP updates found. ".$packageCurrent." is the latest version...:::");
/tool e-mail send server=$smtpServer port=$smtpPort from=($systemName.$domain) \
to=$recipient subject=("No cAP update available on ".$systemName) \
body=($systemName." cAPs have installed the latest package ".$packageLatest);
}
}
$PackageAutoDownload userName=userName password=password packagePath=path \
smtpServer=ipAddress smtpPort=poty [email protected] \
[email protected] capsmanIP=capsmanIP;