Community discussions

MikroTik App
 
bdk
just joined
Topic Author
Posts: 7
Joined: Fri Jan 08, 2021 12:08 am

auto.rcs stopping after 'IF' statement

Tue Jan 26, 2021 7:29 pm

I've read through "Scripts Tips & Tricks" and haven't found the answer to my situation... In reading through another post here and saw how someone would check if a user exists and if not, create it.
My auto.rcs stops after the 'IF' check happens. The 'IF' appears to work correctly as the account gets created if it doesn't exist and the password is set if the account already exists.

This is the tail end of the auto.rsc that I have the router load after a system reset:
...
# Check if user rancid exists, create if it doesn't.
:if ( [/user find where name=rancid] ) do={
   :log info ("User rancid already exists, skipping creation. Setting password")
   :put [ /user set [ find name=rancid ] password=rancid-passwd ]
} else ={
   :log info ("Creating user: rancid")
   :put [ /user add address=10.0.0.0/24 comment="Local auth Rancid user." group=read name=rancid password=rancid-passwd ]
}
/user set [ find name=admin ] password=admin-passwd 
/certificate add name=self-signed-certificate common-name=switch02\
    country=US days-valid=3650 key-size=4096 locality=NorthAmerica organization="USA."\
    state=USA trusted=yes unit="Engineering" key-usage=digital-signature,key-cert-sign,crl-sign
/certificate sign acs-self-signed-certificate
/ip service set www-ssl certificate=acs-self-signed-certificate
The script stops after the IF statement. The admin user's password does not get set and none of the certificate handling occurs.

Can I not use scripting inside the auto.rcs?

Is there something that I need to do to tell the auto.rcs to continue running after the 'IF' check happens?

Thanks.

Who is online

Users browsing this forum: jvanhambelgium and 23 guests