Page 1 of 1

Add a script?

Posted: Wed Mar 09, 2011 6:55 pm
by Beone
Hi,

New to MT.
I'd like to add a script, dyndns for example.
In the manual i see, I need to
/system script add name=dyndns source= to add a script.

But how do I add that source? (Give me back my vi ! ) :-)
I can't imagine i have to write (or copy) the script like that behind the "source=" entry.
Can someone tell me how I add for example this dyndns script? (or point me to the documentation where this is explained)
http://wiki.mikrotik.com/wiki/Dynamic_D ... for_dynDNS


many tnx.
B

Re: Add a script?

Posted: Wed Mar 09, 2011 7:00 pm
by fewi
/system script add name=dyndns
/system script edit [/system script find name=dyndns] source
That gets you a nano like text editor.

Re: Add a script?

Posted: Wed Mar 09, 2011 7:08 pm
by Beone
Lovely, tnx.

Re: Add a script?

Posted: Thu Mar 10, 2011 2:33 pm
by janisk
giving just name of script to edit will also work.

and F5 will refresh the color coding of the script, and if that coulor stops somewhere, it means there is some error in script.

Re: Add a script?

Posted: Thu Mar 10, 2011 4:15 pm
by forne
Beone, the easiest way to add a script is to use WinBox for that. When I tried to copy/paste a large script body into the text editor using Windows telnet, my router got hanged.

Re: Add a script?

Posted: Thu Mar 10, 2011 6:02 pm
by Beone
@Janisk: Tnx for the tip.

@forne: I did it on a rb450G from console (somehow I can't connect with winbox to that device, but I didn't try very hard yet) :-)
I will keep your tip in mind, tnx.

Kind regards
B

Re: Add a script?

Posted: Thu Mar 10, 2011 6:20 pm
by fewi
If you're pining for vi, you'll like the CLI better, anyway. And too right. Winbox is alright for monitoring since it refreshes values in near real time. The CLI is way better for applying configuration.

Re: Add a script?

Posted: Fri Mar 11, 2011 9:57 am
by Beone
If you're pining for vi, you'll like the CLI better, anyway. And too right. Winbox is alright for monitoring since it refreshes values in near real time. The CLI is way better for applying configuration.
True, I played with winbox before to configure a RB750, but swapped to cli soon :-)
On the other hand, in winbox you got a very quick overview of all the possibilities which is nice also, especially when you're new to MT, like me.
Really love RouterOS, but got many things to investigate before I will use it in production. (now everything I do is based on coova-chilli, ubnt and m0n0wall)

Need to read especially the stuff about config backup/restore, mass deployment, etc.
For example I wonder, if I backup/restore configs, are the homebrew scripts (like dyndns) also backed up and restored?

Also while we 're talking, If someone could point me to a way to use the same UAM server / loginscript for chillispot based hotspots and MT hotspots that would be very helpfull too.
(I got issues with UAM secret / challenge which is handled differently in both devices)


Kind regards & thx
B

Re: Add a script?

Posted: Fri Mar 11, 2011 5:42 pm
by Feklar
Backup and restore is made to be used on the same router, or router model that it was taken on. Uploading it to a different model will make a partially broken configuration. We use /export and send ourselves and e-mail every week with the current configuration to work as our backup. /export generates the text commands necessary to get the router configured the way it currently is, and can be uploaded to another router without an issue. You'll just want to remove information like MAC addresses to avoid potential problems.

I'm not sure what the UAM server is, but I'm assuming it's a remote login page? This wiki article covers how to modify the hotspot for various deployments.
http://wiki.mikrotik.com/wiki/Manual:Cu ... ng_Hotspot

Re: Add a script?

Posted: Fri Mar 11, 2011 7:45 pm
by Beone
Backup and restore is made to be used on the same router, or router model that it was taken on. Uploading it to a different model will make a partially broken configuration. We use /export and send ourselves and e-mail every week with the current configuration to work as our backup. /export generates the text commands necessary to get the router configured the way it currently is, and can be uploaded to another router without an issue. You'll just want to remove information like MAC addresses to avoid potential problems.

I'm not sure what the UAM server is, but I'm assuming it's a remote login page? This wiki article covers how to modify the hotspot for various deployments.
http://wiki.mikrotik.com/wiki/Manual:Cu ... ng_Hotspot

Ok, for the backup / restore, I'll keep that in mind. But does it also include the scripts that were added?
Same question for the export.

UAM server indeed is the remote server where the login page resides. I have no problem to make it work with a seperate remote loginpage (only for mikrotik nas)
But I would prefer to use the same login page (hotspotlogin.php, you can find it on the net) for MT nas's as I use with chillispot nas's, but -as stated- have issues to get that working.
I'm sure it can be done though, I've seen other companies doing it, using the chillispot "uamport" value set to "mikrotik" as a hidden GET variable in the MT hotspot login.html page. This way they identify a MT nas next to a chillispot nas.


Kind regards
B.

Re: Add a script?

Posted: Fri Mar 11, 2011 7:56 pm
by fewi
Ok, for the backup / restore, I'll keep that in mind. But does it also include the scripts that were added?
Same question for the export.
Yes, it includes scripts. It includes the ENTIRE configuration.

Hotspot: RouterOS is very flexible. You can redirect to any external login page as long as it is whitelisted in the walled garden. You can use any page to trigger login as long as that page submits the credentials as POST variables 'username' and 'password' to the /login resource on the router.

Re: Add a script?

Posted: Fri Mar 11, 2011 9:26 pm
by Beone
Ok, thx for the confirmation about the scripts.

About remote loginpage: yes, username and password, but there's also the chapid used to encrypt te password.
And it's that encryption/decryption that is handled differently between chillispot and MT.
Need to investigate it all further, but time oohh time... always the same problem :-)

Re: Add a script?

Posted: Fri Mar 11, 2011 10:44 pm
by fewi
Use HTTPS instead. Much easier to administer than various CHAP implementations.

Re: Add a script?

Posted: Sat Mar 12, 2011 8:58 am
by Beone
Use HTTPS instead. Much easier to administer than various CHAP implementations.
Ah ok, you brought some light here.
My uam server does https, but now I realize that in my tests login-by http-chap was set in the hotspot profile instead of https.

So I will change:
/ip hotspot profile
set X login-by=http-chap

To:
/ip hotspot profile
set X login-by=https

and see if it authenticates the right way like that.
Tnx.