Skip to content

Commit

Permalink
[Automated] Merged develop into target master
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou authored Nov 15, 2023
2 parents 4050a3b + e7d85dc commit a3fc462
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 20 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ report: ## Generate report.txt
@if [ -f ~/report.txt ]; then rm -f ~/report.txt; fi
@bash -c 'tools/dev-helper.sh -a >> ~/report.txt'
@sed -ri 's/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g' ~/report.txt

fixworkingdirectory: ## Fix service file WorkingDirectory path
@sudo sed -i "s~\(WorkingDirectory=\).*~\1$$PWD~" /etc/systemd/system/crowsnest.service
11 changes: 10 additions & 1 deletion crowsnest
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if [ "$#" -eq 0 ]; then
fi

## Parse Args
while getopts ":vhc:d" arg; do
while getopts ":vhc:s:d" arg; do
case "${arg}" in
v )
echo -e "\ncrowsnest Version: $(self_version)\n"
Expand All @@ -55,6 +55,15 @@ while getopts ":vhc:d" arg; do
check_cfg "${OPTARG}"
export CROWSNEST_CFG="${OPTARG}"
;;
s )
if [[ "$(awk '{print $1}' /proc/uptime | cut -d '.' -f 1)" -lt "120" ]]; then
if [[ "${OPTARG}" ]]; then
sleep "${OPTARG}"
else
sleep 5
fi
fi
;;
d )
set -x
;;
Expand Down
3 changes: 0 additions & 3 deletions libs/camera-streamer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ function run_ayucamstream() {
# Enable camera-auto_reconnect by default
start_param+=( --camera-auto_reconnect=1 )

# Force camera to be always active by default
start_param+=( --camera-force_active=1 )

# Custom Flag Handling (append to defaults)
if [[ -n "${cstm}" ]]; then
start_param+=( "${cstm}" )
Expand Down
3 changes: 2 additions & 1 deletion libs/messages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ function help_msg {
echo -e "\t crowsnest [Options]"
echo -e "\n\t\t-h Prints this help."
echo -e "\n\t\t-v Prints Version of crowsnest."
echo -e "\n\t\t-c </path/to/configfile>\n\t\t\tPath to your webcam.conf\n"
echo -e "\n\t\t-c </path/to/configfile>\n\t\t\tPath to your webcam.conf"
echo -e "\n\t\t-s <sleep_seconds>\n\t\t\tDelay start \(in seconds\) after boot\n"
}

function deprecated_msg_1 {
Expand Down
52 changes: 40 additions & 12 deletions tools/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -108,6 +123,12 @@ main() {
status_msg "Install environment file ..." "1"
fi

if [[ "$(is_speederpad)" = "1" ]]; then
msg "\nSpeederpad detected!"
msg "Add startup delay to environment file ...\n"
add_sleep_to_crowsnest_env
fi

if install_logrotate_conf; then
status_msg "Install logrotate configuration ..." "0"
else
Expand All @@ -128,9 +149,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

Expand All @@ -140,6 +161,13 @@ main() {
set_gpu_mem
fi

if [[ "$(is_dietpi)" = "1" ]]; then
msg "\nDietPi detected!"
msg "Adjust settings for camera-streamer ...\n"
dietpi_cs_settings
status_msg "Adjust settings for camera-streamer ..." "0"
fi

if [[ "${CROWSNEST_UNATTENDED}" = "0" ]]; then
ask_update_entry
fi
Expand Down
5 changes: 2 additions & 3 deletions tools/libs/build_apps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
106 changes: 106 additions & 0 deletions tools/libs/core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,91 @@ is_raspbian() {
fi
}

is_dietpi() {
if [[ -f /boot/config.txt ]] && [[ -d /boot/dietpi ]]; then
echo "1"
else
echo "0"
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
}

is_speederpad() {
if grep -q "Ubuntu 20.04." /etc/os-release &&
[[ "$(uname -rm)" = "4.9.191 aarch64" ]]; 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
}
Expand Down Expand Up @@ -121,6 +206,15 @@ install_service_file() {
grep -q "${BASE_USER}" "${target_dir}/crowsnest.service" || return 1
}

add_sleep_to_crowsnest_env() {
local service_file
env_file="${CROWSNEST_ENV_PATH}/crowsnest.env"

if [[ -f "${env_file}" ]]; then
sed -i 's/\(CROWSNEST_ARGS="[^"]*\)"/\1 -s"/' "${env_file}"
fi
}

install_env_file() {
local env_file env_target
env_file="${PWD}/resources/crowsnest.env"
Expand Down Expand Up @@ -176,3 +270,15 @@ add_group_video() {
msg "\t==> User ${BASE_USER} is already in group 'video'"
fi
}

dietpi_cs_settings() {
sudo /boot/dietpi/func/dietpi-set_hardware rpi-codec enable
sudo /boot/dietpi/func/dietpi-set_hardware rpi-camera enable

if [[ "$(is_buster)" = "0" ]]; then
if ! grep -q "camera_auto_detect=1" /boot/config.txt; then
msg "\nAdd camera_auto_detect=1 to /boot/config.txt ...\n"
echo "camera_auto_detect=1" >> /boot/config.txt
fi
fi
}
3 changes: 3 additions & 0 deletions tools/libs/messages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions tools/libs/pkglist-rpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit a3fc462

Please sign in to comment.