Gentoo Archives: gentoo-user

From: "Canek Peláez Valdés" <caneko@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Re: systemd? [ Was: The End Is Near ... ]
Date: Sun, 18 Mar 2012 08:51:15
Message-Id: CADPrc82UAySqJ=bW-_i17z=ErPvv5Fc61TNkdoCpn2K0QmVuFw@mail.gmail.com
In Reply to: Re: [gentoo-user] Re: systemd? [ Was: The End Is Near ... ] by Graham Murray
1 On Sun, Mar 18, 2012 at 2:02 AM, Graham Murray <graham@×××××××××××.uk> wrote:
2 > Canek Peláez Valdés <caneko@×××××.com> writes:
3 >
4 >> * Really simple service unit files: The service unit files are really
5 >> small, really simple, really easy to understand/modify. Compare the 9
6 >> lines of sshd.service:
7 >>
8 >> $ cat /etc/systemd/system/sshd.service
9 >> [Unit]
10 >> Description=SSH Secure Shell Service
11 >> After=syslog.target
12 >>
13 >> [Service]
14 >> ExecStart=/usr/sbin/sshd -D
15 >>
16 >> [Install]
17 >> WantedBy=multi-user.target
18 >>
19 >> with the 84 of /etc/init.d/sshd (80 without comments).
20 >
21 > But the 80 lines of /etc/init.d/sshd  do a lot more than just and stop
22 > the service.
23
24 Yes, it does.
25
26 > They ensure that there is an sshd configuration file and
27 > give a meaningful message (including where to find the sample) if it is
28 > not present, and check for the presence of the hostkeys (again which are
29 > needed) and create them if they are not present. Your 9 lines of
30 > sshd.service do none of this.
31
32 That is completely true. I also think that those checks does not
33 belong into the init script: I think the configuration file presence
34 should be guarantee by the package manager at install time, and so the
35 creation of the hostkeys.
36
37 Having said that, systemd provides ConditionPathExists, which allows
38 you to set a file as necessary for a service execution. So my 9 lines
39 transform into
40
41 $ cat /etc/systemd/system/sshd.service
42 [Unit]
43 Description=SSH Secure Shell Service
44 After=syslog.target
45 ConditionPathExists=/etc/ssh/sshd_config
46
47 [Service]
48 ExecStart=/usr/sbin/sshd -D
49
50 [Install]
51 WantedBy=multi-user.target
52
53 If the config file doesn't exists, the service will not start, and you
54 can check the reason why with
55
56 systemctl status sshd.service
57
58 And of course you can set another mini sevice unit file to create the
59 hostkeys. But I repeat: I think those tasks belong into the package
60 manager, no the init script.
61
62 Regards.
63 --
64 Canek Peláez Valdés
65 Posgrado en Ciencia e Ingeniería de la Computación
66 Universidad Nacional Autónoma de México

Replies

Subject Author
Re: [gentoo-user] Re: systemd? [ Was: The End Is Near ... ] Pandu Poluan <pandu@××××××.info>
Re: [gentoo-user] Re: systemd? [ Was: The End Is Near ... ] Neil Bothwick <neil@××××××××××.uk>