Community discussions

MikroTik App
 
OmniSurf
just joined
Topic Author
Posts: 11
Joined: Sun Dec 05, 2010 2:54 am
Location: Plattsburg, MO
Contact:

Can the reset-configuration warning prompt be disabled?

Fri May 23, 2014 10:16 pm

I am remotely managing over 400 MT devices and I am trying to script the reset-configuration. This is for our help desk to have a widget in our network management tool to reset the MT to our configuration without really needing an interactive connection or any Mikrotik specific knowledge. This is for replacement units and when the MT configuration is suspect.

The example script below would trigger a reset-configuration as long as the specified script existed on the MT. However, I had hoped the warning prompt would be suppressed when run from a script like the reboot command. Alas, my hopes are dashed upon the rocks of insanity...

So, is there a way to answer the prompt from within a single script or is there an "undocumented" switch (like force=yes) to prevent the prompt?

The import command is undesirable do to the fact that I would need to write a script to remove our settings just to re-apply the same settings again. Not to mention this wouldn't incorporate a reboot in the process to get a clean start.

I am willing to explore all methods to accomplish this. I've searched the forum to no avail.

#ResetCfg.rsc
#script start
:if ([:len [/file find name="MyLoad.rsc"]] > 0) do={
/system reset-configuration keep-users=no no-defaults=yes skip-backup=yes run-after-reset=MyLoad.rsc
} else {
:put "Specified file not found."
};
#script end

Thanks in advance!
 
OmniSurf
just joined
Topic Author
Posts: 11
Joined: Sun Dec 05, 2010 2:54 am
Location: Plattsburg, MO
Contact:

Re: Can the reset-configuration warning prompt be disabled?

Fri May 23, 2014 11:21 pm

More info...

I wasn't triggering the execution of the script file with the /system/script functions. Once I did that the prompt went away when run from Winbox. The prompt remains when "/system/script/run ResetCfg" is used via SSH.

#CLI
/system script add name=ResetCfg source=\
\":if ([:len [/file find name=\"MyLoad.rsc\"]] > 0) do=\
{/system reset-configuration keep-users=no no-defaults=yes skip-backup=yes \
run-after-reset=MyLoad.rsc}"

#Winbox - Executes without prompt :-)
>System>Script>Select ResetCfg then "Run Script"

#CLI - Still prompts :-(
/system/script/run ResetCfg

I need the script to run without a prompt from SSH.
 
OmniSurf
just joined
Topic Author
Posts: 11
Joined: Sun Dec 05, 2010 2:54 am
Location: Plattsburg, MO
Contact:

Re: Can the reset-configuration warning prompt be disabled?

Tue May 27, 2014 6:17 pm

OK..I've got this working

#add the script via SSH
ssh admin@192.168.88.1 /system script add name=ResetCfg source=\"if ([:len [/file find name=\22MyLoad.rsc\22]] > 0) do={/system reset-configuration keep-users=no no-defaults=yes skip-backup=yes run-after-reset=MyLoad.rsc}\"

#Run the script via SSH
ssh admin@192.168.88.1 /system script run [find name=\"ResetCfg\"]

When SSH has an interactive shell, reset-configuration will still prompt even when running in a script. If the SSH connection doesn't invoke the shell, then it will execute the script without a warning prompt. That is a quirky little distinction.

I hope this helps someone else.