[systemd-devel] WorkingDirectory for user units

Ran Benita ran234 at gmail.com
Sat Dec 3 06:52:49 PST 2011


On Sat, Dec 03, 2011 at 02:32:19PM +0100, Thomas Meyer wrote:
> Hi,
> 
> I put a "user" unit in "/usr/lib/systemd/user" called
> "smServer.service":
> 
> [Unit]
> Description=ShortMessage Server
> After=network.target
> 
> [Service]
> Type=simple
> StandardOutput=syslog
> Environment=CLASSPATH=/usr/share/java/smServer.jar
> WorkingDirectory=/home/thomas
> ExecStart=/usr/bin/java smServer.Controller
> 
> [Install]
> WantedBy=multi-user.target
> 
> 1.) Is there an option to set the WorkingDirectory automatically to the
> users home? The environment variable "HOME" seems to get set for the
> process. Or is there an option to set the WorkingDirectory based on the
> user? default working directory seems to be "/".

I don't think there's a way to do it. I looked into either
 - making the home directory the default working directory (for user's
   systemd)
 - adding a %~ format specifier
 - or maybe both?
A patch shouldn't be too hard, which do you think is best?

> 2.) Also i'm not sure which WantedBy= in the [Install] section to use?
> Do I need the section at all? what dependencies/values are sensible
> here?

I just used default.target, which worked as expected.

> greets
> thomas


More information about the systemd-devel mailing list