I would like to use the variable $PWD in a systemd service file but it appears that it is always empty even though I have set an explicit WorkingDirectory
.
[Unit]
Description=data-builder
Requires=docker.service
After=docker.service
[Service]
Restart=always
# docker-pull could take a while so we disable the timeout
TimeoutStartSec=0
WorkingDirectory=/var/data-builder/
ExecStart=docker run -e HOST_DATA=${PWD}/data -v -v ${PWD}/data:/opt/data-builder/data someorg/data-builder:latest
[Install]
WantedBy=multi-user.target
Is $PWD defined in a systemd unit? Can I use another variable instead?
The lines you state don't need to be handled by a shell of any sort, so no environment or other variable expansion. Just split into "words" and hand off to an exec(3) family sytem call.