Community discussions

MikroTik App
 
Beone
Member Candidate
Member Candidate
Topic Author
Posts: 246
Joined: Fri Feb 11, 2011 1:11 pm

Add a script?

Wed Mar 09, 2011 6:55 pm

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
 
fewi
Forum Guru
Forum Guru
Posts: 7734
Joined: Tue Aug 11, 2009 3:19 am

Re: Add a script?

Wed Mar 09, 2011 7:00 pm

/system script add name=dyndns
/system script edit [/system script find name=dyndns] source
That gets you a nano like text editor.
Specific answers require specific questions. When in doubt, post the output of "/ip address print detail", "/ip route print detail", "/interface print detail", "/ip firewall export", and an accurate network diagram.
 
Beone
Member Candidate
Member Candidate
Topic Author
Posts: 246
Joined: Fri Feb 11, 2011 1:11 pm

Re: Add a script?

Wed Mar 09, 2011 7:08 pm

Lovely, tnx.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Add a script?

Thu Mar 10, 2011 2:33 pm

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.
 
forne
Frequent Visitor
Frequent Visitor
Posts: 65
Joined: Tue Feb 15, 2011 3:18 pm

Re: Add a script?

Thu Mar 10, 2011 4:15 pm

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.
 
Beone
Member Candidate
Member Candidate
Topic Author
Posts: 246
Joined: Fri Feb 11, 2011 1:11 pm

Re: Add a script?

Thu Mar 10, 2011 6:02 pm

@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
 
fewi
Forum Guru
Forum Guru
Posts: 7734
Joined: Tue Aug 11, 2009 3:19 am

Re: Add a script?

Thu Mar 10, 2011 6:20 pm

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.
Specific answers require specific questions. When in doubt, post the output of "/ip address print detail", "/ip route print detail", "/interface print detail", "/ip firewall export", and an accurate network diagram.
 
Beone
Member Candidate
Member Candidate
Topic Author
Posts: 246
Joined: Fri Feb 11, 2011 1:11 pm

Re: Add a script?

Fri Mar 11, 2011 9:57 am

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
 
Feklar
Forum Guru
Forum Guru
Posts: 1726
Joined: Tue Dec 01, 2009 11:46 pm

Re: Add a script?

Fri Mar 11, 2011 5:42 pm

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
 
Beone
Member Candidate
Member Candidate
Topic Author
Posts: 246
Joined: Fri Feb 11, 2011 1:11 pm

Re: Add a script?

Fri Mar 11, 2011 7:45 pm

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.
 
fewi
Forum Guru
Forum Guru
Posts: 7734
Joined: Tue Aug 11, 2009 3:19 am

Re: Add a script?

Fri Mar 11, 2011 7:56 pm

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.
Specific answers require specific questions. When in doubt, post the output of "/ip address print detail", "/ip route print detail", "/interface print detail", "/ip firewall export", and an accurate network diagram.
 
Beone
Member Candidate
Member Candidate
Topic Author
Posts: 246
Joined: Fri Feb 11, 2011 1:11 pm

Re: Add a script?

Fri Mar 11, 2011 9:26 pm

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 :-)
 
fewi
Forum Guru
Forum Guru
Posts: 7734
Joined: Tue Aug 11, 2009 3:19 am

Re: Add a script?

Fri Mar 11, 2011 10:44 pm

Use HTTPS instead. Much easier to administer than various CHAP implementations.
Specific answers require specific questions. When in doubt, post the output of "/ip address print detail", "/ip route print detail", "/interface print detail", "/ip firewall export", and an accurate network diagram.
 
Beone
Member Candidate
Member Candidate
Topic Author
Posts: 246
Joined: Fri Feb 11, 2011 1:11 pm

Re: Add a script?

Sat Mar 12, 2011 8:58 am

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.

Who is online

Users browsing this forum: YaCy [Bot] and 35 guests