From 6f17019fb83ea0228018259bd390fd7fb1fd2a43 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sun, 10 Apr 2022 14:20:03 +0200 Subject: [PATCH] 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 --- libs/core.sh | 3 +- libs/logging.sh | 2 +- libs/versioncontrol.sh | 78 ++++++++++++++++++++++++++++++++++++++++++ webcamd | 1 + 4 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 libs/versioncontrol.sh diff --git a/libs/core.sh b/libs/core.sh index c63fecf..bd7f391 100755 --- a/libs/core.sh +++ b/libs/core.sh @@ -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 diff --git a/libs/logging.sh b/libs/logging.sh index 4301155..4b49ed2 100755 --- a/libs/logging.sh +++ b/libs/logging.sh @@ -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}" } diff --git a/libs/versioncontrol.sh b/libs/versioncontrol.sh new file mode 100644 index 0000000..251383d --- /dev/null +++ b/libs/versioncontrol.sh @@ -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 +#### 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 +} diff --git a/webcamd b/webcamd index a75433a..446f262 100755 --- a/webcamd +++ b/webcamd @@ -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