CreatBotCrowsnest/libs/init_stream.sh
Stephan Wendel 7bdb2555e1
REFACTOR: Refactored init_stream.sh
* Shortend Code in construct_streamer
* BUGFIX: Typo in shellcheck directive

Signed-off-by: Stephan Wendel <me@stephanwe.de>
2021-12-17 21:56:16 +01:00

40 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
#### Init Stream library
#### webcamd - A webcam Service for multiple Cams and Stream Services.
####
#### written by Stephan Wendel aka KwadFan
#### Copyright 2021
#### https://github.com/mainsail-crew/crowsnest
####
#### This File is distributed under GPLv3
####
# shellcheck enable=require-variable-braces
# Exit upon Errors
set -e
## Start Stream Service
# sleep to prevent cpu cycle spikes
function construct_streamer {
local stream_server
log_msg "Try to start configured Cams / Services..."
for i in $(configured_cams); do
stream_server="$(get_param "cam ${i}" streamer 2> /dev/null)"
if [ "${stream_server}" == "ustreamer" ]; then
run_ustreamer "${i}" &
sleep 8 & sleep_pid="$!"
wait "${sleep_pid}"
elif [ "${stream_server}" == "rtsp" ]; then
run_rtsp "${i}" &
sleep 8 & sleep_pid="$!"
wait "${sleep_pid}"
else
log_msg "ERROR: Missing 'streamer' parameter in [cam ${i}]. Skipping."
fi
done
log_msg "... Done!"
}