Do we? Do we need to modify systemd units? Is this what I said earlier?
Yes, we could just undo it, but that alone wouldn’t be a step forward.
You understand this is technically a sideways step, right? Though I don’t mind having a Virtualmin-specific directory for these files while dealing with the EL systems’ mess. In this case, if we go this way, I think the right directory would be /var/virtualmin, and for PHP-FPM, /var/virtualmin/php-fpm consequently.
Yes, this would be another option, but it would be more complicated because we still don’t have SELinux support provided by default. It may confuse users if we include a policy file in the package without SELinux turned on by default.
Oh, but why
/var/virtualminand not arundirectory as the OS packages do it (e.g./run/virtualmin/php-fpmor/var/run/virtualmin/php-fpm)? That seems non-standard, and I don’t like non-standard.
Something needs to recreate this runtime directory after reboots, and systemd already handles that nicely. That’s why I still think we should follow what the system already does instead of adding custom SELinux policies or using custom paths for socket files like in the old days.
In my perspective, using systemd drop-ins is a simpler and better choice for keeping PHP-FPM socket files in /run/php-fpm on EL systems, without the extra complexity. Simply put, we can just include it in our virtual-server RPM package with a 00-virtualmin.conf override for known PHP packages (which we already target and support). The change to our spec RPM file would be as simple as:
# 00-virtualmin.conf (systemd drop-in override)
tmp="$(mktemp)"
cat > "$tmp" <<'EOF'
[Service]
RuntimeDirectory=php-fpm
RuntimeDirectoryMode=0755
RuntimeDirectoryPreserve=yes
EOF
# PHP-FPMs
for unit in php-fpm php70-php-fpm php71-php-fpm php72-php-fpm php73-php-fpm php74-php-fpm \
php80-php-fpm php81-php-fpm php82-php-fpm php83-php-fpm php84-php-fpm
do
install -d -m 0755 "%{buildroot}%{_unitdir}/$unit.service.d"
install -m 0644 "$tmp" "%{buildroot}%{_unitdir}/$unit.service.d/00-virtualmin.conf"
done
rm -f "$tmp"
# Post install
%post
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
# Post uninstall
%postun
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
# Files included
%files
%dir %{_unitdir}/php-fpm.service.d
%{_unitdir}/php-fpm.service.d/00-virtualmin.conf
%dir %{_unitdir}/php*-php-fpm.service.d
%{_unitdir}/php*-php-fpm.service.d/00-virtualmin.conf
…easy to support, and we have full control over the process.
We could even create a separate recommended package named virtualmin-php-fpm-systemd-dropins to handle this separately from virtual-server package.