Bug 53954 - Not possible to enable user-specified instance when unit has alias
Summary: Not possible to enable user-specified instance when unit has alias
Status: RESOLVED FIXED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: All Linux (All)
: medium normal
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-23 02:04 UTC by Dave Reisner
Modified: 2013-02-08 12:22 UTC (History)
4 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Remove alias, add WantedBy (91 bytes, patch)
2012-12-14 15:29 UTC, jsmith
Details | Splinter Review

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.