diff --git a/custompios/crowsnest/config b/custompios/crowsnest/config index afdaa5e..47787d9 100644 --- a/custompios/crowsnest/config +++ b/custompios/crowsnest/config @@ -15,11 +15,14 @@ [ -n "$CROWSNEST_CROWSNEST_DEPS" ] || CROWSNEST_CROWSNEST_DEPS="git crudini bsdutils findutils v4l-utils ffmpeg" [ -n "$CROWSNEST_DEFAULT_CONF" ] || CROWSNEST_DEFAULT_CONF="mainsail_default.conf" [ -n "$CROWSNEST_DEFAULT_CONF_DIR" ] || CROWSNEST_DEFAULT_CONF_DIR="/home/${BASE_USER}/klipper_config" -[ -n "$CROWSNEST_MOONRAKER_SUPPORT" ] || CROWSNEST_MOONRAKER_SUPPORT="y" -[ -n "$CROWSNEST_FORCE_RASPICAMFIX" ] || CROWSNEST_FORCE_RASPICAMFIX="y" +# Force Raspicam fix bool (1:yes / 0:no) +[ -n "$CROWSNEST_FORCE_RASPICAMFIX" ] || CROWSNEST_FORCE_RASPICAMFIX=1 +# Add Crowsnest to moonraker.conf (update manager) bool (1:yes / 0:no) +[ -n "$CROWSNEST_ADD_CROWSNEST_MOONRAKER" ] || CROWSNEST_ADD_CROWSNEST_MOONRAKER=1 + # ustreamer -[ -n "$CROWSNEST_USTREAMER_DEPS" ] || CROWSNEST_USTREAMER_DEPS="git build-essential libevent-dev libjpeg62-turbo-dev \ +[ -n "$CROWSNEST_USTREAMER_DEPS" ] || CROWSNEST_USTREAMER_DEPS="git build-essential libevent-dev libjpeg8-dev \ libbsd-dev libraspberrypi-dev libgpiod-dev" [ -n "$CROWSNEST_USTREAMER_WITH_OMX" ] || CROWSNEST_USTREAMER_WITH_OMX="y" [ -n "$CROWSNEST_USTREAMER_WITH_GPIO" ] || CROWSNEST_USTREAMER_WITH_GPIO="n" diff --git a/custompios/crowsnest/start_chroot_script b/custompios/crowsnest/start_chroot_script index 7dac250..4961f3f 100644 --- a/custompios/crowsnest/start_chroot_script +++ b/custompios/crowsnest/start_chroot_script @@ -12,8 +12,7 @@ # shellcheck disable=all # Error handling -# set -x # Uncomment for debugging purposes -set -e +set -Ee source /common.sh install_cleanup_trap @@ -22,9 +21,10 @@ echo_green "Installing crowsnest and enable webcam Service ..." # install dependencies # force apt update apt update -check_install_pkgs ${CROWSNEST_CROWSNEST_DEPS} +# It could use inbuilt dependencie check, but should speed up if preinstalled. +check_install_pkgs "${CROWSNEST_CROWSNEST_DEPS}" # Move to $HOME dir -pushd /home/${BASE_USER} &> /dev/null || exit 1 +pushd "/home/${BASE_USER}" &> /dev/null || exit 1 # make sure config folder exist if [ ! -d "${CROWSNEST_DEFAULT_CONF_DIR}" ]; then sudo -u "${BASE_USER}" mkdir -p "${CROWSNEST_DEFAULT_CONF_DIR}" @@ -32,20 +32,13 @@ pushd /home/${BASE_USER} &> /dev/null || exit 1 # clone Repo echo_green "Clone crowsnest repository ..." gitclone CROWSNEST_CROWSNEST_REPO crowsnest - # install crowsnest - pushd /home/${BASE_USER}/crowsnest &> /dev/null || exit 1 - echo_green "Running crowsnest installer ..." - sudo -u "${BASE_USER}" make install - # add update manager section to moonraker.conf - if [ -f "/home/${BASE_USER}/klipper_config/moonraker.conf" ] && - [ "${CROWSNEST_MOONRAKER_SUPPORT}" == "y" ]; then - sudo -u ${BASE_USER} \ - sh -c 'echo -e "\n" >> /home/$(whoami)/klipper_config/moonraker.conf' - sudo -u ${BASE_USER} \ - sh -c 'cat file_templates/moonraker_update.txt \ - >> /home/$(whoami)/klipper_config/moonraker.conf' - fi - if [ "${CROWSNEST_FORCE_RASPICAMFIX}" == "y" ]; then + # install crowsnest - use crowsnest's make unattended + pushd "/home/${BASE_USER}/crowsnest" &> /dev/null || exit 1 + echo_green "Launch crowsnest install routine ..." + pushd "/home/${BASE_USER}/crowsnest" &> /dev/null || exit 1 + sudo -u "${BASE_USER}" make unattended + # Apply Raspicam fix if enabled. + if [ "${CROWSNEST_FORCE_RASPICAMFIX}" == "1" ]; then echo -en "Applying Raspicam Fix ... \r" sudo sh -c 'echo "bcm2835-v4l2" >> /etc/modules' sudo cp file_templates/bcm2835-v4l2.conf /etc/modprobe.d/ diff --git a/file_templates/moonraker_update.txt b/file_templates/moonraker_update.txt index bddad01..2928aa6 100644 --- a/file_templates/moonraker_update.txt +++ b/file_templates/moonraker_update.txt @@ -1,4 +1,5 @@ +# Crowsnest update_manager entry [update_manager webcamd] type: git_repo path: ~/crowsnest diff --git a/tools/install.sh b/tools/install.sh index 272dcd4..01fd35d 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -2,20 +2,18 @@ # Crow's Nest # A multiple Cam and Stream Service for mainsailOS # Written by Stephan Wendel aka KwadFan <me@stephanwe.de> -# Copyright 2021 +# Copyright 2021 - 2022 # https://github.com/mainsail-crew/crowsnest # GPL V3 ######## # shellcheck enable=require-variable-braces -## disabeld SC2086 for some lines because there we want 'word splitting' +## disabled SC2086 for some lines because there we want 'word splitting' +# Exit on errors set -Ee -## Debug -# set -x - # Global Vars BASE_USER=$(whoami) TITLE="crowsnest - A Webcam Daemon for Raspberry Pi OS" @@ -27,7 +25,7 @@ if [ ${UID} == '0' ]; then fi ### noninteractive Check -if [ -z "${DEBIAN_FRONTEND}" ]; then +if [ "${DEBIAN_FRONTEND}" != "noninteractive" ]; then export DEBIAN_FRONTEND=noninteractive fi @@ -205,11 +203,12 @@ function install_crowsnest { echo -en "Reload systemd to enable new deamon ...\r" sudo systemctl daemon-reload echo -e "Reload systemd to enable new daemon ... [OK]" - echo -en "Enable webcamd.service on boot ...\r" - sudo systemctl enable webcamd.service - echo -e "Enable webcamd.service on boot ... [OK]\r" fi - if [ "${UNATTENDED}" == "true" ]; then + echo -en "Enable webcamd.service on boot ...\r" + sudo systemctl enable webcamd.service + echo -e "Enable webcamd.service on boot ... [OK]\r" + if [ "${CROWSNEST_ADD_CROWSNEST_MOONRAKER}" == "1" ] && + [ -f "${moonraker_conf}" ]; then echo -en "Adding Crowsnest Update Manager entry to moonraker.conf ...\r" cat "${moonraker_conf}" "${moonraker_update}" | \ tee "${moonraker_conf}" > /dev/null @@ -262,7 +261,7 @@ function install_raspicam_fix { while getopts "z" arg; do case ${arg} in z) - echo "Running in UNATTENDED Mode ..." + echo "WARN: Running in UNATTENDED Mode ..." set -x UNATTENDED="true" ;; @@ -274,13 +273,17 @@ done install_cleanup_trap import_config welcome_msg -detect_existing_webcamd +if [ "${UNATTENDED}" != "true" ]; then + detect_existing_webcamd +fi echo -e "Running apt update first ..." sudo apt update install_crowsnest sub_init build_apps -install_raspicam_fix +if [ "${UNATTENDED}" != "true" ]; then + install_raspicam_fix +fi goodbye_msg exit 0 diff --git a/tools/uninstall.sh b/tools/uninstall.sh index aadc4ff..7e14efb 100755 --- a/tools/uninstall.sh +++ b/tools/uninstall.sh @@ -142,7 +142,8 @@ function uninstall_go { } function remove_raspicam_fix { - if [ -f /proc/device-tree/model ] && + if [ -f /etc/modprobe.d/bcm2835-v4l2.conf ] && + [ -f /proc/device-tree/model ] && grep -q "Raspberry" /proc/device-tree/model ; then echo -en "Removing Raspicam Fix ...\r" sudo sed -i '/bcm2835/d' /etc/modules