Building image, keeping config files

Hello,
i started building my own image, starting from the almost perfect hnyman image for R7800 and changing a couple of things (for example, adding nginx and sftp server)
incredibly it works and i can install the image :slight_smile:
but i have a couple of problems:

  • i lost the system->software menu item in Luci and i don't know why
  • i put in the files folder also my config files for nginx, but the default config installed by nginx wins. i assume it is created after. how can i fix this?

thanks

nginx: I guess, that your nginx is auto started by standard script in /etc/init.d
Which will provide the "default" config via/from uci to nginx.
Disable the automatic start of nginx (i.e. using /etc/uci-defaults), and do the start of nginx yourself, i.e. from rc.local

ok it makes sense, i see two scripts in uci-defaults related with nginx, i'll try working on those (or adding one more to be executed later..)
thanks.
any idea on the luci "software" menu item missing?

No, sorry. I never use LuCI in custom built image, as quite often I need unusual config options/files, anyway. Like for nginx. I always do direct mods to the config files in /etc/config, if required.

Hello again,
i'm amused i can build my own image with all the packages i use (now i also have transmission and minidlna working, i'll be turning off my qnap nas soon lol), but there is still something i can't understand with reference to the "files" directory and the "uci-defaults" script.
I put some files in the files/etc/nginx folder (well, my configuration files and my ssl certs)
Then i also created a uci-defaults script to make the router overwrite the standard config file of nginx with the one i need.
Well, this is not working.
I intend that:

  • the content in the "files/etc" folder does not overwrite files already existant (and the etc folder is kept by the system in case of update)
  • similarly, the uci-defaults script can't overwrite files

Am i wrong? if this is the case, is there an alternative method to do the above?
Thanks a lot

Your explanation is unclear.

Basic path:

  • "files" directory in the build system contains files that will be overwrite the defaults package files during the build process, and those files from "files" are thus included in the image
  • when you flash that, the files are included from the image and are always flashed there (into /rom)
  • if you "keep settings" in a sysupgrade, your old/current the config files will then overwrite the files embbeded in the image (and will be placed in /overlay).
  • if you have something in uci-defaults, you can modify the config files further, but it is up to you to ensure that your own shell script behaves well.

Based on your explanation, I am still unsure what you actually want to do.

As you compile your own image, I can't figure out why you would need uci-defaults, as you can include the correct config files directly in the image.

Uci-defaults files are meant mostly for transition scripts etc., where you need to modify the config files e.g. due to changes in the main package. The term uci-defaults maybe leads you astray.

1 Like

Hello :slight_smile:
i think the point is that "if you "keep settings" in a sysupgrade, your old/current the config files will then overwrite the files embbeded in the image (and will be placed in /overlay)."

So the files kept are overwriting the files in the image. Ok this explains the behaviour i'm seeing..
Basically i "keep settings" because i don't know where the general config is saved (pppoe connection, wifi config and so on), but probably i should look for these files and include them in the build, avoiding the keep settings.
I'm using uci-defaults to:

  • install acme.sh (that modifies the crontab)
  • update the nginx config

As always, thanks a lot :slight_smile:

ok, i understand why my question sounded so stupid :slight_smile:
i did a backup of config files so now i can have a image full functional without keeping old settings

BUT

i still have one problem with nginx. the package has a couple of uci-defaults script that are messing up my config file embedded in the image.
is there a way to avoid the uci-defaults script to be used?
should i for example use a uci-defaults script to delete the wrong ones?

thanks

Why not simply delete/edit the offending script files in nginx before compilation, in your local source tree.
feeds/packages/net/nginx/...

You can either patch the makefile to not install the ucidefaults files (if they are completely unnecessary), or you can edit the files themselves and remove/edit just the offending lines.

Originals:

https://github.com/openwrt/packages/blob/master/net/nginx/Makefile#L370

https://github.com/openwrt/packages/blob/master/net/nginx/files-luci-support/60_nginx-luci-support

Note that SSL and no-ssl are handled separately.

i didn't know i could edit also the packages..
amazing, this is a much better idea
thanks a lot

may i ask you what do you use to create your patch file?
i assume this should be the right way to modify my nginx package..
i tries with the "diff" linux command, but the output file is not like yours..
thanks

You can just edit the Makefile.
(No need to actually create a separate patch)

well, obviously this works like a charm and i thank you :slight_smile:
but i can't understand what is going to happen in case of update of the nginx package..

if there are conflicts when nginx Makefile is updated next time, git will notify you and you will need to edit the conflicts away. Normal git work... (e.g. a simple package upstream version update does not usually cause conflicts, but if the package maintainer makes heavy edits to the Makefile, you may need to fix things...)