feat: added feature versioncontrol

If log_level is set at least to verbose it will
display versions of used 3rd Party tools like
ustreamer, rtsp-simple-server and ffmpeg

Signed-off-by: Stephan Wendel <me@stephanwe.de>
This commit is contained in:
Stephan Wendel 2022-04-10 14:20:03 +02:00
parent 3692b310a5
commit 6f17019fb8
No known key found for this signature in database
GPG Key ID: F465B83ACBA45639
4 changed files with 82 additions and 2 deletions

View File

@ -114,7 +114,8 @@ function initial_check {
check_dep "xargs"
check_dep "ffmpeg"
check_apps
# check_dep "rtsp-simple-server" # Stay for later use.
versioncontrol
# print cfg if ! log_level: quiet
if [ -z "$(check_cfg "${WEBCAMD_CFG}")" ]; then
if [ "$(log_level)" != "quiet" ]; then
print_cfg

View File

@ -119,7 +119,7 @@ function debug_msg {
local prefix
prefix="Develop -- DEBUG:"
while read -r msg; do
log_msg "${prefix}${msg}"
log_msg "${prefix} ${msg}"
echo -e "${msg}" | logger -t webcamd
done <<< "${1}"
}

78
libs/versioncontrol.sh Normal file
View File

@ -0,0 +1,78 @@
#!/bin/bash
#### version control library
#### webcamd - 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
####
#### Description: Checks Versions of Streamer and ffmpeg
####
# shellcheck enable=require-variable-braces
# Exit upon Errors
set -Ee
function versioncontrol {
function vc_log_msg {
log_msg "Version Control: ${1}"
}
function get_ustreamer_version {
local cur_ver avail_ver
pushd "${BASE_CN_PATH}"/bin/ustreamer || exit 1
avail_ver="$(git describe --tags --always)"
cur_ver="v$("${PWD}"/ustreamer -v)"
if [ "${cur_ver}" == "${avail_ver}" ]; then
vc_log_msg "ustreamer is up to date. (${cur_ver})"
fi
if [ "${cur_ver}" != "${avail_ver}" ]; then
vc_log_msg "ustreamer new version available: ${avail_ver} (${cur_ver})."
fi
popd || exit 1
}
function get_rtsp_version {
local cur_ver avail_ver
pushd "${BASE_CN_PATH}"/bin/rtsp-simple-server || exit 1
avail_ver="$(cat version)"
cur_ver="$("${PWD}"/rtsp-simple-server --version)"
if [ "${cur_ver}" == "${avail_ver}" ]; then
vc_log_msg "rtsp-simple-server is up to date. (${cur_ver})"
fi
if [ "${cur_ver}" != "${avail_ver}" ]; then
vc_log_msg "rtsp-simple-server new version available: ${avail_ver} (${cur_ver})."
fi
popd || exit 1
}
function get_ffmpeg_version {
local cur_ver avail_ver
avail_ver="$(dpkg-query -W ffmpeg | awk -F':' '{print $2}')"
cur_ver="$(ffmpeg -version | awk 'NR==1 {print $3}')"
if [ "${cur_ver}" == "${avail_ver}" ]; then
vc_log_msg "ffmpeg is up to date. (${cur_ver})"
fi
if [ "${cur_ver}" != "${avail_ver}" ]; then
vc_log_msg "ffmpeg new version available: ${avail_ver} (${cur_ver})."
fi
}
### MAIN
function main {
if [ "$(log_level)" != "quiet" ]; then
get_ustreamer_version
get_rtsp_version
get_ffmpeg_version
fi
}
main
return
}

View File

@ -30,6 +30,7 @@ source "${BASE_CN_PATH}/libs/messages.sh"
source "${BASE_CN_PATH}/libs/rtspsimple.sh"
source "${BASE_CN_PATH}/libs/ustreamer.sh"
source "${BASE_CN_PATH}/libs/v4l2_control.sh"
source "${BASE_CN_PATH}/libs/versioncontrol.sh"
source "${BASE_CN_PATH}/libs/watchdog.sh"
#### MAIN