-
Notifications
You must be signed in to change notification settings - Fork 26
/
RouterOS_Script_Fetch.rsc
37 lines (27 loc) · 1.24 KB
/
RouterOS_Script_Fetch.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
# RouterOS Function
# Copyright (c) Grzegorz Budny
# Version 1.0
# Last update: 2/8/2020
# Fetches RouterOS script from external https location and runs it or creates schedule task
:global FetchScript do={
:foreach url,destinationFileName in=$urls do={
/tool fetch mode=https http-method=get url=$url dst-path=($destinationPath."/".$destinationFileName);
:log info "...:::Scripts fetched:::...";
:if ($isRun) do={
/system script run ($destinationPath.$destinationFileName);
:log info "...:::Script loaded to environment:::...";
}
:if ($isSchedule) do={
/system scheduler \
add interval=($interval.h) name=$taskName on-event=("system script run ".($destinationPath."/".$destinationFileName)) \
policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-date=jan/01/1970 start-time=$startTime;
:log info "...:::Script joined to scheduler:::...";
}
}
}
#Example
:global urlsBase {"URL1"="script1"; \
"URL2"="script2" \
};
$FetchScript urls=$urlsBase destinationPath="destinationPath" destinationFileName=$urlsBase;