On Sun, Mar 18, 2012 at 2:02 AM, Graham Murray <gra...@gmurray.org.uk> wrote: > Canek Peláez Valdés <can...@gmail.com> writes: > >> * Really simple service unit files: The service unit files are really >> small, really simple, really easy to understand/modify. Compare the 9 >> lines of sshd.service: >> >> $ cat /etc/systemd/system/sshd.service >> [Unit] >> Description=SSH Secure Shell Service >> After=syslog.target >> >> [Service] >> ExecStart=/usr/sbin/sshd -D >> >> [Install] >> WantedBy=multi-user.target >> >> with the 84 of /etc/init.d/sshd (80 without comments). > > But the 80 lines of /etc/init.d/sshd do a lot more than just and stop > the service.
Yes, it does. > They ensure that there is an sshd configuration file and > give a meaningful message (including where to find the sample) if it is > not present, and check for the presence of the hostkeys (again which are > needed) and create them if they are not present. Your 9 lines of > sshd.service do none of this. That is completely true. I also think that those checks does not belong into the init script: I think the configuration file presence should be guarantee by the package manager at install time, and so the creation of the hostkeys. Having said that, systemd provides ConditionPathExists, which allows you to set a file as necessary for a service execution. So my 9 lines transform into $ cat /etc/systemd/system/sshd.service [Unit] Description=SSH Secure Shell Service After=syslog.target ConditionPathExists=/etc/ssh/sshd_config [Service] ExecStart=/usr/sbin/sshd -D [Install] WantedBy=multi-user.target If the config file doesn't exists, the service will not start, and you can check the reason why with systemctl status sshd.service And of course you can set another mini sevice unit file to create the hostkeys. But I repeat: I think those tasks belong into the package manager, no the init script. Regards. -- Canek Peláez Valdés Posgrado en Ciencia e Ingeniería de la Computación Universidad Nacional Autónoma de México