Ok. It should be possible to automatically remove all these configurations. One algorithm would be:
-
Build a list of packages which are also removed by the specific nethserver package. Either do it upfront or do it incrementely package by package later by querying the list of “yum autoremove”.
-
Before removal of a package, check which template files are defined by the installed package. Then remove the package and check again. If there is another package installed which has a template part for the same file, trigger the template expansion to regenerate the destination file otherwise remove the destination file. (have a command “yum-ns-remove” which is used instead of “yum remove”)
Algorithm 2:
Another possibility would be to have an post action for package installed which records the list of files generated by templates in separate file. This list would contain template generated destinations. If someone remove some packages with yum, you can afterwards start a ns-template-cleanup, which does similar checks as in point 2 above, i.e. check whether a former template generated file still has a template in the installed packages, then issue a template-expansion otherweise delete the file. In any case remove the file from the list of template generated files.