Bug 53954

Summary: Not possible to enable user-specified instance when unit has alias
Product: systemd Reporter: Dave Reisner <d>
Component: generalAssignee: systemd-bugs
Status: RESOLVED FIXED QA Contact: systemd-bugs
Severity: normal    
Priority: medium CC: freedesktop, jsmith, kristian, zbyszek
Version: unspecified   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Remove alias, add WantedBy

Description Dave Reisner 2012-08-23 02:04:21 UTC
v188 added the ability to enable a unit with an instance name. However, if the unit has an Alias, it is not possible to enable this unit by any other template name than the name defined by the Alias.

--> Example unit:

[Unit]
Description=dhcpcd on %I
Wants=network.target
Before=network.target

[Service]
Type=forking
PIDFile=/run/dhcpcd-%I.pid
ExecStart=/sbin/dhcpcd -A -q -w %I
ExecStop=/sbin/dhcpcd -k %I

[Install]
Alias=multi-user.target.wants/dhcpcd@eth0.service

--> Expected behavior:
# systemctl enable dhcpcd@eth1.service
ln -s '/usr/lib/systemd/system/dhcpcd@.service' '/etc/systemd/system/multi-user.target.wants/dhcpcd@eth1.service'

--> Actual behavior:
# systemctl enable dhcpcd@eth1.service
ln -s '/usr/lib/systemd/system/dhcpcd@.service' '/etc/systemd/system/multi-user.target.wants/dhcpcd@eth0.service'
Comment 1 jsmith 2012-12-14 15:18:10 UTC
The Install section wants teh Alias removing and using WantedBy instead eg:

[Unit]
Description=dhcpcd on %I
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device

[Service]
Type=forking
PIDFile=/run/dhcpcd-%I.pid
ExecStart=/usr/sbin/dhcpcd -q -w %I
ExecStop=/usr/sbin/dhcpcd -x %I

[Install]
WantedBy=multi-user.target
Comment 2 jsmith 2012-12-14 15:29:54 UTC
Created attachment 71508 [details] [review]
Remove alias, add WantedBy

Proposed patch.
Comment 4 Zbigniew Jedrzejewski-Szmek 2013-02-08 12:22:20 UTC
Should be fixed in http://cgit.freedesktop.org/systemd/systemd/commit/?id=7584d23.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.