diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index a5d1e37b..065dc46f 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -44,7 +44,7 @@ list_cam_formats() { prefix="$(date +'[%D %T]') crowsnest:" log_msg "Supported Formats:" while read -r i; do - printf "%s\t\t%s\n" "${prefix}" "${i}" >>"${CROWSNEST_LOG_PATH}" + printf "%s\t\t%s\n" "${prefix}" "${i}" >> "${CROWSNEST_LOG_PATH}" done < <(v4l2-ctl -d "${device}" --list-formats-ext | sed '1,3d') } @@ -54,7 +54,7 @@ list_cam_v4l2ctrls() { prefix="$(date +'[%D %T]') crowsnest:" log_msg "Supported Controls:" while read -r i; do - printf "%s\t\t%s\n" "${prefix}" "${i}" >>"${CROWSNEST_LOG_PATH}" + printf "%s\t\t%s\n" "${prefix}" "${i}" >> "${CROWSNEST_LOG_PATH}" done < <(v4l2-ctl -d "${device}" --list-ctrls-menus) } @@ -62,7 +62,7 @@ list_cam_v4l2ctrls() { detect_libcamera() { local avail if [[ "$(is_raspberry_pi)" = "1" ]] && - [[ -x "$(command -v libcamera-hello)" ]]; then + [[ -x "$(command -v libcamera-hello)" ]]; then avail="$(libcamera-hello --list-cameras | grep -c "Available")" if [[ "${avail}" = "1" ]]; then get_libcamera_path | wc -l @@ -78,8 +78,8 @@ detect_libcamera() { get_libcamera_path() { if [[ "$(is_raspberry_pi)" = "1" ]] && [[ -x "$(command -v libcamera-hello)" ]]; then - libcamera-hello --list-cameras | sed '1,2d' | - grep "\(/base/*\)" | cut -d"(" -f2 | tr -d '$)' + libcamera-hello --list-cameras | sed '1,2d' \ + | grep "\(/base/*\)" | cut -d"(" -f2 | tr -d '$)' fi } @@ -89,7 +89,7 @@ list_picam_resolution() { prefix="$(date +'[%D %T]') crowsnest:" log_msg "'libcamera' device(s) resolution(s) :" while read -r i; do - printf "%s\t\t%s\n" "${prefix}" "${i}" >>"${CROWSNEST_LOG_PATH}" + printf "%s\t\t%s\n" "${prefix}" "${i}" >> "${CROWSNEST_LOG_PATH}" done < <(libcamera-hello --list-cameras | sed '1,2d;s/Modes:/Colorspace:/') } @@ -137,18 +137,18 @@ function detect_legacy { command -v vcgencmd &>/dev/null; then if vcgencmd get_camera &>/dev/null; then avail="$( - vcgencmd get_camera | - awk -F '=' '{ print $3 }' | - cut -d',' -f1 - )" + vcgencmd get_camera \ + | awk -F '=' '{ print $3 }' \ + | cut -d',' -f1 + )" fi fi echo "${avail:-0}" } function dev_is_legacy { - v4l2-ctl --list-devices | grep -A1 -e 'mmal' | - awk 'NR==2 {print $1}' + v4l2-ctl --list-devices | grep -A1 -e 'mmal' \ + | awk 'NR==2 {print $1}' } ## Determine if cam has H.264 Hardware encoder @@ -172,7 +172,7 @@ detect_mjpeg() { ## Check if device is raspberry sbc is_raspberry_pi() { if [[ -f /proc/device-tree/model ]] && - grep -q "Raspberry" /proc/device-tree/model; then + grep -q "Raspberry" /proc/device-tree/model; then echo "1" else echo "0" @@ -181,7 +181,7 @@ is_raspberry_pi() { is_pi5() { if [[ -f /proc/device-tree/model ]] && - grep -q "Raspberry Pi 5" /proc/device-tree/model; then + grep -q "Raspberry Pi 5" /proc/device-tree/model; then echo "1" else echo "0" @@ -190,7 +190,7 @@ is_pi5() { is_ubuntu_arm() { if [[ "$(is_raspberry_pi)" = "1" ]] && - grep -q "ubuntu" /etc/os-release; then + grep -q "ubuntu" /etc/os-release; then echo "1" else echo "0" diff --git a/libs/logging.sh b/libs/logging.sh index 9fdb228f..0bc48caa 100755 --- a/libs/logging.sh +++ b/libs/logging.sh @@ -39,7 +39,7 @@ function init_logging { function set_log_level { local loglevel - loglevel="$(get_param crowsnest log_level 2>/dev/null)" + 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" @@ -51,7 +51,7 @@ function set_log_level { function delete_log { local del_log - del_log="$(get_param "crowsnest" delete_log 2>/dev/null)" + del_log="$(get_param "crowsnest" delete_log 2> /dev/null)" if [ "${del_log}" = "true" ]; then rm -rf "${CROWSNEST_LOG_PATH}" fi @@ -61,7 +61,7 @@ function log_msg { local msg prefix msg="${1}" prefix="$(date +'[%D %T]') crowsnest:" - printf "%s %s\n" "${prefix}" "${msg}" >>"${CROWSNEST_LOG_PATH}" + printf "%s %s\n" "${prefix}" "${msg}" >> "${CROWSNEST_LOG_PATH}" printf "%s\n" "${msg}" } @@ -81,10 +81,10 @@ function print_cfg { 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 + 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 { @@ -92,7 +92,7 @@ function print_cams { v4l="$(find /dev/v4l/by-id/ -iname "*index0" 2>/dev/null | wc -l)" libcamera="$(detect_libcamera)" legacy="$(detect_legacy)" - total="$((v4l + libcamera + legacy))" + total="$((v4l+libcamera+legacy))" if [ "${total}" -eq 0 ]; then log_msg "ERROR: No usable Devices Found. Stopping $(basename "${0}")." exit 1 @@ -114,8 +114,8 @@ function print_cams { fi fi if [[ "${legacy}" -ne 0 ]]; then - raspicam="$(v4l2-ctl --list-devices | grep -A1 -e 'mmal' | - awk 'NR==2 {print $1}')" + 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}" @@ -139,8 +139,8 @@ function print_host { ## 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/"$//')" + 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 @@ -154,7 +154,7 @@ function print_host { log_msg "Host Info: Model: ${sbc_model}" fi if [[ -n "${generic_model}" ]] && - [[ -z "${sbc_model}" ]]; then + [[ -z "${sbc_model}" ]]; then log_msg "Host Info: Model: ${generic_model}" fi ## CPU count