I have been playing around with FFMpeg and figured out how to take a snapshot of my cameras and save it to a file. I have also created a .sh script on the Pi.
Whats the best way to trigger this script on reboot?
My cctv.sh script
GNU nano 2.7.4 File: cctv.sh
#!/bin/bash
#ffmpeg cctv script to get snapshot from cctc cameras
ffmpeg -y -rtsp_transport tcp -i rtsp://admin:sinola10@192.168.1.80:554/Streaming/Channels/302 -an -vf fps=1/10 -s 800x450 -update 1 /etc/openhab2/html/img.jpg &
I have tried to edit the rc.local file as suggested in a tutorial I read with -:
#!/bin/sh -e
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
FLAG="/opt/afterfirstboot.lock"
FIRSTBOOT="/boot/first-boot.sh"
# Only executed after first boot
if [ ! -f "$FLAG" ]; then
echo "[openHABian] Flag file 'afterfirstboot.lock' not found, continuing with '$FIRSTBOOT' script."
if [ ! -f "$FIRSTBOOT" ]; then "[openHABian] 'first-boot.sh' not found, Exiting."; exit 0; fi
if (/bin/bash "$FIRSTBOOT"); then
echo "[openHABian] Finishing up... "
echo "[openHABian] Created after first boot script succeeded (see /etc/rc.local). Do not delete." > "$FLAG"
else
echo "[openHABian] Script '$FIRSTBOOT' failed."
fi
fi
sudo bash /home/cctv.sh &
exit 0
# vim: filetype=sh
I also think I have set permissions correctly… but go easy on me I have a serious Linux learning curve.
[20:06:46] root@openHABianPi:/etc# cd ~
[20:07:00] root@openHABianPi:~# ls -l
total 8
-rwxr-xr-x 1 root root 229 Jul 11 19:23 cctv.sh
drwxr-xr-x 19 root root 4096 Jul 7 18:49 ffmpeg
[20:07:05] root@openHABianPi:~#
If I execute the script manually it works but when I reboot the Pi it does not work, could some guru point me in the right direction please? What have I missed or not learnt correctly?