Community discussions

MikroTik App
 
Charg
newbie
Topic Author
Posts: 30
Joined: Wed Apr 07, 2021 11:49 am

Post-wifi split, how to apply only appropriate part of exported config?

Thu Jan 25, 2024 5:38 pm

I've had a single mikrotik model previously, which is why all the configurating was done by importing that single script. And I'd like to keep that approach of single script. Now one more router model is added to the zoo, and it has new driver in separate package (or something like that). Which is why /interface wireless isn't available on these models, hence script needs to be adjusted.

Here's my intention:
  • if package with name like wave2 exist - stop execution and write text that update is neccessary - that part works as expected
  • if package with name like wireless exist - configure interfaces in /interface wireless submenu - that part does NOT work as expected on mikrotiks where this menu doesn't exist. I expect entire do={} block to be skipped because condition isn't met - but it doesn't happen for whatever reason.
  • if package with name like wifi-qcom exist - configure interfaces in /interface wifi menu - script doesn't go to that part because previous part fails
So here's code I'm talking about:
:if ([:len [/system package find name~"wave2"]]>0) do={error "UPDATE ROUTEROS, 7.13.1 or newer"}
:if ([:len [/system package find name~"wireless"]]>0) do={
/interface wireless
set [ find default-name=wlan1 ] country=ukraine disabled=no mode=ap-bridge ssid=ssidname wireless-protocol=802.11
set [ find default-name=wlan2 ] country=ukraine disabled=no mode=ap-bridge ssid=ssidname wireless-protocol=802.11
/interface wireless security-profiles
set [ find default=yes ] authentication-types=wpa2-psk eap-methods="" mode=dynamic-keys supplicant-identity=MikroTik
}
:if ([:len [/system package find name~"wifi-qcom"]]>0) do={
/interface/wifi
set [ find default-name=wifi1 ] name=wlan1 disabled=no configuration.country=Ukraine configuration.ssid=ssidname security.authentication-types=wpa2-psk,wpa3-psk security.passphrase=password
set [ find default-name=wifi2 ] name=wlan2 disabled=no configuration.country=Ukraine configuration.ssid=ssidname security.authentication-types=wpa2-psk,wpa3-psk security.passphrase=password
}
All of that code is in a file. When I import this file (/import file=config.rsc verbose=yes) on model that does NOT have wireless package - I'd expect entire do={} block to be skipped. However, execution continues line by line and errors out at this line:
set [ find default-name=wlan1 ] country=ukraine disabled=no mode=ap-bridge ssid=ssidname wireless-protocol=802.11 \
What I want it to do is to skip everything inside do={} block because condition if ([:len [/system package find name~"wireless"]]>0) isn't true.

I've also tried ending each line inside do={} block with backslash, with semicolon or nothing - same result: execution stops at line mentioned above.

I'd be grateful if someone suggest a way to achieve single script for both device types.

Who is online

Users browsing this forum: No registered users and 8 guests