From 370549c68dd0ff197b9517356cdae191b4be2510 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Tue, 16 Jul 2024 10:10:31 +0300 Subject: [PATCH] Fix webcam to work with /boot/firmware/octopi.txt path #823 https://github.com/guysoft/CustomPiOS/issues/220 --- .../filesystem/home/root/bin/streamer_select | 6 +++- .../octopi/filesystem/home/root/bin/webcamd | 34 +++++++++++-------- .../root/etc/init.d/change_hostname | 8 ++++- .../root/etc/init.d/change_password | 8 ++++- .../root/usr/local/bin/networkcheck | 6 +++- 5 files changed, 44 insertions(+), 18 deletions(-) diff --git a/src/modules/octopi/filesystem/home/root/bin/streamer_select b/src/modules/octopi/filesystem/home/root/bin/streamer_select index 9d965140..3b6662af 100755 --- a/src/modules/octopi/filesystem/home/root/bin/streamer_select +++ b/src/modules/octopi/filesystem/home/root/bin/streamer_select @@ -3,7 +3,11 @@ # Exit on any error. set -e +CONFIG_FILE=/boot/firmware/octopi.txt +# Fallback for older images +if [ ! -f "${CONFIG_FILE}" ] && [ -f "/boot/octopi.txt" ]; then CONFIG_FILE=/boot/octopi.txt +fi MJPEG_TYPE=mjpeg HLS_TYPE=hls MJPEG_SERVICE=webcamd.service @@ -29,4 +33,4 @@ elif [ "${camera_streamer}" = "${HLS_TYPE}" ]; then else echo "Streamer type '${camera_streamer}' is not supported." exit 1 -fi \ No newline at end of file +fi diff --git a/src/modules/octopi/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd index 6185a368..b05f3958 100755 --- a/src/modules/octopi/filesystem/home/root/bin/webcamd +++ b/src/modules/octopi/filesystem/home/root/bin/webcamd @@ -1,29 +1,35 @@ #!/bin/bash -######################################################################## -### DO NOT EDIT THIS FILE TO CHANGE THE CONFIG!!! ### -### ---------------------------------------------------------------- ### -### There is no need to edit this file for changing resolution, ### -### frame rates or any other mjpg-streamer parameters. Please edit ### -### /boot/octopi.txt instead - that's what it's there for! You can ### -### even do this with your Pi powered down by directly accessing the ### -### file when using the SD card as thumb drive in your regular ### -### computer. ### -######################################################################## +############################################################################### +### DO NOT EDIT THIS FILE TO CHANGE THE CONFIG!!! ### +### ----------------------------------------------------------------------- ### +### There is no need to edit this file for changing resolution, ### +### frame rates or any other mjpg-streamer parameters. Please edit ### +### /boot/firmware/octopi.txt instead - that's what it's there for! You can ### +### even do this with your Pi powered down by directly accessing the ### +### file when using the SD card as thumb drive in your regular ### +### computer. ### +############################################################################### MJPGSTREAMER_HOME=/opt/mjpg-streamer MJPGSTREAMER_INPUT_USB="input_uvc.so" MJPGSTREAMER_INPUT_RASPICAM="input_raspicam.so" +CONFIG_FILE=/boot/firmware/octopi.txt +# Fallback for older images +if [ ! -f "${CONFIG_FILE}" ] && [ -f "/boot/octopi.txt" ]; then +CONFIG_FILE=/boot/octopi.txt +fi + brokenfps_usb_devices=("046d:082b" "1908:2310" "0458:708c" "0458:6006" "1e4e:0102" "0471:0311" "038f:6001" "046d:0804" "046d:0994" "0ac8:3450") -config_dir="/boot/octopi.conf.d" +config_dir="${CONFIG_FILE}/octopi.conf.d" echo "Starting up webcamDaemon..." echo "" cfg_files=() -cfg_files+=/boot/octopi.txt +cfg_files+="${CONFIG_FILE}" if [[ -d ${config_dir} ]]; then cfg_files+=( `ls ${config_dir}/*.txt` ) fi @@ -41,7 +47,7 @@ array_assigned_device=() echo "--- Configuration: ----------------------------" for cfg_file in ${cfg_files[@]}; do - # init configuration - DO NOT EDIT, USE /boot/octopi.conf.d/*.txt INSTEAD! + # init configuration - DO NOT EDIT, USE /boot/firmware/octopi.conf.d/*.txt INSTEAD! camera="auto" camera_usb_options="-r 640x480 -f 10" camera_raspi_options="-fps 10" @@ -54,7 +60,7 @@ for cfg_file in ${cfg_files[@]}; do fi usb_options="$camera_usb_options" - # if webcam device is explicitly given in /boot/octopi.txt, save the path of the device + # if webcam device is explicitly given in /boot/firmware/octopi.txt, save the path of the device # to a variable and remove its parameter from usb_options extracted_device=`echo $usb_options | sed 's@.*-d \(/dev/\(video[0-9]\+\|v4l/[^ ]*\)\).*@\1@'` if [ "$extracted_device" != "$usb_options" ] diff --git a/src/modules/octopi/filesystem/root/etc/init.d/change_hostname b/src/modules/octopi/filesystem/root/etc/init.d/change_hostname index 7c5ef568..2eb943d0 100755 --- a/src/modules/octopi/filesystem/root/etc/init.d/change_hostname +++ b/src/modules/octopi/filesystem/root/etc/init.d/change_hostname @@ -11,8 +11,14 @@ . /lib/lsb/init-functions +BOOT_FOLDER=/boot/firmware +# Fallback for older images +if [ ! -f "${CONFIG_FILE}" ] && [ -f "/boot/octopi.txt" ]; then +BOOT_FOLDER=/boot +fi + do_start () { - text_file="/boot/octopi-hostname.txt" + text_file="${BOOT_FOLDER}/octopi-hostname.txt" if [ ! -f "$text_file" ] then exit 0 diff --git a/src/modules/octopi/filesystem/root/etc/init.d/change_password b/src/modules/octopi/filesystem/root/etc/init.d/change_password index 851d3e2b..bcd60409 100755 --- a/src/modules/octopi/filesystem/root/etc/init.d/change_password +++ b/src/modules/octopi/filesystem/root/etc/init.d/change_password @@ -11,8 +11,14 @@ . /lib/lsb/init-functions +BOOT_FOLDER=/boot/firmware +# Fallback for older images +if [ ! -f "${CONFIG_FILE}" ] && [ -f "/boot/octopi.txt" ]; then +BOOT_FOLDER=/boot +fi + do_start () { - text_file="/boot/octopi-password.txt" + text_file="${BOOT_FOLDER}/octopi-password.txt" if [ ! -f "$text_file" ] then exit 0 diff --git a/src/modules/octopi/filesystem/root/usr/local/bin/networkcheck b/src/modules/octopi/filesystem/root/usr/local/bin/networkcheck index a39d5fa4..1ae2b994 100755 --- a/src/modules/octopi/filesystem/root/usr/local/bin/networkcheck +++ b/src/modules/octopi/filesystem/root/usr/local/bin/networkcheck @@ -1,6 +1,10 @@ #!/bin/bash +CONFIG_FILE=/boot/firmware/octopi.txt +# Fallback for older images +if [ ! -f "${CONFIG_FILE}" ] && [ -f "/boot/octopi.txt" ]; then +CONFIG_FILE=/boot/octopi.txt -source /boot/octopi.txt +source "${CONFIG_FILE}" if [ $enable_network_monitor == 1 ] && [ "$destination_host" != "" ]; then