Skip to content

Instantly share code, notes, and snippets.

@nonkronk
Last active February 24, 2024 16:11
Show Gist options
  • Save nonkronk/1c871ba07a9419f47a2e30891e709afa to your computer and use it in GitHub Desktop.
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
#!/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