pengwin-setup icon indicating copy to clipboard operation
pengwin-setup copied to clipboard

Add systemd detection and service management for systemd-enabled Pengwin

Open Copilot opened this issue 3 months ago • 0 comments

Pengwin will boot with systemd enabled by default. Installers must detect systemd at PID 1 and use systemctl to manage services, while maintaining backward compatibility with WSL1 and systemd-disabled scenarios.

Changes

Core Detection

  • Added is_systemd_running() to common.sh - checks if PID 1 is systemd
  • Profile.d scripts use inline detection: [ "$(ps -p 1 -o comm=)" = "systemd" ]

Service Installers

  • LAMP (apache2, mariadb): systemctl enable --now when systemd detected
  • SSH: systemctl enable --now when systemd detected
  • XRDP: systemctl enable --now when systemd detected
  • rc.local: Creates and enables rc-local.service for systemd boot execution

Startup Scripts (/etc/profile.d)

  • Detect systemd inline (can't source common.sh in profile.d context)
  • Check systemctl is-active --quiet before attempting service start
  • Prevents double-starting services already managed by systemd
  • Falls back to traditional service commands when systemd not detected

Example

# Installer pattern
if is_systemd_running; then
  sudo systemctl enable --now apache2
else
  sudo service apache2 start
fi

# Startup script pattern
if [ "$(ps -p 1 -o comm=)" = "systemd" ]; then
  if ! systemctl is-active --quiet apache2; then
    systemctl start apache2
  fi
else
  service apache2 --full-restart
fi

Services Updated

  • apache2, mariadb (LAMP)
  • ssh
  • xrdp (desktop)
  • rc.local
  • joomla (via LAMP)

Note: Cassandra uses custom launcher (not systemd service). Docker connects to Windows Docker Desktop (not Linux service). Both unchanged as intended.

Original prompt

the next version of pengwin will be systemd enabled by default, so your task is first create a function in the commons.sh that checks if pengwin was booted with systemd like SYSTEMD PID = 1.

Then use that function in everyplace it worth. Pengwin-setup make many installers that start services using a script in /etc/profile.d but also they can enable a service. I want you to make the changes that work in both scenarios.

For xample the lamp installer, installs apache, but apache has a service that can start with systemd. So the installer can detect if systemd is running and enable the service after the installation of the package. Also the start script can check if the service is already running and don't try to start it via non systemd methods. This helps in the case the user decides disable systemd and their services will still run via traditional methods. The same if the distro is migrated to wsl1. Be aware that commons.sh is not available to startup script so in this case you can sue the method used by pengwin-base 00-pengwin.sh or something similar

Do this to every installer that you know that the package install a systemd service. In general check for any incompatibility that can raise if systemd is enabled, including the desktop installer.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot avatar Nov 21 '25 15:11 Copilot