Systemd service leaves out command in script

258 views Asked by At

I am trying to start a service named pigpiod.service via systemd. It invokes a script with three commands. The second one is left out. Why is this?

/etc/systemd/system/pigpiod.service:

[Unit]
Description=Starts pigpiod
Before=touchscreen.service

[Service]
ExecStart=/home/sysop/pigpiod.sh

[Install]
WantedBy=multi-user.target

/home/sysop/pigpiod.sh:

#!/bin/sh

touch /home/sysop/before_pigpiod
/usr/bin/pigpiod
touch /home/sysop/after_pigpiod
  • When restarting the machine the two files get created in /home/sysop/, but pigpiod is not starting.
  • When starting the service manually via sudo systemctl start pigpiod the same happens.
  • When running sudo /home/sysop/pigpiod.sh manually pigpiod is actually starting!

This is the output of sudo systemctl status pigpiod -l right after boot:

● pigpiod.service - Starts pigpiod
   Loaded: loaded (/etc/systemd/system/pigpiod.service; enabled)
   Active: inactive (dead) since Sat 2017-09-16 20:02:03 UTC; 2min 29s ago
  Process: 440 ExecStart=/home/sysop/pigpiod.sh (code=exited, status=0/SUCCESS)
 Main PID: 440 (code=exited, status=0/SUCCESS)

Sep 16 20:02:02 kivypie systemd[1]: Starting Starts pigpiod...
Sep 16 20:02:02 kivypie systemd[1]: Started Starts pigpiod.

Why is it, that systemd skips the execution of /usr/bin/pigpiod, but manually running the script as root does not?

My system: Raspberry Pi Model 3B, Raspbian GNU/Linux 8 (jessie)

1

There are 1 answers

0
Nuetrino On BEST ANSWER

pigpiod forks without the -g option. So use Type = forking or use pigpiod -g

[Unit]
Description=Starts pigpiod
Before=touchscreen.service

[Service]
ExecStart=/home/sysop/pigpiod.sh
Type=forking

[Install]
WantedBy=multi-user.target