diff --git a/tools/install.sh b/tools/install.sh index 49e76514..ce0c4f77 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -49,20 +49,11 @@ main() { [[ -n "${BASE_USER}" ]] || BASE_USER="${SUDO_USER}" - if [[ "$(is_buster)" = "1" ]]; then not_supported_msg exit 1 fi - if [[ "$(is_raspbian)" = "1" ]]; then - link_pkglist_rpi - fi - - if [[ "$(is_raspbian)" = "0" ]]; then - link_pkglist_generic - fi - welcome_msg msg "Running apt-get update first ...\n" @@ -72,6 +63,30 @@ main() { status_msg "Running apt-get update first ..." "1" fi + if [[ "${CROWSNEST_UNATTENDED}" != "1" ]]; then + msg "Doing some tests ...\n" + if shallow_cs_dependencies_check; then + CN_INSTALL_CS="1" + else + CN_INSTALL_CS="0" + fi + status_msg "Doing some tests ..." "0" + else + if [[ "$(is_raspbian)" = "1" ]]; then + CN_INSTALL_CS="1" + else + CN_INSTALL_CS="0" + fi + fi + + if [[ "${CN_INSTALL_CS}" = "1" ]]; then + msg "Installing with camera-streamer ...\n" + link_pkglist_rpi + else + msg "Installing without camera-streamer ...\n" + link_pkglist_generic + fi + source_pkglist_file msg "Installing dependencies ...\n" if install_dependencies ;then @@ -128,9 +143,9 @@ main() { add_group_video - if [[ "$(is_bookworm)" = "1" ]]; then - msg "Bookworm detected!" - msg "Using main branch of camera-streamer for Bookworm..." + if [[ "$(is_bookworm)" = "1" ]] && [[ "${CN_INSTALL_CS}" = "1" ]]; then + msg "\nBookworm detected!" + msg "Using main branch of camera-streamer for Bookworm ...\n" CROWSNEST_CAMERA_STREAMER_REPO_BRANCH="main" fi diff --git a/tools/libs/build_apps.sh b/tools/libs/build_apps.sh index 989d3ddb..e02fd62f 100755 --- a/tools/libs/build_apps.sh +++ b/tools/libs/build_apps.sh @@ -44,11 +44,10 @@ build_apps() { msg "Cloning ustreamer repository ..." clone_ustreamer ## Detect Image build for Raspberrys - if [[ "$(is_raspbian)" = "1" ]]; then + if [[ "${CN_INSTALL_CS}" = "1" ]]; then msg "Cloning camera-streamer repository ..." clone_cstreamer - fi - if [[ "$(is_raspbian)" = "0" ]]; then + else msg "Install of camera-streamer skipped, only supported on Raspberry SBC's! ... " fi sudo -u "${BASE_USER}" "${PWD}"/bin/build.sh --build diff --git a/tools/libs/core.sh b/tools/libs/core.sh index 796ea1e9..53dddf8a 100755 --- a/tools/libs/core.sh +++ b/tools/libs/core.sh @@ -48,6 +48,74 @@ is_raspbian() { fi } +is_raspberry_pi() { + if [[ -f /proc/device-tree/model ]] && + grep -q "Raspberry" /proc/device-tree/model; then + echo "1" + else + echo "0" + fi +} + +is_ubuntu_arm() { + if [[ "$(is_raspberry_pi)" = "1" ]] && + grep -q "ubuntu" /etc/os-release; then + echo "1" + else + echo "0" + fi +} + +test_load_module() { + if modprobe -n "${1}" &> /dev/null; then + echo 1 + else + echo 0 + fi +} + +shallow_cs_dependencies_check() { + msg "Checking for camera-streamer dependencies ...\n" + + msg "Checking if device is a Raspberry Pi ...\n" + if [[ "$(is_raspberry_pi)" = "0" ]]; then + status_msg "Checking if device is a Raspberry Pi ..." "3" + msg "This device is not a Raspberry Pi therefore camera-streeamer cannot be installed ..." + return 1 + fi + status_msg "Checking if device is a Raspberry Pi ..." "0" + + msg "Checking if device is not running Ubuntu ...\n" + if [[ "$(is_ubuntu_arm)" = "1" ]]; then + status_msg "Checking if device is not running Ubuntu ..." "3" + msg "This device is running Ubuntu therefore camera-streeamer cannot be installed ..." + return 1 + fi + status_msg "Checking if device is not running Ubuntu ..." "0" + + msg "Checking for required kernel module ...\n" + SHALLOW_CHECK_MODULESLIST="bcm2835_codec" + if [[ "$(test_load_module ${SHALLOW_CHECK_MODULESLIST})" = "0" ]]; then + status_msg "Checking for required kernel module ..." "3" + msg "Not all required kernel modules for camera-streamer can be loaded ..." + return 1 + fi + status_msg "Checking for required kernel module ..." "0" + + msg "Checking for required packages ...\n" + # Update the number below if you update SHALLOW_CHECK_PKGLIST + SHALLOW_CHECK_PKGLIST="^(libavformat-dev|libavutil-dev|libavcodec-dev|liblivemedia-dev|libcamera-dev|libcamera-apps-lite)$" + if [[ $(apt-cache search --names-only "${SHALLOW_CHECK_PKGLIST}" | wc -l) -lt 6 ]]; then + status_msg "Checking for required packages ..." "3" + msg "Not all required packages for camera-streamer can be installed ..." + return 1 + fi + status_msg "Checking for required packages ..." "0" + + status_msg "Checking for camera-streamer dependencies ..." "0" + return 0 +} + link_pkglist_rpi() { sudo -u "${BASE_USER}" ln -sf "${SRC_DIR}/libs/pkglist-rpi.sh" "${SRC_DIR}/pkglist.sh" &> /dev/null || return 1 } diff --git a/tools/libs/messages.sh b/tools/libs/messages.sh index 7e668358..20f3df72 100755 --- a/tools/libs/messages.sh +++ b/tools/libs/messages.sh @@ -44,6 +44,9 @@ status_msg() { if [[ "${status}" == "2" ]]; then echo -e "${msg} [\e[33mSKIPPED\e[0m]" fi + if [[ "${status}" == "3" ]]; then + echo -e "${msg} [\e[33mFAILED\e[0m]" + fi } not_as_root_msg() { diff --git a/tools/libs/pkglist-rpi.sh b/tools/libs/pkglist-rpi.sh index 966143a3..d2a4ff1f 100644 --- a/tools/libs/pkglist-rpi.sh +++ b/tools/libs/pkglist-rpi.sh @@ -22,5 +22,6 @@ PKGLIST="git crudini bsdutils findutils v4l-utils curl" ### Ustreamer Dependencies PKGLIST="${PKGLIST} build-essential libevent-dev libjpeg-dev libbsd-dev" ### Camera-Streamer Dependencies +### If you change something below, also have a look at tools/libs/core.sh->shallow_cs_dependencies_check PKGLIST="${PKGLIST} cmake libavformat-dev libavutil-dev libavcodec-dev libcamera-dev libcamera-apps-lite" PKGLIST="${PKGLIST} liblivemedia-dev pkg-config xxd build-essential cmake libssl-dev"