On Fri, 27.09.13 12:26, Muhammad Shakeel ([email protected]) wrote:
> Hi, > > If there is a foo.service which is required to run during first > system boot then what is the best solution to permanently disable it > afterwards? > > I can think of two solutions but I am not sure which one is > correct/more appropriate. > > 1) ExecStartPost=systemctl disable foo.service (I doubt this will > work) This should work. > 2) ExecStartPost=/bin/rm -f foo.service (this works for me but is > this a clean solution?) This is a bad idea. For most packaged software unit files are usually shipped as part of an RPM, and stored in /usr. During normal boots /usr is likely to be read-only. Hence you cannot remove those unit files. Also, you should not remove unit files without disabling them, hence you'd need #1 before this anyway. > Is there any flag in for systemd unit files which can be set to run > a service on first boot only? My recommendation would be to use something like ConditionFileExists= on some configuration or flag file and let the service enabled unconditionally and always, but skipped in later boots. This is usually the best thing to keep things as state-less as possible. This of course applies only if what you are trying to do is for showing a configuration dialog on first boot or so. This has the benefit that you actually bind execution of your service to the actual existance of first time configuration (which is probably what you really want to express, no?) instead of the first boot (which only indirectly is what you want to express, right?). Hope that makes some sense... More information on ConditionFileExists= and the other conditions you find in "man 5 systemd.unit". Lennart -- Lennart Poettering - Red Hat, Inc. _______________________________________________ systemd-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/systemd-devel
