Can I run hotspot setup wizard using API, Telnet, or SSH?

I would like to script hotspot setup wizard. I have thought about using TELNET and Expect but I prefer an easier method.

My questions is can I run the hotspot setup wizard using the API, Telnet (non-interactive), or SSH?

Why not just apply the commands that the wizard would generate? The wizard doesn’t do anything special, it just generates configuration that can also be applied manually.

This sounds like quite a good workaround but it’s not ideal. I could export my custom configuration. Then I could run the wizard and export again. Then do two imports.

It sounds a little bit messy. More ideal would be to trigger the wizard with predefined configuration parameters. Until further notice I guess I can’t use the API, Telnet, or SSH to run the setup wizard and I am stuck with import/export or Expect.

You can insert/change configuration via SSH in an automated fashion - in the simplest case just via

ssh user@host "/ip hotspot add name=whatever; /ip hotspot profile add name=whatever;"

If the user is set up with PKI and the private key is loaded in the SSH keychain that is completely non-interactive. That also gives you control over all the parameters the wizard doesn’t even expose.

Also, as per http://wiki.mikrotik.com/wiki/Manual:Configuration_Management#Automatic_Import any file called whatever.auto.rsc will automatically be executed on upload.

Both methods would be less messy than stepping through a wizard in an automated fashion.

I appreciate your quick replies and your workaround and thanks I know how to import automated scripts.

The point is the wizard asks about 5 questions. I then generates about 55 configuration rules. Some of these rules are pretty complex and look pretty internal. Some of them are dynamic. Have you have a look at some of them? E.g. the dynamic NAT jump and redirect rules? Like the one that redirects to port 64874? How would I script those? They don’t even show on the command line.

Please don’t take this personally, and I really appreciate your prompt replies, but I am sticking to my original question. I need a clear answer to my original question which is “Can I use the API or Telnet or SSH to activate the wizard with predefined parameters?”

Well, here’s a clear answer: no, you cannot script the wizard unless you’re using Expect scripts to parse replies.

But those NAT and filter rules get automatically created whenever a Hotspot is activated. I am intimately familiar with them.

/ip hotspot add profile=default interface=ether1

Poof. All those NAT and filter rules magically appear. There is no need to create them. The wizard doesn’t create them, either.

The below works perfectly fine to create a fully functional Hotspot from scratch, including a VLAN subinterface and all the DHCP parameters. The Hotspot specific part can be shortened to just 4 lines - two if you don’t need a local user with a dedicated profile, and one if you don’t need a dedicated Hotspot profile.

/interface vlan
add arp=enabled comment="" disabled=no interface=inside l2mtu=1596 mtu=1500 name=test use-service-tag=no vlan-id=35
/ip address
add address=10.35.0.1/22 broadcast=10.35.3.255 comment="" disabled=no interface=test network=10.35.0.0
/ip pool
add name=DHCP-Pool-test ranges=10.35.0.11-10.35.3.254
/ip dhcp-server network
add address=10.35.0.0/22 comment=test dns-server=10.35.0.1 gateway=10.35.0.1
/ip dhcp-server
add address-pool=DHCP-Pool-test authoritative=yes bootp-support=static disabled=no interface=test lease-time=3h name=DHCP-test
/ip hotspot profile
add dns-name=hotspot.example.com hotspot-address=10.35.0.1 html-directory=test http-proxy=0.0.0.0:0 login-by=http-pap name=test rate-limit=1m/1m smtp-server=0.0.0.0
/ip hotspot user profile
add idle-timeout=none keepalive-timeout=15m name=test rate-limit=1m/1m shared-users=unlimited status-autorefresh=1m transparent-proxy=no
/ip hotspot user
add disabled=no name=test password=test profile=test
/ip hotspot
add disabled=no idle-timeout=30m interface=test keepalive-timeout=5m name=test profile=test

I promise not to take things personally, and haven’t so far. I am, however, sticking to my original reply that you’re going about this the wrong way.

Awesome, thanks. Your rules look good, I’ll use them.