[opensuse-packaging] systemd-rpm-macros: New %systemd_preset_* macros
If you create a new systemd service, you have to: 1. Also add %service_{add|del}_* macros 2. Create preset for that, and this preset (probably in the systemd-presets-branding-openSUSE package) has to be installed BEFORE the new service itself. If you do it that in this way, the %service_add_* macros set its initial to the state defined in the preset file. But it you do only 1., but not 2., or if the distro decides to change the default state, and the package is already installed, the new value of the preset is never applied. The initialization by %service_add_* is a clean one shot action, done in the time of the first installation. I got several bug reports about a bad state of some services installed by default. Fixing that was very complicated and needed ugly hacks. As the SUSE default for all undefined services is "disable", it can be a problem. And simple force enabling it on installation is not a good fix (it will always override system admin's customization). But it is not easy to recognize, whether the service is off just because it was always off, or it is off because system admin decided to turn it off. I started to think about it, and developed a new activation strategy: - One shot preset is performed during the first installation (exactly as before). - If the default preset for the particular service is changed, one shot preset is performed for that particular service. (Yes, it can override system admin's customization, but it happens just once and never more. So it could be considered as a smallest possible damage.) This makes possible to fix problems like: - Enable smartd by default. - Enable uuidd socket activation, that was mistakenly installed without any preset. How to use these new macros: If your package installs a preset file, you should add following scripts: %pre -p /bin/bash %systemd_preset_pre %posttrans -p /bin/bash %systemd_preset_posttrans It will do everything for you. Additional notes: 1. If you are using a rolling update, it could be too late for preset changes that appeared before introduction of these macros. Please review systemd-presets-branding-openSUSE rpm changes, and check manually. You will probably need to enable at least apparmor.service, restorecond.service and smartd.service by default. 2. Presets are normally stored in systemd-presets-branding-openSUSE package, so all defaults are in a single place, and a branding vendor can easily change them. But sometimes it does not make sense to change the default state. For example: If a socket activated service in an optional package cannot be started out of the box, it can be considered as broken. In such case it makes sense to install preset together with the package (e. g. /usr/lib/systemd/system-preset/50-uuidd.preset), and branding vendor can easily decide not to install it. -- Best Regards / S pozdravem, Stanislav Brabec software developer --------------------------------------------------------------------- SUSE LINUX, s. r. o. e-mail: sbrabec@suse.com Lihovarská 1060/12 tel: +49 911 7405384547 190 00 Praha 9 fax: +420 284 084 001 Czech Republic http://www.suse.cz/ PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76 -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
Stanislav Brabec wrote:
How to use these new macros:
I just added it to the documentation: https://en.opensuse.org/openSUSE:Systemd_packaging_guidelines#Preset_files -- Best Regards / S pozdravem, Stanislav Brabec software developer --------------------------------------------------------------------- SUSE LINUX, s. r. o. e-mail: sbrabec@suse.com Lihovarská 1060/12 tel: +49 911 7405384547 190 00 Praha 9 fax: +420 284 084 001 Czech Republic http://www.suse.cz/ PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76 -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
participants (1)
-
Stanislav Brabec