Bug 714830 - No equivalent of --initscript parameter to /usr/sbin/alternatives when using systemd instead of an /etc/init.d script
No equivalent of --initscript parameter to /usr/sbin/alternatives when using ...
Product: Fedora
Classification: Fedora
Component: chkconfig (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Bill Nottingham
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2011-06-20 18:44 EDT by Sam Varshavchik
Modified: 2014-03-16 23:28 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 723679 (view as bug list)
Last Closed: 2011-07-20 15:33:23 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
test patch (3.64 KB, patch)
2011-07-15 17:23 EDT, Bill Nottingham
no flags Details | Diff
better patch (3.27 KB, patch)
2011-07-19 17:18 EDT, Bill Nottingham
no flags Details | Diff

  None (edit)
Description Sam Varshavchik 2011-06-20 18:44:33 EDT
Description of problem:

The --initscript option to /usr/sbin/alternatives does not work with systemd

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. Take two or more existing packages. Each package install its own /etc/init.d/{servicename}. Each package installs a corresponding alternatives symlink using the --initscript option to alternatives.
2. Using the alternatives command to switch between the alternative services also ends up with the alternatives taking care of running chkconfig on and chkconfig off.
3. Now, update all packages from /etc/init.d/{service} to /lib/systemd/system/{servicename}.service
4. Note that there is no equivalent --initscript option for systemd, for the alternatives command, so leave the same alternatives --install in place.
5. Proceed to install the rpms. Either upgrades of the pre-systemd versions, or new installs.
Actual results:


# /usr/sbin/alternatives --install /usr/sbin/sendmail mta \
     /usr/lib/courier/bin/sendmail 91 \
     --slave /usr/bin/mailq mta-mailq /usr/lib/courier/bin/mailq \
     --slave /usr/bin/rmail mta-rmail /usr/lib/courier/bin/rmail \
     --slave /usr/bin/newaliases mta-newaliases \
          /usr/lib/courier/sbin/makealiases \
     --initscript courier
error reading information on service courier: No such file or directory

Expected results:

Activating the alternatives link to a package should result in a systemctl enable {service}.name, and, perhaps, systemctl disable {service}.name, for the corresponding service, for a package that uses systemd.

Deactivating the alternatives link to a package, should result in a systemctl stop {service}.name and systemctl disable {service}.name for the corresponding service.

Additional info:

Dropping the --initscript parameter, of course, works, but then controlling the alternatives-managed link has no effect on the supporting service daemon, which must then be managed manually. This is a loss of functionality from initscripts.
Comment 1 Bill Nottingham 2011-06-28 17:00:27 EDT
I started looking at this today.

The big issue is that the --initscript argument today works in terms of 'chkconfig --add' and 'chkconfig --del', where it removes/adds all the start/stop links entirely. There's not a direct analog here, so it's not a trivial fix - might require some changes to its semantics.
Comment 3 Sam Varshavchik 2011-07-15 17:16:18 EDT
The test patch appears to be a CNN article...
Comment 4 Bill Nottingham 2011-07-15 17:23:04 EDT
That's a neat trick. Will fix.
Comment 5 Bill Nottingham 2011-07-15 17:23:40 EDT
Created attachment 513448 [details]
test patch
Comment 7 Sam Varshavchik 2011-07-15 19:49:07 EDT
Does not work. A watchpoint shows isSystemd that gets initialized by the patch subsequently gets clobbered by line 595:

	/* Insert new set into the set of alternatives */
	for (i = 0 ; i < set.numAlts ; i++) {
		if (!strcmp(set.alts[i].master.target, newAlt.master.target)) {
====>			set.alts[i] = newAlt;
Comment 8 Bill Nottingham 2011-07-19 16:59:01 EDT
What is it doing for you if you pass --verbose? It seems to be working for me.
Comment 9 Bill Nottingham 2011-07-19 16:59:27 EDT
Oh, never mind. --set works, the initial install doesn't.
Comment 10 Bill Nottingham 2011-07-19 17:18:20 EDT
Created attachment 513882 [details]
better patch

Here's a better patch that works for me, and will be in the next rawhide build; it just leaves the determination of whether to call systemctl to when it actually performs the action.
Comment 11 Sam Varshavchik 2011-07-19 22:05:09 EDT
Gave the new patch a spin.

Seems to work, except for one thing. --remove does not run "systemctl disable". The alternatives symlink gets removed, but the systemd service does not get disabled.

For me, --install runs "systemctl enable", but --remove does not run "systemctl disable". This seems to be inconsistent.
Comment 12 Bill Nottingham 2011-07-20 14:22:45 EDT
That's not a regression, though.

If I recall, the idea is that that is done in the package's scripts on uninstallation.
Comment 13 Sam Varshavchik 2011-07-20 15:26:30 EDT
But, presumably, so would be on installation too.

Since chkconfig does not support systemd at all, I don't see what's here to regress. But this is an opportunity to make things more consistent.

It seems more consistent to me that if chkconfig enables the service on install, it should also disable it on uninstall. Or, do not enable or disable on install and uninstall at all; make it the package's responsibility, to enable and disable its service, in addition to installing and uninstalling an alternatives links; and chkconfig only invokes systemctl when switching to a new alternative.
Comment 14 Bill Nottingham 2011-07-20 15:33:23 EDT
I've cloned this bug for that issue (bug 723679); setting this one as CLOSED->RAWHIDE.

Note You need to log in before you can comment on or make changes to this bug.