I wrote a bash-script that will check if a webcam is still "up" and if it isn't it will reboot the SBC. (script checks for a snapshot.jpg from the webcam) I noticed however that:
"reboot -f" doesn't work ("reboot" does)
Sometimes "reboot" doesn't work properly (when i ssh into the SBC afterwards, most dietpi-services are not active anymore) (failed startup?)
What is the proper way to reboot? How do i script (bash) "dietpi-services stop"?
ps: (some more info) i have 2 webcam (usb) connected to the SBC. Lots of times 1 of these webcams will "shutdown" or remain "open" so a proces that wants to take a snapshot from that cam will not work.I fear that it is a linux-"driver" problem.
services that i have running:
-smb
-nfs
-syncthing
-Homeassistant
-Lighttpd
I used to take snapshots with "motion". Right now i use fswebcam for that.
The script:
Code: Select all
#!/bin/bash
rm /home/homeassistant/.homeassistant/www/woonkamer.jpg
rm /home/homeassistant/.homeassistant/www/keuken.jpg
rm /home/homeassistant/.homeassistant/www/tuin.jpg
rm /home/homeassistant/.homeassistant/www/voordeur.jpg
wget -O /home/homeassistant/.homeassistant/www/tuin.jpg --http-user=xxx --http-password=yyy' http://192.168.0.32/cgi-bin/video.cgi?msubmenu=jpg
wget -O /home/homeassistant/.homeassistant/www/voordeur.jpg --http-user=xxx --http-password='yyy' http://192.168.0.72/axis-cgi/jpg/image.cgi
fswebcam -d /dev/video0 -r 640x480 -F 10 /home/homeassistant/.homeassistant/www/keuken.jpg
fswebcam -d /dev/video1 -r 600x800 --rotate 90 -F 10 /home/homeassistant/.homeassistant/www/woonkamer.jpg
FILE=/home/homeassistant/.homeassistant/www/woonkamer.jpg
if test -f "$FILE"; then
echo "$FILE exist"
else echo "woonkamer.jpg missing $(date)" >> /root/error.log && sudo reboot
fi
FILE=/home/homeassistant/.homeassistant/www/keuken.jpg
if test -f "$FILE"; then
echo "$FILE exist"
else echo "keuken.jpg missing $(date)" >> /root/error.log && sudo reboot
fi