-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathRouterOS_Config_Fetch.rsc
65 lines (41 loc) · 1.81 KB
/
RouterOS_Config_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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# RouterOS Function
# Copyright (c) Grzegorz Budny
# Version 1.0
# Last update: 22/22/2020
# Fetches RouterOS script (dedicated for initial config) adds scheduler entry to start it on startup
:global FetchConfig do={
:log info "...:::Configuration fetch process started:::...";
:do {
/tool fetch address=$repositoryIP user=$userName password=$password \
port=21 mode=ftp src-path=($sourcePath.$sourceFileName) dst-path=($destinationPath.$destinationFileName);
} on-error={
:put "An error occured when dowloading configuration file!";
:log critical "...:::An error occured when dowloading configuration file!:::...";
};
:if($isRun)do={
:do {
:log info "...:::Configuration import started:::...";
/import ($destinationPath.$destinationFileName);
} on-error={
:put "An error occured during configuration import!";
:log critical "...:::An error occured during configuration import!:::...";
};
:delay 5;
:log warning "...:::Import secessful. Rebooting device:::...";
/system reboot;
}\
else={
:log info "...:::Configuring import on startup:::...";
: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;
} on-error={
:put "An error occured during import job schedule!";
:log critical "...:::An error occured during import job schedule!:::...";
}
:log info "...:::Configuration job scheduled for next startup!:::...";
}
}
FetchConfig isRun=true;