diff --git a/etc/scripts/30-rtsp-watchdog b/etc/scripts/30-rtsp-watchdog new file mode 100644 index 0000000..f7152c5 --- /dev/null +++ b/etc/scripts/30-rtsp-watchdog @@ -0,0 +1,34 @@ +#!/bin/sh +PIDFILE="/var/run/rtsp-watchdog.pid" + +status() +{ + pid="$(cat "$PIDFILE" 2>/dev/null)" + if [ "$pid" ]; then + kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1 + fi +} + +start() +{ + echo "Starting RTSP Watchdog script..." + fang-rtsp-watchdog.sh /dev/null 2>&1 & + echo "$!" > "$PIDFILE" +} + +stop() +{ + pid="$(cat "$PIDFILE" 2>/dev/null)" + if [ "$pid" ]; then + kill $pid || rm "$PIDFILE" + fi +} + +if [ $# -eq 0 ]; then + start +else + case $1 in start|stop|status) + $1 + ;; + esac +fi diff --git a/usr/bin/fang-rtsp-watchdog.sh b/usr/bin/fang-rtsp-watchdog.sh new file mode 100644 index 0000000..521679c --- /dev/null +++ b/usr/bin/fang-rtsp-watchdog.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +echo "RTSP Watchdog script started" + +while : +do + sleep 10 + if pgrep -x "snx_rtsp_server" > /dev/null + then + echo "RTSP ON" + else + echo "RTSP OFF" + /media/mmcblk0p2/data/etc/scripts/20-rtsp-server start > /dev/null + fi +done