Page 1 of 1
Import on restart not working
Posted: Tue Jan 12, 2010 12:14 am
by 16mc
I have created a script for configuring our CPE's. I can cut and past to the command line and it works fine. If I import from the command line it works.
I exported the config and then attempted to reset and import the script using /system reset run-after-reset=file.rsc does not work. Tried calling a file that just does an import no go either. Write a short file with a couple of commands to set ip, works fine. Been messing with it all day and it seems to be a hit and miss with mostly misses. Reading the post there appeared to be issues with some versions of 3.x and fixed by 3.30. I have tried 4.2 and 4.4 with no success, is this still an issue?
I need to put standard configs on several hundred clients and this seem to be a good way to do it as I need to delete firewall setting etc. and there are various configs so a reset seem the simplest way.
Any input would be helpfull
Re: Import on restart not working
Posted: Tue Jan 12, 2010 2:54 am
by changeip
how big is the script in bytes? what happens if you set a delay at the beginning of the script of 5-10s?
Re: Import on restart not working
Posted: Wed Mar 10, 2010 11:37 pm
by Prairiekid
What are the odds? I was trying to get this working yesterday afternoon, and found that it would run partially through the exported script, but not all the way. Did you get an answer to this problem. I would like this to work as well to clean up some messy configs that are out there on some of my old radios. Past in our new config called "install" and then run after reset to repair any issues. In theory this should work.
Re: Import on restart not working
Posted: Thu Mar 11, 2010 1:40 am
by missinlnk
I always have to clean up our scripts that have been exported before they will import correctly. The easiest way to troubleshoot the script is to copy/paste it into a terminal. Scroll back up in the terminal and you should find at least one error message in the middle of your script. That error should tell you enough to allow you to fix the problem. Many times it's a line that isn't relevant to your custom config and that line can just be removed completely from your rsc file.
Re: Import on restart not working
Posted: Thu Mar 11, 2010 4:11 pm
by janisk
also, if you are trying to set up something like wireless interface settings, it may fail, even if syntax is ok and you are setting up sane things, the problem is - if you try to set up that is not yet initialized it will fail, like with wireless - it is initialized last, so, when you try to set up something on wireless interface that is there when everything boots up, interface is just not there.
try to add some delay or something.
Re: Import on restart not working
Posted: Fri Mar 12, 2010 3:42 pm
by pedja
It would be better if MT would load script after everything is initialized. That is what most of us would expect.
But, bigger problem is that when you export script, you usually cannot import it back without syntax errors.
Re: Import on restart not working
Posted: Fri Mar 12, 2010 3:45 pm
by mrz
I was able to export, reset config and import config back without errors.
Contact support and specify which part of configuration is not importing.
Re: Import on restart not working
Posted: Sat Mar 13, 2010 1:19 am
by Prairiekid
I did get it working as well following some of these suggestions. Added the 10 second delay, and then added one section at a time until I found the config items that were breaking the script. Seams to be that it doesn't want to add my user settings, as well as accepting the line where the Admin password is changed. Everything else worked, which is good enough for me at the moment because at least my radio reconnects to the system. At this point I have only a few manual changes to enter.
Re: Import on restart not working
Posted: Sat Mar 13, 2010 6:50 am
by dssmiktik
I too find that direct exports need modifications sometimes to correctly import.
This is usually because interfaces are set using the number (0, 1, 2) as they appear on startup.
It's usually best to setup a script to detect known values (mac address, ip address, etc...) or clear a config sub-menu before creating any rules.
As a rule of thumb, I try to put checks in where ever possible:
# Wait for wireless to come up
/interface wireless
{
:while ([:len find] = 0) do={ :delay 1 }
# at this point, we found at least one wireless interface. do some actions...
}
# To set an interface's name
/interface ethernet
{
:if ([:len find mac-address="00:11:22:33:44:55"] > 0) do={
# set interface name. this allows filter rules that use interface name to import correctly
/interface ethernet set [find mac-address="00:11:22:33:44:55"] name="LAN"
}
:if ([:len find mac-address="55:44:33:22:11:00"] > 0) do={
# set interface name. this allows filter rules that use interface name to import correctly
/interface ethernet set [find mac-address="55:44:33:22:11:00"] name="WAN"
}
}
# Remove all firewall
/ip firewall
{
# remove all firewall -> filter, nat, mange, and address-list rules to start with clean slate
filter {
:foreach r in=[find] do={ remove $r }
# add new rules
}
nat {
:foreach r in=[find] do={ remove $r }
# add new rules
}
mangle {
:foreach r in=[find] do={ remove $r }
# add new rules
}
address-list {
:foreach r in=[find] do={ remove $r }
# add new rules
}
}
Hope this is useful. With some error-checking, scripting can be quite reliable.