Last active
February 24, 2024 16:11
-
-
Save nonkronk/1c871ba07a9419f47a2e30891e709afa to your computer and use it in GitHub Desktop.
Script to auto-update USB path of printer for CUPSD container on UNRAID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# define the name of cupsd container & printer | |
CONTAINER_NAME=cupsd | |
PRINTER_NAME='Seiko Epson Corp. L3110 Series' | |
# get bus and device number for Seiko Epson Corp. L3110 Series | |
bus_and_device=$(lsusb | grep -i "${PRINTER_NAME}" | awk '{print $2, $4}' | tr ':' ' ') | |
# extract bus and device numbers | |
bus_num=$(echo $bus_and_device | cut -d' ' -f1) | |
device_num=$(echo $bus_and_device | cut -d' ' -f2) | |
# generate new path | |
new_path="/dev/bus/usb/${bus_num}/${device_num}" | |
# update the config file | |
sed -i "s@/dev/bus/usb/[0-9]\{3\}/[0-9]\{3\}@${new_path}@g" /boot/config/plugins/dockerMan/templates-user/my-${CONTAINER_NAME}.xml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment