From da7c111950cecd13c59cd8d546ff3b333e4262c3 Mon Sep 17 00:00:00 2001 From: paukstelis Date: Mon, 2 Aug 2021 17:27:06 -0400 Subject: [PATCH] Re-working physical USB address for cameras without serial numbers --- addnew_printer.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/addnew_printer.sh b/addnew_printer.sh index 8a4ebc7..3e53581 100755 --- a/addnew_printer.sh +++ b/addnew_printer.sh @@ -186,12 +186,14 @@ if [[ -n $INSTALL ]]; then counter=0 while [[ -z "$CAM" ]] && [[ $counter -lt 30 ]]; do CAM=$(timeout 1s journalctl -kf | sed -n -e 's/^.*SerialNumber: //p') - TEMPUSBCAM=$(timeout 1s journalctl -kf | sed -n -e 's/^.*uvcvideo \(.*\): tty.*/\1/p') + TEMPUSBCAM=$(timeout 1s journalctl -kf | sed -n -e 's|^.*input:.*/\(.*\)/input/input.*|\1|p') counter=$(( $counter + 1 )) done if [ -z "$CAM" ]; then echo "Camera Serial Number not detected" | log - echo "You will have to use another tool for setting up camera services" | log + echo "Camera will be setup with physical USB address of $TEMPUSBCAM." | log + echo "The camera will have to stay plugged into this location." | log + USBCAM=$TEMPUSBCAM else echo "Camera detected with serial number: $CAM" | log fi @@ -267,9 +269,9 @@ then mv $SCRIPTDIR/cam_$INSTANCE.service /etc/systemd/system/ echo $CAMPORT >> /etc/camera_ports #config.yaml modifications - echo "webcam:" >> $OCTOCONFIG/.$INSTANCE/config.yaml - echo " snapshot: http://localhost:$CAMPORT?action=snapshot" >> $OCTOCONFIG/.$INSTANCE/config.yaml - echo " stream: http://localhost:$CAMPORT?action=stream" >> $OCTOCONFIG/.$INSTANCE/config.yaml + #echo "webcam:" >> $OCTOCONFIG/.$INSTANCE/config.yaml + #echo " snapshot: http://localhost:$CAMPORT?action=snapshot" >> $OCTOCONFIG/.$INSTANCE/config.yaml + #echo " stream: http://localhost:$CAMPORT?action=stream" >> $OCTOCONFIG/.$INSTANCE/config.yaml echo fi #Octobuntu Cameras udev identifier - either Serial number or USB port @@ -278,10 +280,11 @@ then echo SUBSYSTEM==\"video4linux\", ATTRS{serial}==\"$CAM\", ATTR{index}==\"0\", SYMLINK+=\"cam_$INSTANCE\" >> /etc/udev/rules.d/99-octoprint.rules fi - #USB port - #if [ -n "$USBCAM" ]; then - # echo KERNELS==\"$USBCAM\",SUBSYSTEMS==\"video4linux\", ATTR{index}==\"0\", SYMLINK+=\"cam_$INSTANCE\" >> /etc/udev/rules.d/99-octoprint.rules - #fi + #USB port camera + if [ -n "$USBCAM" ]; then + #echo KERNELS==\"$USBCAM\",SUBSYSTEMS==\"video4linux\", ATTR{index}==\"0\", SYMLINK+=\"cam_$INSTANCE\" >> /etc/udev/rules.d/99-octoprint.rules + echo SUBSYSTEM==\"video4linux\",KERNELS==\"$USBCAM\",SUBSYSTEMS==\"usb\",DRIVERS==\"uvcvideo\",SYMLINK+=\"cam_$INSTANCE\" >> /etc/udev/rules.d/99-octoprint.rules + fi #Reset udev udevadm control --reload-rules