The issue is that Samba is a special case, and does not come with a native systemd service, only with legacy sys v init scripts, also samba is broken into two separate services - smbd and nmbd.
Our service manager in My OSMC expects a single, proper systemd service and canât deal with interrogating and controlling a sysv service especially broken into two services so we divert the original init scripts and add a meta-service:
The original init scripts are âdisabledâ during installation of samba so they donât start on boot, and it is up to the meta service to start samba on boot if it is enabled. The status of this meta service is queried to see whether samba is enabled.
The problem comes about when the debian samba package is upgraded - the sys v init script will be stopped by the package upgrade scripts but because the smbd and nmbd init services are marked as disabled they will not be automatically restarted, thus an upgrade of samba would stop samba until a reboot.
This is the reason for 99-samba-update-restart - itâs not ideal but it does solve the problem.
No it doesnât - according to documentation âReload one or more units if they support it. If not, restart them instead. This does nothing if the units are not running.â - at the point this command runs, the smbd service it not running - this is why we have to run the command in the first place to restart the service.
The script that I run in the Dpkg post step checks checks that (a) the samba.service is enabled (b) smbd.service (actually the sys v init script for smbd) is not running, if both are true, restart the samba meta-service, which in turn restarts smbd and nmbd services.
We check if the service is enabled because we should not restart samba on upgrade if the user has disabled it in the service manager. We check that smbd is not already running so that we do not unnecessarily restart it when other packages are upgraded.
I assumed the same as well from documentation I had read but when tested I only saw it run once.
As I say I think dpkg configure is run for all packages (*) at once with multiple package names passed at once on the dpkg command line, thus there is only one dpkg configure executed to configure multiple packages in a row.
The normal upgrade process of multiple packages is:
- All package pre-scripts are run
- All packages are unpacked
- All package post-scripts are run
(*) The exception to this is where there are packages with Pre-Depends, where step 1 for package A that pre-depends on package B is delayed until after step 3 of package B.
PS thanks for the hints on triggers - I have looked into them a little bit but as you say they are not well documented so I havenât had a chance to study them in detail and see what real world use cases they are useful in.