I'm trying to follow the ArchWiki guide for writing a custom service file to launch DavMail as a system-wide daemon. Previously I had a line in my ~/.xinitrc that read
nohup /usr/bin/davmail /etc/conf.d/davmail.properties
as per the DavMail instructions (where /usr/bin/davmail
is a symlink to /usr/share/java/davmail/davmail.sh
). Now that I've made the computer into a headless server, I'd like the auto-launcher to be independent of an X session.
All the guides I've seen online for a DavMail initscript assume that the distro is using sysvinit, not systemd. My attempt at a custom systemd service file is
[Unit]
Description=DavMail Exchange Gateway
Requires=network.target
After=network.target
[Service]
Type=forking
RemainAfterExit=yes
ExecStart=/usr/bin/davmail /etc/conf.d/davmail.properties
ExecStop=killall davmail
[Install]
WantedBy=multi-user.target
which fails to fork properly. Prepending the ExecStart
command with /usr/bin/nohup
is no help, because systemd complains about an invalid argument (preferring to take control of the daemonization itself, if I'm correctly understanding previous forum answers). Changing the Service Type to oneshot
or simple
also fails.
I think an issue here is that DavMail requires a Java interpreter to run, and systemd service files aren't as flexible as shell scripts in handing off the job to a Java interpreter. But maybe there's a much simpler explanation. Has anyone successfully written a systemd service file for DavMail that they'd be willing to share?
/usr/lib/systemd/scripts/
, and now the DavMail daemon will launch without any problems. – biqu Apr 02 '13 at 20:50