Mailinglist Archive: opensuse-factory (808 mails)
| < Previous | Next > |
[opensuse-factory] Re: Wanted: How to use systemd unit conf files for sendmail
- From: Frederic Crozat <fcrozat@xxxxxxxx>
- Date: Wed, 10 Aug 2011 11:45:01 +0200
- Message-id: <1312969503.8920.13.camel@par-r81vxc7.par.novell.com>
Le vendredi 05 août 2011 à 12:02 +0200, Dr. Werner Fink a écrit :
Sorry for the slow answer, I'm at Desktop Summit, which slows my mail
processing a little bit :)
Some fixes for After:
After=nss-lookup.target network.target remote-fs.target syslog.target
time-sync.target
It should work (but I didn't test it). I think second option might be better.
But I guess it is a matter of taste.
Indeed, the socket listening code is systemd will fail and it won't try to
activate sendmail.service
I would probably use mail-transfer-agent.target for Service= in
smtp-local.socket, to not tie
smtp-local.socket to sendmail.service.
You can't do that directly in a unit file.
One option is to create a systemd generator (which is what is used for crypttab
and getty service),
to be installed in /lib/systemd/system-generator which would be started by
systemd and would create temporary .service files in
/run/systemd/generators (which is a tmpfs) which would be used by systemd as
"normal" service files.
I've tested quickly and just dropping generator script in
/lib/systemd/system-generators, make sure it is executable and takes one
parameter which is the path where generated
unit files should be written.
Then reboot and voilà :)
But you might want to systemd-devel mailing list to be sure I'm not on crack.
--
Frederic Crozat <fcrozat@xxxxxxxx>
SUSE
--
To unsubscribe, e-mail: opensuse-factory+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-factory+help@xxxxxxxxxxxx
Hi,
Sorry for the slow answer, I'm at Desktop Summit, which slows my mail
processing a little bit :)
for bug bnc#710279 I'm also have look how to switch over to systemd
unit configuration files for starting sendmail MTA and also sendmail
client mail queue handler.
Currently I have for the MTA process an smtp.socket file with
[Unit]
Description=SMTP Socket
DefaultDependencies=no
[Socket]
ListenStream=25
FreeBind=true
Accept=false
Service=sendmail.service
and the service unit sendmail.service:
[Unit]
Description=Sendmail Mail Transport Agent
After=nss-lookup.target network.target remote-fs.target syslog.target
rtc-set.target
Wants=amavis.service cyrus.service ldap.service nscd.service ypbind.service
Conflicts=postfix.service exim.service
Some fixes for After:
After=nss-lookup.target network.target remote-fs.target syslog.target
time-sync.target
[Service]
Type=forking
Environment=SENDMAIL_ARGS=-L sendmail -Am -bd -q30m -om
EnvironmentFile=-/etc/sysconfig/mail
EnvironmentFile=-/etc/sysconfig/sendmail
PIDFile=/var/run/sendmail.pid
ExecStartPre=-/usr/bin/make -C /etc/mail
ExecStart=/usr/sbin/sendmail $SENDMAIL_ARGS
[Install]
WantedBy=mail-transfer-agent.target
Also=sendmail-client.service
... now the question is: will this work, that is start sendmail MTA on
demand if `systemctl enable smtp.socket' was executed? Or is it better
to switch in sendmail.service to multi-user.target for WantedBy?
It should work (but I didn't test it). I think second option might be better.
But I guess it is a matter of taste.
For the sendmail client mail queue handler I've path unit
sendmail-client.path with:
[Unit]
Description=Sendmail Client Mail Queue Watcher
[Path]
DirectoryNotEmpty=/var/spool/clientmqueue/
[Install]
WantedBy=multi-user.target
to be able to start the service unit sendmail-client.service:
[Unit]
Description=Sendmail Mail Transport Client
After=smtp-local.socket
[Service]
Type=forking
Environment=SENDMAIL_CLIENT_ARGS=-L sendmail-client -Ac -qp30m
EnvironmentFile=-/etc/sysconfig/mail
EnvironmentFile=-/etc/sysconfig/sendmail
PIDFile=/var/spool/clientmqueue/sm-client.pid
ExecStartPre=/bin/touch /var/spool/clientmqueue/sm-client.pid
ExecStartPre=/bin/chown mail:mail /var/spool/clientmqueue/sm-client.pid
ExecStartPre=/bin/chmod 0600 /var/spool/clientmqueue/sm-client.pid
ExecStartPre=-/usr/bin/make -C /etc/mail
ExecStart=/usr/sbin/sendmail $SENDMAIL_CLIENT_ARGS
[Install]
WantedBy=mail-transfer-agent.target
Does this work? Together with a unit smtp-local.socket it
should be possible to start the sendmail MTA if not already up:
[Unit]
Description=Local SMTP Socket
DefaultDependencies=no
[Socket]
ListenStream=25
BindToDevice=lo
Accept=false
Service=sendmail.service
IMHO this will only used if no process is listen on localhost port 25
or is this wrong? The manual pages of systemd do not show what happens
is a port is already busy due an other way of enabling the MTA.
Indeed, the socket listening code is systemd will fail and it won't try to
activate sendmail.service
I would probably use mail-transfer-agent.target for Service= in
smtp-local.socket, to not tie
smtp-local.socket to sendmail.service.
Currently I've not found a way to port
PortOpts=""
for cfg in /etc/sendmail.cf /etc/mail/sendmail.cf
do
test -s $cfg || continue
PortOpts=$(sed -rn '/^O[[:blank:]]+DaemonPortOptions=.*Name=MTA.*$/I {
s/[[:blank:]]+//g
s/^O[^=]+=(.*)/\1/p
}' $cfg)
break
done
unset cfg
if test "$SMTPD_LISTEN_REMOTE" != "yes" ; then
PortOpts="${PortOpts:+${PortOpts},}Addr=127.0.0.1"
SENDMAIL_ARGS="-O DaemonPortOptions=${PortOpts} $SENDMAIL_ARGS"
fi
from /etc/init.d/sendmail to the service unit sendmail.service.
With this there is a control if the MTA is listen on port 25
of any remote network interface or if not. How can this be done
within a systemd service unit (without using a wrapper script)?
You can't do that directly in a unit file.
One option is to create a systemd generator (which is what is used for crypttab
and getty service),
to be installed in /lib/systemd/system-generator which would be started by
systemd and would create temporary .service files in
/run/systemd/generators (which is a tmpfs) which would be used by systemd as
"normal" service files.
I've tested quickly and just dropping generator script in
/lib/systemd/system-generators, make sure it is executable and takes one
parameter which is the path where generated
unit files should be written.
Then reboot and voilà :)
But you might want to systemd-devel mailing list to be sure I'm not on crack.
--
Frederic Crozat <fcrozat@xxxxxxxx>
SUSE
--
To unsubscribe, e-mail: opensuse-factory+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-factory+help@xxxxxxxxxxxx
| < Previous | Next > |