Changes

From SME Server
Jump to navigationJump to search
3,259 bytes added ,  19:36, 7 December 2020
Line 539: Line 539:  
===== Previous pure Syvinit service, with a provided systemd unit =====
 
===== Previous pure Syvinit service, with a provided systemd unit =====
 
If we are lucky we can simply use the ones provided as a replacement, we add a service.d/50koozali.conf for the service and alter it in the way we need.
 
If we are lucky we can simply use the ones provided as a replacement, we add a service.d/50koozali.conf for the service and alter it in the way we need.
 +
 +
'''The template will need to be expanded for ''package''-update, bootstrap-console-save, console-save, post-install, post-upgrade at least'''
 +
 +
you will need to plan a createlinks addition :<syntaxhighlight lang="perl">
 +
#smeserver-dovecot-update
 +
# services to adjust
 +
safe_symlink("restart", "root/etc/e-smith/events/smeserver-dovecot-update/services2adjust/dovecot");
 +
safe_symlink("restart", "root/etc/e-smith/events/smeserver-dovecot-update/services2adjust/rsyslog");
 +
 +
# specific actions we want for this package
 +
event_link("adjust-dovecot", "smeserver-dovecot-update", "02");
 +
 +
# systemd-specific action mandatory for this package-update event
 +
event_link("systemd-reload", $event, "89");
 +
event_link("systemd-default", $event, "88");
 +
 +
# specific template we will need for this package
 +
templates2events("/etc/rsyslog.conf",$event);
 +
 +
# systemd-specific template mandatory for this package-update event
 +
templates2events("/usr/lib/systemd/system/dovecot.service.d/50koozali.conf", ($event, qw(bootstrap-console-save console-save post-install post-upgrade) ));
 +
 +
</syntaxhighlight>
 +
 +
Usually we then create 3 fragments
 +
* /etc/e-smith/templates/usr/lib/systemd/system/nut-monitor.service.d/50koozali.conf/20unit
 +
<syntaxhighlight lang="bash">
 +
[Unit]
 +
#this could be omitted, very specific to the nut service
 +
PartOf=nut.service
 +
After=nut.service
 +
 +
</syntaxhighlight>
 +
* /etc/e-smith/templates/usr/lib/systemd/system/nut-monitor.service.d/50koozali.conf/40service
 +
<syntaxhighlight lang="bash">
 +
[Service]
 +
# reset all ExecStartPre
 +
ExecStartPre=
 +
# add our own
 +
ExecStartPre=/sbin/e-smith/service-status nut
 +
# ignore this one if it fails
 +
ExecStartPre=-/bin/mytest
 +
 +
# reset previous Start
 +
ExecStart=
 +
# do our own
 +
ExecStart=/bin/sv u helo
 +
</syntaxhighlight>
 +
* /etc/e-smith/templates/usr/lib/systemd/system/nut-monitor.service.d/50koozali.conf/80install
 +
<syntaxhighlight lang="bash">
 +
[Install]
 +
#probably the most wanted part !
 +
WantedBy=sme-server.target
 +
 +
</syntaxhighlight>
 +
 +
You will then need to create the destination path in the spec file in %build
 +
 +
mkdir -p root/usr/lib/systemd/system/nut-monitor.service.d/50koozali.conf
 +
 +
Finally, think to remove any remains of previous sysvinit as it might prevent the service to enable in /etc/systemd/system-preset/49-koozali.preset. to enable the service all the conditions should be met:
 +
* a key $key in configuration db should exist as type=service and status=enabled
 +
* a file $key.service should exist in /usr/lib/systemd/system/ or in /etc/systemd/system/
 +
* there should be no file /etc/rc.d/init.d/$key nor /etc/rc.d/init.d/supervise/$key
 +
{{Warning box|1=we use preset-all to enable our services, however there is a bug in systemd up to v236 (up to Rhel8). With this bug drop in configuraiton file sin *.service.d/  are ignored when systemctl search for [Install] content to do preset-all.
 +
As a result our WantedBy=sme-server.target are igored
 +
we write a replacement with systemd-default action script, but this one has also limits:
 +
# works only with sme-server.target
 +
# does not check really where is the WantedBy, if it'S elsewhere than the expected [Install] section it will use it as well
 +
# does not work with templated unit (@.service)}}
    
===== Previous pure Syvinit service, without a provided systemd unit =====
 
===== Previous pure Syvinit service, without a provided systemd unit =====
Line 585: Line 655:     
As a last resort we could hide the whole file using the service.d/50koozali.conf  and simply call runit, see the next example.
 
As a last resort we could hide the whole file using the service.d/50koozali.conf  and simply call runit, see the next example.
 +
 +
see [[#Previous pure Syvinit service, with a provided systemd unit]] for reference...
    
===== Previous Runit service, without a provided systemd unit =====
 
===== Previous Runit service, without a provided systemd unit =====
Super Admin, Wiki & Docs Team, Bureaucrats, Interface administrators, Administrators
3,250

edits

Navigation menu