Hallo,
irgendwie hat es mich schon immer gestört, dass zum RPi_Cam_Web_Interface (https://elinux.org/RPi-Cam-Web-Interface) kein richtiges (init.d/systemd/etc.) Start/Stop-Skript beiliegt.
Ich verwende nun folgende Unit - anstelle rc.local - die bisher sauber funktioniert und die vorhanden start/stop-Shellskripte nutzt:
[Unit]
Description=RPi_Cam_Web_Interface
BindsTo=lighttpd.service
After=rc-local.service lighttpd.service
[Service]
Type=simple
ExecStartPre=/usr/local/bin/check4cam.sh
ExecStart=/home/pi/tools/RPi_Cam_Web_Interface/start.sh
RemainAfterExit=true
ExecStop=/home/pi/tools/RPi_Cam_Web_Interface/stop.sh
WorkingDirectory=/home/pi/tools/RPi_Cam_Web_Interface/
SuccessExitStatus=1
User=pi
Group=pi
[Install]
WantedBy=multi-user.target
Annahme: man holt sich die Quellen per GIT in den angegebenen Pfad.
check4cam prüft, ob überhaupt eine Kamera angeschlossen ist:
#!/bin/sh
if ( /usr/bin/vcgencmd get_camera | grep -q 'detected=0' ); then
echo "no camera connected!"
exit 2
else
echo "camera connected!"
exit 0
fi
Komischerweise liefert das stop.sh einen exit 1 Wert - daher musste ich den erlauben...start/stop.sh möchte ich aber nicht ändern (da per GIT aktualisierbar).
Gruss
Marcus