systemd questions

Michal Hlavinka mhlavink at redhat.com
Mon May 16 12:32:20 UTC 2011


> > 2) does systemd have support for conditions in service files? It seem
> > it's not supported right now. Is there any plan for this?
> 
> I am not entirely sure what you understand by "condition",

for example condition based on string/variable in file, so:
a) EnvironmentFile=/etc/sysconfig/something; 
ExecStart=[ $MODE = master ] && /usr/sbin/xyz_master || /usr/sbin/xyz_slave

or

b) ExecStart=grep -q something /etc/sysconfig/something && /usr/sbin/xyz_master 
|| /usr/sbin/xyz_slave

or based on exit status of some command
c) xyz_required && /usr/sbin/xyz 

but I guess I need to use shell script for this

so following question: is there going to be any standard place for those 
scripts? I'm using /usr/libexec/<package>/script_file

> > 5) in old initscripts, there was /etc/init.d/halt with section for ups
> > shutdown. With that script gone, was that functionality ported to
> > systemd
> > somehow?
> 
> Well, any such code is just inherently broken. It *cannot* work.

but it does work for more than a decade

> A
> number of kernel subsystems hook into the shutdown code of the
> kernel. For example storage code syncs meta data to disk after the
> reboot() syscall is invoked. If you however turn off power before
> reaching reboot(), then this step is omitted which might trigger data
> loss.

when ups recieves command for shutdown, it does not shutdown power 
immediately, but after 30 seconds. Given that this command should be executed 
after umount, synced disks,... when everything is ready for power off...
30 seconds proved to be enough time for this.

> UPS code like that needs to sit in the kernel itself to properly
> work. Adding userspace kludges which invokes this from userspace is a
> recipe for desaster. 

If *you* wan't to write kernel drivers for tons of UPS models using 
serial/usb/network/... connections with tons of protocols (with incomplete 
documentation)... it's your freedom to do so ;)

> (That all said you may drop binaries into /lib/systemd/system-shutdown
> which are executed right before invoking reboot(). But if you package
> anything that drops binaries into that dir for UPS uses, then I will
> personally track you down and tell you mom how bad you are!)

That'd hardly scare my mom :D




More information about the devel mailing list