* Fix makefile flags on low memory devices (#124) * Fix `makefile` flags on low memory devices On devices with less than 512MB existing devices will use `-j2` due to wrong condition. * docs: Update index with correct heading and link to backends (#131) This is a follow-up to #108 and fixes heading and hyperlink to the list of backends * Typo in `core.sh` (#138) * Fix makefile flags on low memory devices (#124) (#125) * Fix `makefile` flags on low memory devices On devices with less than 512MB existing devices will use `-j2` due to wrong condition. Co-authored-by: Kamil Trzciński <ayufan@ayufan.eu> * Typo in `core.sh` 'Dependencys' --> dependencies --------- Co-authored-by: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Co-authored-by: Kamil Trzciński <ayufan@ayufan.eu> * Fix makefile flags on low memory devices (#124) (#125) (#144) * Fix `makefile` flags on low memory devices On devices with less than 512MB existing devices will use `-j2` due to wrong condition. Co-authored-by: Kamil Trzciński <ayufan@ayufan.eu> * docs(messages.sh): fix typos, improve spelling (#145) * feat: add legacy cam support (#146) * feat: add legacy cam support Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com> * feat: add blockyfix Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com> * fix: add ustreamer legacy cam workaround Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com> --------- Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com> * Fix makefile flags on low memory devices (#124) (#125) (#147) * Fix `makefile` flags on low memory devices On devices with less than 512MB existing devices will use `-j2` due to wrong condition. Co-authored-by: Kamil Trzciński <ayufan@ayufan.eu> * fix: fix make config empty path (#148) Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com> * fix: fix default_path_msg function name (#149) * fix: fix default_path_msg function name Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com> * fix: fix message Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com> --------- Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com> * fix: fix libcamera-apps-lite not getting updated (#160) libcamera-apps-lite is needed for libcamera-hello. Crowsnest uses libcamera-hello to detected raspicams Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com> * fix: fix Shellcheck test error (#153) * fix: fix Shellcheck test error Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com> * style: remove empty condition Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com> --------- Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com> * fix: fix CustomPiOS docker build error (#158) This should skip any check of `SUDO_USER` Tested with Win & Linux host with Docker Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com> --------- Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com> Co-authored-by: Kamil Trzciński <ayufan@ayufan.eu> Co-authored-by: DeviousFusion <dj3tusk@gmail.com> Co-authored-by: Sergei <67871383+slepiavka@users.noreply.github.com> Co-authored-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>
155 lines
4.8 KiB
Bash
Executable File
155 lines
4.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
#### Logging library
|
|
|
|
#### 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
|
|
|
|
## Logging
|
|
function set_log_path {
|
|
#Workaround sed ~ to BASH VAR $HOME
|
|
CROWSNEST_LOG_PATH=$(get_param "crowsnest" log_path | sed "s#^~#${HOME}#gi")
|
|
declare -g CROWSNEST_LOG_PATH
|
|
#Workaround: Make Dir if not exist
|
|
if [ ! -d "$(dirname "${CROWSNEST_LOG_PATH}")" ]; then
|
|
mkdir -p "$(dirname "${CROWSNEST_LOG_PATH}")"
|
|
fi
|
|
}
|
|
|
|
function init_logging {
|
|
set_log_path
|
|
set_log_level
|
|
delete_log
|
|
log_msg "crowsnest - A webcam Service for multiple Cams and Stream Services."
|
|
log_msg "Version: $(self_version)"
|
|
log_msg "Prepare Startup ..."
|
|
print_host
|
|
}
|
|
|
|
function set_log_level {
|
|
local loglevel
|
|
loglevel="$(get_param crowsnest log_level 2> /dev/null)"
|
|
# Set default log_level to quiet
|
|
if [ -z "${loglevel}" ] || [[ "${loglevel}" != @(quiet|verbose|debug) ]]; then
|
|
CROWSNEST_LOG_LEVEL="quiet"
|
|
else
|
|
CROWSNEST_LOG_LEVEL="${loglevel}"
|
|
fi
|
|
declare -r CROWSNEST_LOG_LEVEL
|
|
}
|
|
|
|
function delete_log {
|
|
local del_log
|
|
del_log="$(get_param "crowsnest" delete_log 2> /dev/null)"
|
|
if [ "${del_log}" = "true" ]; then
|
|
rm -rf "${CROWSNEST_LOG_PATH}"
|
|
fi
|
|
}
|
|
|
|
function log_msg {
|
|
local msg prefix
|
|
msg="${1}"
|
|
prefix="$(date +'[%D %T]') crowsnest:"
|
|
printf "%s %s\n" "${prefix}" "${msg}" >> "${CROWSNEST_LOG_PATH}"
|
|
printf "%s\n" "${msg}"
|
|
}
|
|
|
|
#call '| log_output "<prefix>"'
|
|
function log_output {
|
|
local prefix
|
|
prefix="DEBUG: ${1}"
|
|
while read -r line; do
|
|
if [[ "${CROWSNEST_LOG_LEVEL}" = "debug" ]]; then
|
|
log_msg "${prefix}: ${line}"
|
|
fi
|
|
done
|
|
}
|
|
|
|
function print_cfg {
|
|
local prefix
|
|
prefix="$(date +'[%D %T]') crowsnest:"
|
|
log_msg "INFO: Print Configfile: '${CROWSNEST_CFG}'"
|
|
(sed '/^#.*/d;/./,$!d' | cut -d'#' -f1) < "${CROWSNEST_CFG}" | \
|
|
while read -r line; do
|
|
printf "%s\t\t%s\n" "${prefix}" "${line}" >> "${CROWSNEST_LOG_PATH}"
|
|
printf "\t\t%s\n" "${line}"
|
|
done
|
|
}
|
|
|
|
function print_cams {
|
|
local total v4l
|
|
v4l="$(find /dev/v4l/by-id/ -iname "*index0" 2> /dev/null | wc -l)"
|
|
total="$((v4l+($(detect_libcamera))+($(detect_legacy))))"
|
|
if [ "${total}" -eq 0 ]; then
|
|
log_msg "ERROR: No usable Devices Found. Stopping $(basename "${0}")."
|
|
exit 1
|
|
else
|
|
log_msg "INFO: Found ${total} total available Device(s)"
|
|
fi
|
|
if [[ "$(detect_libcamera)" -ne 0 ]]; then
|
|
log_msg "Detected 'libcamera' device -> $(get_libcamera_path)"
|
|
fi
|
|
if [[ "$(detect_legacy)" -ne 0 ]]; then
|
|
raspicam="$(v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \
|
|
awk 'NR==2 {print $1}')"
|
|
log_msg "Detected 'Raspicam' Device -> ${raspicam}"
|
|
if [[ ! "${CROWSNEST_LOG_LEVEL}" = "quiet" ]]; then
|
|
list_cam_formats "${raspicam}"
|
|
list_cam_v4l2ctrls "${raspicam}"
|
|
fi
|
|
fi
|
|
if [[ -d "/dev/v4l/by-id/" ]]; then
|
|
detect_avail_cams
|
|
fi
|
|
}
|
|
|
|
function print_host {
|
|
local disksize generic_model memtotal sbc_model
|
|
generic_model="$(grep "model name" /proc/cpuinfo | cut -d':' -f2 | awk NR==1)"
|
|
sbc_model="$(grep "Model" /proc/cpuinfo | cut -d':' -f2)"
|
|
memtotal="$(grep "MemTotal:" /proc/meminfo | awk '{print $2" "$3}')"
|
|
disksize="$(LC_ALL=C df -h / | awk 'NR==2 {print $4" / "$2}')"
|
|
## print only if not "${CROWSNEST_LOG_LEVEL}": quiet
|
|
if [[ "${CROWSNEST_LOG_LEVEL}" != "quiet" ]]; then
|
|
log_msg "INFO: Host information:"
|
|
## OS Infos
|
|
## OS Version
|
|
if [[ -f /etc/os-release ]]; then
|
|
log_msg "Host Info: Distribution: $(grep "PRETTY" /etc/os-release | \
|
|
cut -d '=' -f2 | sed 's/^"//;s/"$//')"
|
|
fi
|
|
## Release Version of MainsailOS (if file present)
|
|
if [[ -f /etc/mainsailos-release ]]; then
|
|
log_msg "Host Info: Release: $(cat /etc/mainsailos-release)"
|
|
fi
|
|
## Kernel version
|
|
log_msg "Host Info: Kernel: $(uname -s) $(uname -rm)"
|
|
## Host Machine Infos
|
|
## Host model
|
|
if [[ -n "${sbc_model}" ]]; then
|
|
log_msg "Host Info: Model: ${sbc_model}"
|
|
fi
|
|
if [[ -n "${generic_model}" ]] &&
|
|
[[ -z "${sbc_model}" ]]; then
|
|
log_msg "Host Info: Model: ${generic_model}"
|
|
fi
|
|
## CPU count
|
|
log_msg "Host Info: Available CPU Cores: $(nproc)"
|
|
## Avail mem
|
|
log_msg "Host Info: Available Memory: ${memtotal}"
|
|
## Avail disk size
|
|
log_msg "Host Info: Diskspace (avail. / total): ${disksize}"
|
|
fi
|
|
}
|