[systemd-devel] systemd-service for each user

Jakob Schürz wertstoffe at nurfuerspam.de
Tue Nov 11 09:52:26 PST 2014


Hi!

I don't know, for which words I have to search to find a solution for my 
Problem.

On my server i created a mailserver.target, on which all relevant 
services for the mailserver depend. So i can [re]start and stop all 
services (exim4, cyrus, saslauthd, amavis...) only with

systemctl start|restart|stop mailserver.target

The thing is, i have users not each with ~/.fetchmailrc
So i've written a unit
/etc/systemd/system/fetchmail at .service

[Unit]
Description=fetchmail for User %i
BindsTo=mailserver.target
After=cyrus-imapd.service exim4.service
ConditionFileNotEmpty=/home/%i/.fetchmailrc

[Service]
Type=simple
User=%i
Environment=FETCHMAILUSER=%i
ExecStart=/usr/bin/fetchmail --nodetach
#PIDFile=/home/%i/.fetchmail.pid

[Install]
WantedBy=mailserver.target

But i don't know, how to start this unit for each user.
systemctl start mailserver should scan each user and start 
fetchmail at user1.service, fetchmail at user2.service...

Is this possible with systemd? Or should i create a shell-script to do 
the job?

greetings
Jakob
-- 
http://xundeenergie.at
http://verkehrsloesungen.wordpress.com/
http://cogitationum.wordpress.com/



More information about the systemd-devel mailing list