<div dir="ltr"><div dir="ltr"></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Oct 19, 2019 at 6:00 AM Baptiste Jonglez <<a href="mailto:baptiste@bitsofnetworks.org">baptiste@bitsofnetworks.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
On 30-09-19, Russell Senior wrote:<br>
> > As a side-note, does anybody use uci-defaults scripts?<br>
> > <a href="https://openwrt.org/docs/guide-developer/uci-defaults" rel="noreferrer" target="_blank">https://openwrt.org/docs/guide-developer/uci-defaults</a><br>
> ><br>
> > It seems like the best way to implement customization without having to<br>
> > update file templates with each OpenWrt release, but during my quick<br>
> > overview tour I haven't noticed any project using this method.<br>
> ><br>
> <br>
> Yes, we use it. Iirc, one thing you need to be aware of is that the<br>
> uci-defaults scripts run after any restored settings. This isn't a problem<br>
> for us, because we never save settings when reflashing. I have some<br>
> infrastructure that saves the initial uci config and diffs files in the<br>
> overlayfs, so that any local changes can be noticed and folded into<br>
> replacement firmware.<br>
<br>
Thanks for this input!<br>
<br>
I take it that you generate firmware images then, which tool do you use?<br>
Just the imagebuilder + uci-defaults scripts, or something more elaborate?<br></blockquote><div><br></div>I'm only slightly embarrassed to say that I just use the normal OpenWrt build system. We are generally building OpenWrt master HEAD, so we are subjected to more upstream volatility than if we were sticking to a stable branch. We have approximately a dozen each of about 5 different gateway devices in our network, and building images has been a semi-manual process.  We have a database of node configuration values available as json from an api [1], and a script [2] that extracts values from the database and inserts them into a template for the files overlay. The template uses uci-defaults scripts. The reason we moved to using files/etc/uci-defaults/ scripts instead of static files/etc/config/ files is so that we don't lazily miss OpenWrt config changes. <br></div><div class="gmail_quote"><br></div><div class="gmail_quote">Our process is something like this:<br></div><div class="gmail_quote"><br></div><div class="gmail_quote"> a) we git pull the OpenWrt tree, and update feeds;<br></div><div class="gmail_quote"> b) we build an image with an auto-generated files overlay tree and test it on a local device in our test bed and make sure it basically works;</div><div class="gmail_quote"> c) we auto-generate the files overlay tree for a remote device;</div><div class="gmail_quote"> d) we cp -a that files overlay to a files-orig tree;</div><div class="gmail_quote"> e) we look at the build artifacts from the last version we flashed on the remote devices and look at the diff -ruN between the files-orig and files we used in generating that prior version and apply the patch (sometimes with minor changes or fixups) to the newly auto-generated files overlay;<br></div><div class="gmail_quote"> f) we exploit the squashfs+overlayfs file system on the remote device to check to see what we might have adjusted since the last time we flashed [3], and make whatever adjustments that seem appropriate to the new files overlay (we capture the initial uci config shortly after first-boot [4], and have diffutils available on the devices);</div><div class="gmail_quote"> g) we build the image with the modified files overlay and scp it to the remote device and "sysupgrade -v -n" it, and make sure it comes back up, is phoning home, and seems to be working;</div><div class="gmail_quote"> h) we save the build artifacts for that remote device including:</div><div class="gmail_quote">  1) the bin directory;</div><div class="gmail_quote">  2) the .config</div><div class="gmail_quote">  3) the output of the scripts/diffconfig.sh;<br></div><div class="gmail_quote">  4) files-orig tree (the auto-generated tree);</div><div class="gmail_quote">  5) files tree (actually used in the build);</div><div class="gmail_quote"><br></div><div class="gmail_quote">Because there are changes in OpenWrt over time, this process requires human oversight to get right with a high probability. The consequences of getting it wrong are painful enough (down time and driving across town in order to recover) that we have been reluctant to further automate it. At our scale and development pace, it works for us.<br></div><div class="gmail_quote"><br></div><div class="gmail_quote">Because it is almost always me building the images, and I have the full build system available, it doesn't really make sense to use the imagebuilder.</div><div class="gmail_quote"><br></div><div class="gmail_quote">[1] <a href="https://personaltelco.net/api/v0/hosts">https://personaltelco.net/api/v0/hosts</a></div><div class="gmail_quote">[2] <a href="https://github.com/personaltelco/ptp-openwrt-files">https://github.com/personaltelco/ptp-openwrt-files</a></div><div class="gmail_quote">[3] <a href="https://github.com/RussellSenior/ptpcab/blob/master/ptp-utils/files/since-last-flash.sh">https://github.com/RussellSenior/ptpcab/blob/master/ptp-utils/files/since-last-flash.sh</a></div><div class="gmail_quote">[4] <a href="https://github.com/personaltelco/ptp-openwrt-files/blob/master/etc/uci-defaults/ptp.zzz.defaults">https://github.com/personaltelco/ptp-openwrt-files/blob/master/etc/uci-defaults/ptp.zzz.defaults</a></div></div>