On Mon, Sep 22, 2014 at 12:40 PM, Steven Stern subscribed-lists@sterndata.com wrote:
Can I treat a .service file like a bash script and do all those "loop" sorts of things?
No, but you can invoke a bash script from a service file that does things in a loop. But that doesn't buy you much^D anything really over the initial initscript. ;-)
A proper systemdish way to accomplish this would be to use an instance service for dropbox and use the standard systemd tools to enable/disable it for particular users instead of keeping the list in an /etc/sysconfig file.
First, I'd suggest reading this nice introduction to instance services; it's not very long and afterward you'll have a full understanding of what's going on with my example below: http://0pointer.de/blog/projects/instances.html
To create an instance service for dropbox, instead of using "dropbox.service", create a "dropbox@.service" file (the @ is very important), with the following contents: -- [Unit] Description=Dropbox service for user %I
[Service] ExecStart=/home/%i/.dropbox-dist/dropboxd User=%i
[Install] WantedBy=multi-user.target
--
Once you have that, instead of managing the users it is started for with a file in /etc/sysconfig, just use systemctl to enable/disable it for users as appropriate.
To enable the dropbox service for the "sdstern" user: # systemctl enable dropbox@sdstern.service
To disable the dropbox service for the "sdstern" user later on: # systemctl disable dropbox@sdstern.service
And, to see all the users dropbox is enabled for: % ls /etc/systemd/system/multi-user.target.wants/dropbox@*
-T.C.