Netinstall userscript not working

Hi folks,

I have a script that I use to provide as a “base config” using netinstall.

/system identity
set name=some-name-to-identify

/system clock
set time-zone-name=Europe/Berlin

/interface bridge
add name=bridge_default

/interface lte
set [ find ] allow-roaming=no name=lte1 pin=1234

/interface lte apn
set [ find default=yes ] apn=internet.telekom

/interface bridge port
add bridge=bridge_default interface=ether1
add bridge=bridge_default interface=ether2

/ip address
add address=172.31.255.1/30 interface=bridge_default network=172.31.255.0

/ip firewall filter
add action=accept chain=input comment="accept established, related, untracked" connection-state=established,related,untracked
add action=drop chain=input comment="drop invalid" connection-state=invalid
add action=accept chain=input comment="accept ICMP" protocol=icmp
add action=accept chain=input comment="accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=accept chain=input comment="dns tcp" dst-port=53 in-interface=bridge_default protocol=tcp
add action=accept chain=input comment="dns udp" dst-port=53 in-interface=bridge_default protocol=udp
add action=accept chain=input comment=ssh dst-port=22 in-interface=bridge_default protocol=tcp
add action=accept chain=input comment=winbox dst-port=8291 in-interface=bridge_default protocol=tcp
add action=drop chain=input
add action=accept chain=forward comment="accept established,related, untracked" connection-state=established,related,untracked
add action=drop chain=forward comment="drop invalid" connection-state=invalid
add action=drop chain=forward comment="drop all from WAN (lte1)" in-interface=lte1

/ip firewall nat
add action=masquerade chain=srcnat out-interface=lte1

/ip dns
set allow-remote-requests=yes

/user
set [find name=admin] password=SuperSecretPassphrase

/system routerboard settings
set auto-upgrade=yes

It seems like the most stuff is working fine, but the lte config part just does not work. When I remove

/interface lte
set [ find ] allow-roaming=no pin=1234

/interface lte apn
set [ find default=yes ] apn=internet.telekom

it seems to work fine, but as soon as I add these code lines it won’t work after factory reset.

I also tried to work around using these code lines:

/system script
add dont-require-permissions=no name=setupLteModemOnBoot owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="\r\
    \n/interface lte set [ find ] allow-roaming=no pin=1234\r\
    \n/interface lte apn set [ find default=yes ] apn=internet.telekom\r\
    \n"

/system scheduler
add name=setupLteModemOnBoot on-event="/system/script/run setupLteModemOnBoot" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-time=startup

But it seems that either the scheduler is not triggering or the script does not work on early startup … when I use these lines and execute the script manually after the WAP ist started, it works as expected.

I assume the LTE modem is somehow handled another way then “normal” interfaces?!? Hope anyone can clarify what’s going on with the LTE interface :smiley:

Best regards
J

PS if I copy all the code lines to a completely unconfigured (/system reset-configuration no-defaults=yes) line by line, everything works as expected.

It is indeed needed to wait a bit longer before touching that LTE interface.
Right after startup, it’s not there yet. I’ve seen it sometimes absent for a bit under a minute on AX Lite LTE.
Best to move that LTE part as last section of your script so all the rest can finish already.

Use a hard coded delay or check first in a loop some times with small waiting period that the interface effectively exists before proceeding.
If not found, abort and log error.

Default config script might give you some better view how to handle it best.

On AX Lite LTE it’s like this:

:local count 0;
:while ([/interface lte find] = "") do={ 
     :set count ($count +1);
     :if ($count = 115) do={
          :log warning "DefConf: Unable to find LTE interface(s)"; 
          /ip address add address=192.168.88.1/24 interface=ether1 comment="defconf";
          /quit
          }
     :delay 1s;
};