Stephan Wendel f6e2156ab3
Merge develop branch (#163)
* 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>
2023-08-11 18:04:33 +02:00

127 lines
3.2 KiB
Bash
Executable File

#!/bin/bash
#### Core 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
## Version of crowsnest
function self_version {
pushd "${BASE_CN_PATH}" &> /dev/null
git describe --always --tags
popd &> /dev/null
}
# Init Traps
trap 'shutdown' 1 2 3 15
trap 'err_exit $? $LINENO' ERR
# Behavior of traps
# log_msg, see libs/logging.sh L#46
# Print Error Code and Line to Log
# and kill running jobs
function err_exit {
local file_trace func_trace line_trace
read -r LINE FUNC FILE < <(caller 0)
func_trace="${FUNC}"
file_trace="$(basename "${FILE}")"
line_trace="${LINE}"
if [ "${1}" != "0" ]; then
log_msg "ERROR: Error ${1} occured on line ${line_trace}"
log_msg "==> Error occured in file: ${file_trace} -> ${func_trace}"
log_msg "ERROR: Stopping $(basename "$0")."
log_msg "Goodbye..."
fi
if [ -n "$(jobs -pr)" ]; then
jobs -pr | while IFS='' read -r job_id; do
kill "${job_id}"
done
fi
exit 1
}
# Print Goodbye Message
# and kill running jobs
function shutdown {
log_msg "Shutdown or Killed by User!"
log_msg "Please come again :)"
if [ -n "$(jobs -pr)" ]; then
jobs -pr | while IFS='' read -r job_id; do
kill "${job_id}"
done
fi
log_msg "Goodbye..."
exit 0
}
## Sanity Checks
# Dependency Check
# call check_dep <programm>, ex.: check_dep vim
function check_dep {
local dep
dep="$(whereis "${1}" | awk '{print $2}')"
if [[ -z "${dep}" ]]; then
log_msg "Dependency: '${1}' not found. Exiting!"
exit 1
else
log_msg "Dependency: '${1}' found in ${dep}."
fi
}
function check_apps {
local cstreamer ustreamer
ustreamer="bin/ustreamer/ustreamer"
cstreamer="bin/camera-streamer/camera-streamer"
if [[ -x "${BASE_CN_PATH}/${ustreamer}" ]]; then
log_msg "Dependency: '${ustreamer##*/}' found in ${ustreamer}."
else
log_msg "Dependency: '${ustreamer##*/}' not found. Exiting!"
exit 1
fi
## Avoid dependency check if non rpi sbc
if [[ "$(is_raspberry_pi)" = "1" ]] && [[ "$(is_ubuntu_arm)" = "0" ]]; then
if [[ -x "${BASE_CN_PATH}/${cstreamer}" ]]; then
log_msg "Dependency: '${cstreamer##*/}' found in ${cstreamer}."
else
log_msg "Dependency: '${cstreamer##*/}' not found. Exiting!"
exit 1
fi
fi
}
# Check all needed Dependencies
# If pass print your set configfile to log.
# print_cfg, see libs/logging.sh L#75
# pint_cams, see libs/logging.sh L#84
function initial_check {
log_msg "INFO: Checking Dependencies"
check_dep "crudini"
check_dep "find"
check_dep "xargs"
check_apps
versioncontrol
# print cfg if ! "${CROWSNEST_LOG_LEVEL}": quiet
if [ -z "$(check_cfg "${CROWSNEST_CFG}")" ]; then
if [[ "${CROWSNEST_LOG_LEVEL}" != "quiet" ]]; then
print_cfg
fi
fi
log_msg "INFO: Detect available Devices"
print_cams
return
}