#!/bin/sh

DEVCLASS=$1
DEVNAME=$2

case $DEVCLASS in
0)
	case "$DEVNAME" in
	ugen*)
		BUSNAME=$(usbdevs -vv | egrep "Controller|$DEVNAME\$" | grep -B 1 "$DEVNAME\$" | awk -F'[ :]' '/^Controller/ { print $2 }')
		echo $BUSNAME > /var/run/${DEVNAME}.bus
		chown _cups:_saned /dev/${DEVNAME}.* &&
			chmod 660 /dev/${DEVNAME}.*
		chown _cups:_saned $BUSNAME &&
			chmod 660 $BUSNAME
		;;
	esac
	;;
esac
