[systemd-devel] Service should run with a certain User?
Baldur
baldur at email.de
Sat Apr 23 01:03:37 PDT 2011
Hi all,
after doing the simple examples of .service scripts, i was able to run
some of my
home-brewn services with fedora 15 beta.
However now i tried something advanced (?) and i have to admit defeat.
I have
simply no idea how to proceed.
I used to run with upstart a script with an "ugly" solution to do
something like that
su cruisctl -c "servicescript.sh"
This was not pretty, however the script did run under the wanted user.
Now i tried the same thing with systemd. It worked if tried the ugly
solution.
I found that systemd has thee User= option, so i tried to avoid the su
and start the
script with systemed. But the service doesn't start
when i set the "User=" option, it always returns a 203 error.
Can somebody tell me what i am doing wrong?
Here is my test setup
[Unit]
Description=Cruise Control
After=local-fs.target network.target
[Service]
Type=simple
EnvironmentFile=/etc/sysconfig/cruisctl
User=cruisctl
WorkingDirectory=/var/cruisecontrol
#ExecStart=/usr/bin/java $CRUISCTLOPTIONS
ExecStart=/root/test.sh $CRUISCTLOPTIONS
[Install]
WantedBy=multi-user.target
The test.sh looks like this
#!/bin/sh
echo "Start" >/tmp/x
echo Directory: $(pwd) >>/tmp/x
echo Ant Home: $ANT_HOME >>/tmp/x
echo $1 $2 $3 $4 $5 $6 >>/tmp/x
sleep 60
Error is like that
cruisctl.service - Cruise Control
Loaded: loaded (/lib/systemd/system/cruisctl.service)
Active: failed
Process: 4313 ExecStart=/root/test.sh $CRUISCTLOPTIONS
(code=exited, status=203/EXEC)
CGroup: name=systemd:/system/cruisctl.service
More information about the systemd-devel
mailing list