CreatBotCrowsnest/libs/watchdog.sh
Stephan Wendel 95c1dca13f
feat!: adds camera-streamer to crowsnest
This introduces camera-streamer as streamer option
via `mode: multi`

camera-streamer is a feature packed stream service.
It is capable to deliver mjpg/snapshots/webrtc and rtsp

Limited to raspberry pi sbc's for now.

This should also resolv
Feature request #51
Feature request #37
Fixes #83
Closes #85
Fixes #89

BREAKING CHANGES:

Dropping support for Debian Buster based images and kernels older than
5.15y

Dropping RTSP support due aler9/simple-rtsp-server

Dropping usage of ffmpeg

No support anymore for Raspicam V1 (EOL)

Signed-off-by: Stephan Wendel <me@stephanwe.de>

Signed-off-by: Stephan Wendel <me@stephanwe.de>
2023-03-11 18:57:19 +01:00

78 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
#### Watchdog
#### crowsnest - A webcam Service for multiple Cams and Stream Services.
####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021
#### https://github.com/mainsail-crew/crowsnest
####
#### This File is distributed under GPLv3
####
# shellcheck enable=require-variable-braces
# Exit upon Errors
set -Ee
#### Watchdog Functions and Variables
## Do not reuse functions from other libs/scripts!
# We want watchdog operating independently!
function clean_watchdog {
rm -f /tmp/lost-*
}
function crowsnest_watchdog {
# Helper Functions
function available {
find "${1}" &> /dev/null
echo "${?}"
}
function lost_dev {
local lostfile
lostfile="$(echo "${1}" | awk -F '/' '{print $NF}')"
touch /tmp/lost-"${lostfile}"
}
function is_lost {
local lostdev
lostdev="$(echo "${1}" | awk -F '/' '{print $NF}')"
find /tmp/lost-"${lostdev}" &> /dev/null
echo "${?}"
}
function returned_dev {
local lostdev
lostdev="$(echo "${1}"| awk -F '/' '{print $NF}')"
rm -f /tmp/lost-"${lostdev}" &> /dev/null
}
function get_conf_devices {
local gcd
for i in $(crudini --existing=file --get "${CROWSNEST_CFG}" | \
sed '/crowsnest/d' | cut -d ' ' -f2); do
gcd+=("${i}")
done
echo "${gcd[@]}"
}
### MAIN
for i in $(get_conf_devices); do
cc="$(crudini --get "${CROWSNEST_CFG}" "cam ${i}" "device" \
| awk '{print $1}')"
if [[ ! "${cc}" =~ "/base/soc" ]] &&
[[ "$(available "${cc}")" -ne 0 ]] && [[ "$(is_lost "${cc}")" -ne 0 ]]; then
log_msg "WATCHDOG: Lost Device: '${cc}'"
lost_dev "${cc}"
elif [[ ! "${cc}" =~ "/base/soc" ]] &&
[[ "$(is_lost "${cc}")" -eq 0 ]] && [[ "$(available "${cc}")" -eq 0 ]]; then
log_msg "WATCHDOG: Device '${cc}' returned."
returned_dev "${cc}"
fi
done
}