It’s documented in the Developer Manual (see databases, templates, actions and events).
A simplified explanation could be that when a file contains a header message telling “do not modify this file…”, it is a template.
Templates are under /etc/e-smith/templates/
. They can be overridden by custom templates. This is done by recreating the full path to the destination, but under the /etc/e-smith/templates-custom/
tree.
For instance, a basic procedure for a custom template of /etc/php.d/nethserver.ini
could be:
- Locate the template: /etc/e-smith/templates/etc/php.d/nethserver.ini/ (note templates can be composed of multiple fragments).
ls /etc/e-smith/templates/etc/php.d/nethserver.ini/
10base template-begin
- Find the setting you want to modify, either by reading the files or grepping them.
- Once you know which file contains the setting, copy it to a custom template (note in some occasions it might be desirable to create an empty fragment with the additions, instead)
mkdir -p /etc/e-smith/templates-custom/etc/php.d/nethserver.ini/ #recreating the full file path
cp /etc/e-smith/templates/etc/php.d/nethserver.ini/10base /etc/e-smith/templates-custom/etc/php.d/nethserver.ini/ #copying the desired template fragment
- Edit the copied file, setting the desired values and save the changes.
- Manually expand the template, OR execute the related event:
- Manually expanding the template:
expand-template /etc/php.d/nethserver.ini
- executing the related event:
signal-event nethserver-php-update
By expanding the template you’ll see the changes applied to the original file (/etc/php.d/nethserver.ini
)
Sometimes it is necessary to do additional actions after expanding the template. For instance when the file is only read by a service when it starts. In that case, you can manually restart the service to force it to read the file and apply the changes. Or…
…to simplify this, when multiple actions come into play, there are pre-made events. This events will expand the related templates and execute the required actions by issuing a single command (signal-event YOUR_EVENT
). As it’s hard to remember every command I make extensive use of command auto-completion (tab key) to look for hints.
Something I often forget is to look for settings in the databases before creating a template. Remembering this could be a time-saver.
So instead of going ahead for a custom template, you can query (and edit) the NethServer databases by making use of the db
and config
commands. config
command is limited to the configuration
database whereas db
command can access any database. As said before, use tab auto-completion for hints.
If the required setting is in the databases prefer it over a custom template.
Some useful command options are show
, getprop
, setprop
:
# querying the configuration database (config command)
config show php
config getprop php UploadMaxFilesize
# querying the configuration database (db command)
db configuration show
db configuration getprop php UploadMaxFilesize
I would first query the databases to see if the setting I’m looking for is available, and also to know its value before the change.
Then replace the value (config setprop…) making sure to input the right syntax. Failing to do so may later lead to unexpected results.
After that, execute the related signal-event