[systemd-devel] failure to disable a servie from restarting

Colin Guthrie gmane at colin.guthr.ie
Tue Jan 22 04:02:58 PST 2013


'Twas brillig, and Paul Wouters at 21/01/13 21:29 did gyre and gimble:
> On 01/16/2013 11:09 AM, Lennart Poettering wrote:
>> On Mon, 14.01.13 02:22, Zbigniew Jędrzejewski-Szmek
>> (zbyszek at in.waw.pl) wrote:
>>
>>>> But I don't want to _stop_ the service. I want the running service
>>>> to not restart when/if it dies.
>>> There's a dbus property
>>>    readonly s Restart
>>> exposed for units. It would serve your usecase perfectly to make it
>>> writable. Alas.
>>
>> This wouldn't really work, as the next "systemctl daemon-reload" would
>> drop the field again...
>>
>>> A solution for now could be to
>>> 'sed s/Restart=yes/Restart=no/ ipsec.service >
>>> /run/systemd/systemd/ipsec.service'
>>> and 'systemctl daemon-reload'. The changes will go away at next
>>> reboot. (This will only work if you install files into
>>> /usr/lib/systemd/system and not /etc/systemd/system, since the latter
>>> once take precedence.)
>>
>> Yeah, this is kinda the same solution I proposed here:
>>
>> https://bugzilla.redhat.com/show_bug.cgi?id=807897
> 
> But /run gets cleared on reboots. So I would still lose the setting.
> 
> I opted for always changing the /lib/systemd/system/ipsec.service file
> and running daemon-reload.

Didn't read the whole thread, but rather than modifying the file in /lib
(or /usr/lib), you should simply copy it to /etc/systemd/systemd instead
and do a daemon-reload and then an enable --force to ensure the right
symlink is created for safety (tho' it may not really matter).

The list of directories checked for unit files is:

/etc/systemd/system
/run/systemd/system
[/usr]/lib/systemd/system

So you can easily override the system package provided files in /etc/.
This is one of the primary design goals - allow packages to provide
things, but allow them to be overridden by the administrator easily.

All the best.

Col





-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/


More information about the systemd-devel mailing list