I'm sure there must be a better solution, but couldn't you test the new firmware on an identical router on your lan to get the settings right, and build the firmware including any needed packages and with your new config files in the appropriate directories and flash it on your local test router first to check everything works without intervention. Or else create a script that runs on first boot and uses UCI commands.
In fact a quick google finds: Custom script to run on first boot using linux builder - #16 by psherman