Custom entry in config.xml

I have for a while been using a custom compiled version of the firmware (see my OpenVPN+IPTables guide). All is working well except for the fact that with the OS being replaced at each boot, I need to manually load stuff after each boot.

To solve the boot issue, I’ve edited the firmware again, this time to add some entries to the “system_init” script. That seems to work as expected (loads on boot the stuff I need loading). But I would like to make some of the script being loaded customisable. In the firmware, this seems for the most part to be done in the “config.xml” file which is read and parsed by the “system_init”. Parsing the file is quite straight forward, as is adding entries - it’s just XML after all.

The trouble I have is that whenever I go to the web interface and change anything, all of the custom entries I have added to the “config.xml” file seem to get deleted.

Anyone know if it is possible to add custom entries to this file without them being deleted by the web interface?

Nice to see you back here, TCWorld - after a very long absence.

Unfortunately, no, I don’t think you can. That config.xml is really meant to be used for the configs that the system_init script reads at boot time. But why don’t you put your own custom xml configs in a separate file and use the same small xml parser program and use that to load your values. This way your xml values stays unchanged, even when the WD one gets overwritten. Unless I misunderstood you and you are not trying to add your own custom xml configs but are putting in your own edited configs.

However, if some of these xml values are gonna remain the same - you can pre-bake them into the firmware’s config.xml file itself. I don’t have my dev environment for this firmware up and ready at the moment - so I can’t tell you the specifics - but I have actually modded the config.xml with some custom values and put them inside a zip or tar file I think - it’s one of the core files that’s in the merge directory when you compile the firmware. Inside that zip or tar file, there is this config.xml. You can add any edits there, if you like - and those are going to be preset always once you compile the firmware…so even when the dashboard makes edits to this file…I believe your changes will be preserved.

Do you know if there is any documentation on how the xmldbc works, couldn’t find a man page for it anywhere. I sort of get how to access things, and how to load an XML file, but I wasn’t sure if you could load more than one at the same time (how does it distinguish between each one open?) which is why I was trying to stick extra settings in the same one. If I can parse my own independent one, that would be ideal. Basically I wanted to have a config file so I can enable or disable OpenVPN starting at boot.

At the moment I have set it up so that system_init calls a bash script in the /usr/local/config directory, which I can then add the openvpn command into if I need, but I feel this is not a particularly secure way of doing things - it leaves a script file that gets called at boot which is not destroyed on restart - so if someone edits it, and adds something stupid like “shutdown” or whatever, it would completely brick the Nas (auto reboot on startup, sounds great…). Instead I want to have the openvpn command hard coded into the system_init script, and then use XML to determine whether to run it or not.