Bug#764607: systemd: systemctl does not re-create display-manager.service symlink

Maximiliano Curia maxy at gnuservers.com.ar
Mon Feb 20 10:21:48 GMT 2017


¡Hola!

El 2014-11-24 a las 13:37 +0100, Didier Roche escribió:
> -DEFAULT_SERVICE=/etc/systemd/system/display-manager.service 
> +DEFAULT_SERVICE=display-manager.service 
> +SERVICE=$(basename $(cat "$DEFAULT_DISPLAY_MANAGER_FILE")).service 
> # set default-display-manager systemd service link according to our config 
> -if [ "$1" = configure ] && [ -d /etc/systemd/system/ ]; then 
> -  if [ -e "$DEFAULT_DISPLAY_MANAGER_FILE" ]; then 
> -    SERVICE=/lib/systemd/system/$(basename $(cat "$DEFAULT_DISPLAY_MANAGER_FILE")).service 
> -    if [ -h "$DEFAULT_SERVICE" ] && [ $(readlink "$DEFAULT_SERVICE") = /dev/null ]; then 
> -      echo "Display manager service is masked" >&2 
> -    elif [ -e "$SERVICE" ]; then 
> -      ln -sf "$SERVICE" "$DEFAULT_SERVICE" 
> -    else 
> -      echo "WARNING: $SERVICE is the selected default display manager but does not exist" >&2 
> -      rm -f "$DEFAULT_SERVICE" 
> -    fi 
> +if [ "$1" = configure ] && [ -x /bin/systemctl ]; then 
> +  if [ $(systemctl is-enabled "$DEFAULT_SERVICE") = masked ]; then 
> +    echo "Display manager service is masked" >&2 
>   else 
> -    rm -f "$DEFAULT_SERVICE" 
> +    [ -d /run/systemd/system ] && systemctl daemon-reload 
> +    if [ ! `systemctl enable --force $SERVICE 2>/dev/null` ]; then

This should be written as:
 if ! systemctl enable --force $SERVICE 2>/dev/null;

As written it should always fail.

Please note that this snippet only works on systems that have a running 
systemd, thus it may fail when installing it in using debbootstrap, the 
debian installer, using a chroot, etc.

If possible, please tells us what have you tested. I'm also unsure of what 
would systemd do if you are replacing a running display-manager.service, we 
don't systemd to stop the running display-manager (as that's probably being 
used).

> +      echo "WARNING: $SERVICE is the selected default display manager but does not have a systemd service" >&2

I see that the set of strings used by gdm sddm and lightdm are different. We 
should also sync those.

Happy hacking,
-- 
"It is practically impossible to teach good programming to students that have
had a prior exposure to BASIC: as potential programmers they are mentally
mutilated beyond hope of regeneration."
-- Edsger W. Dijkstra
 Saludos /\/\ /\ >< `/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-systemd-maintainers/attachments/20170220/4f5961e8/attachment.sig>


More information about the Pkg-systemd-maintainers mailing list