exit
fi
groupadd -r scanner
usermod -a -G scanner apache
usermod -a -G scanner root
lsusb
read product_ID
echo "SUBSYSTEM==\"usb\", ATTR{idVendor}==\""$vend_ID"\",ATTR{idProduct}==\""$product_ID'", ACTION="add",NAME="bus/usb/$env{BUSNUM}/$env\{DEVNUM\}", GROUP="scanner",OPTIONS+="last_rule"' > /etc/udev/rules.d/22_scanner.rules
echo "Rules created! Please unplug and replug your scanner to finish."
Basically, this makes sure the script is running as root (and becomes root if not), lists the currently attached USB devices, and asks for the vendor and product IDs. It then pastes those into a rule that will work.