I would try to explain e-smith layer by my favourite way : learning by doing
Integrate a rpm of wordpress from epel https://github.com/stephdl/nethserver-wordpress/tree/ns6
this example is quite easy, the epel maintainers write a /etc/wordpress/wp-config.php but we need to modify it.
-we could play with grep and sed for modifying variables, but it is not easy since the first change will break the regex
-we could use a template…this is what i did https://github.com/stephdl/nethserver-wordpress/tree/ns6/root/etc/e-smith/templates/etc/wordpress/wp-config.php
The database is just here to record variables like db password, db user…
in a nutshell
The template /etc/e-smith/templates/etc/wordpress/wp-config.php will overwrite /etc/wordpress/wp-config.php
the template /etc/e-smith/templates.metadata/etc/wordpress/wp-config.php will give the good owner rights on /etc/wordpress/wp-config.php because you may want that this file is used by apache for example (default is root)
Templates are tied to an event (nethserver-wordpress-update here) at the createlink level https://github.com/stephdl/nethserver-wordpress/blob/ns6/createlinks
templates2events("/etc/httpd/conf.d/wordpress.conf", nethserver-wordpress-update);
templates2events("/etc/wordpress/wp-config.php", nethserver-wordpress-update);
the database wordpress will record all variables that we need to use in our templates
see https://github.com/stephdl/nethserver-wordpress/tree/ns6/root/etc/e-smith/db/configuration/defaults/wordpress
you can see the db values in a terminal by :
config show wordpress
Actions are specifics you can use it for many things…it is like a script https://github.com/stephdl/nethserver-wordpress/tree/ns6/root/etc/e-smith/events/actions, they are tied to an event (nethserver-wordpress-update for example) and they are launched when you want, depending the number they get in the createlink https://github.com/stephdl/nethserver-wordpress/blob/ns6/createlinks
event_actions(nethserver-wordpress-update,
'initialize-default-databases' => '00',
'nethserver-wordpress-conf' => '20',
'nethserver-wordpress_permissions-conf' => '30'
X<10 before the template expand
10<X<90 after the template expand
X>90 after the adjust service (service trigger)
when you do a contrib, services need to be restarted or reloaded and it is done at the createlink level and also tied to an event https://github.com/stephdl/nethserver-wordpress/blob/ns6/createlinks
event_services(nethserver-wordpress-update, 'httpd' => 'reload');
at the end you can find all templates, actions, services of your event if you do
ll -R /etc/e-smith/events/nethserver-wordpress-update
The Event is the action that you call either at the end of your rpm installation (nethserver-…-update), or when you press save in nethgui, it will overwrite templates, launch actions, and restart services. you can call manually it by
’signal-event nethserver-wordpress-update’
If you want to modify a value like maybe the name of the folder after the url (https://yourIP/wordpress)
you will do
config setprop wordpress URL foldername
signal-event nethserver-wordpress-update
you don’t need to edit a .conf file, it is automatic, you have altered the database and simply launched the event which will overwrite files with correct values, launch actions and restart services
The nethgui is just an ‘api’ which writes variables in the database and launch the event at the end…no more…Of course the UI is the most difficult part for me, even if nethgui is able to give things easier than with formagick for the SME Server panel.
I do believe that zentyal uses a similar approach, for clearos I don’t know. It is something logical, that it can probably be enhanced but it is easy to take in hand.