Page 1 of 1

repository for scripts

Posted: Tue Dec 22, 2015 11:35 am
by foxch2
Всем привет
нужна помощь. использую около 30 маршрутизаторов
Есть ли способ распространить скрипты и задачи в планировщик из центра?
не подключаясь на каждый.
Я понимаю, что скрипты на всех маршрутизаторах будут одинаковыми, меня это устраивает.

Hello
need help. I use about 30 routers
Is there a way to distribute scripts and tasks to the scheduler from the centre?
without connecting to each.
I understand that the script on all routers will be identical, it suits me.

Re: repository for scripts

Posted: Tue Dec 22, 2015 12:46 pm
by patrikg
Have a look at this page to find some scripts, that you can change to
match what you need.

http://wiki.mikrotik.com/wiki/Scripts

http://wiki.mikrotik.com/wiki/Manual:Scripting

Re: repository for scripts

Posted: Tue Dec 22, 2015 12:52 pm
by boen_robot
There isn't a RouterOS proprietary way of doing this.

You can do it by making one of the routers accessible to the others via FTP, and from those other routers, you can then do
/tool fetch url="ftp://user:pass@192.168.88.1/script.rsc" keep-result=yes
:delay 2s
/import file="script.rsc";
However, keep in that that in this fashion, you're potentially vulnerable to man-in-the-middle attacks (which in this case could prove to be fatal, as the attacker creates their own admin username via injected code in the script, and that way completely takes over your router). You'd need to set up a separate device as an HTTPS server (with a valid certificate) to not be.

Re: repository for scripts

Posted: Tue Dec 22, 2015 12:53 pm
by ConnectivityEngineer
The easiest way is to simply setup a shared file location on a webserver

Then run
/tool fetch url=http://yourdomain.com/files/data.txt[code]

Every script I run also has the following at the top


[code]
# Printing local time for Log purposes ...
:local CurrentTime [/system clock get time];
:log warning "Script run at Current Time = $CurrentTime. . ."
What I have done is I actually run a script that fetches a new script which is the one I update to list all the files we want to then get and run.

So first Script grabs a script to fetch any and all scripts I want as well as deletes any scripts we do not want on our systems any longer.


I run the script once per day - and it makes things pretty good.

Now - one other option ~ look into the API and do some magic for PHP

Re: repository for scripts

Posted: Tue Dec 22, 2015 4:20 pm
by foxch2
There isn't a RouterOS proprietary way of doing this.

You can do it by making one of the routers accessible to the others via FTP, and from those other routers, you can then do
/tool fetch url="ftp://user:pass@192.168.88.1/script.rsc" keep-result=yes
:delay 2s
/import file="script.rsc";
However, keep in that that in this fashion, you're potentially vulnerable to man-in-the-middle attacks (which in this case could prove to be fatal, as the attacker creates their own admin username via injected code in the script, and that way completely takes over your router). You'd need to set up a separate device as an HTTPS server (with a valid certificate) to not be.
I thought in this way
I just didn't know that i can import tasks use this
/import file="script.rsc";

about attacks - all my routers connected to VPN
FTP server is on the internal network and has no access to external network

I'll try it