Page 1 of 1

How can I tell if rsc is running from terminal, or using "Reset Config"?

Posted: Mon Aug 31, 2015 3:36 am
by Tal
Is there any way to tell if an rsc file is being imported from the terminal using the "import" command, or by using the "Run After Reset" feature of the "Reset Configuration" tool?

The only thing I can come up with right now is using uptime, but that's not very accurate.

Re: How can I tell if rsc is running from terminal, or using "Reset Config"?

Posted: Wed Sep 02, 2015 2:55 pm
by favincen
A script ran by "Run After Reset" feature should find an empty configuration (no ip address, no system identity, etc.).

I have myself an initialization script that will run only if it considers the box has default settings. I test for no ip address (other than eventually 192.168.88.1/24), and default system identity :
# A box is considered unconfigured if system identity name is the default "MikroTik" and 
# it has no ip address or only the default 192.168.88.1/24 . 
if ( ( [/system identity get name] = "MikroTik" ) and \
     ( [:len [/ip address find where address!="192.168.88.1/24"] ] = 0 ) \
   ) do={ 
  :log warning "This box is brand new. Configuring it !"
# ADD ANY CODE YOU WISH
}
hope this helps.

Re: How can I tell if rsc is running from terminal, or using "Reset Config"?

Posted: Wed Sep 02, 2015 3:24 pm
by Tal
Thanks, but I already have similar code in my script. This only tells me if the router config is clean though - not if it's running from terminal or using the "run after reset" feature, which is what I need to know. Any other ideas?