#!/bin/bash
#
# /etc/hotplug/usb/logitechmouse
#
# Sets up newly plugged-in USB device so that members of the plugdev
# group can access it from userspace.
#
# Note that for this script to work, you'll need all of the following:
# a) a line in the file /etc/hotplug/usb.usermap or another usermap file
#    in /etc/hotplug/usb/ that corresponds to the device you are using.
# b) membership in the plugdev group for all users who intend to use
#    this setup.
# c) a Linux kernel supporting hotplug and usbdevfs
# d) the hotplug package (http://linux-hotplug.sourceforge.net/)
#
# In the usermap file, the first field "usb module" should be named
# "logitechmouse" to invoke this script.

GROUP=plugdev

if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
then
    if getent group $GROUP > /dev/null; then
        chmod 660 "${DEVICE}"
        chown root.$GROUP "${DEVICE}"
    fi
fi
