ext-sources/usbcam
changeset 585 a1d5251a6293
equal deleted inserted replaced
584:72db31faf343 585:a1d5251a6293
       
     1 #!/bin/bash
       
     2 # $Id$
       
     3 #
       
     4 # /etc/hotplug/usb/usbcam
       
     5 #
       
     6 # Sets up newly plugged in USB camera so that the user who owns
       
     7 # the console according to pam_console can access it from user space
       
     8 #
       
     9 # Note that for this script to work, you'll need all of the following:
       
    10 # a) a line in the file /etc/hotplug/usermap that corresponds to the 
       
    11 #    camera you are using. You can get the correct lines for all cameras 
       
    12 #    supported by gphoto2 by running "gphoto2 --print-usb-usermap".
       
    13 # b) a setup using pam_console creates the respective lock files
       
    14 #    containing the name of the respective user. You can check for that
       
    15 #    by executing "echo `cat /var/{run,lock}/console.lock`" and 
       
    16 #    verifying the appropriate user is mentioned somewhere there.
       
    17 # c) a Linux kernel supporting hotplug and usbdevfs
       
    18 # d) the hotplug package (http://linux-hotplug.sourceforge.net/)
       
    19 #
       
    20 # In the usermap file, the first field "usb module" should be named 
       
    21 # "usbcam" like this script.
       
    22 # 
       
    23 
       
    24 if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
       
    25 then
       
    26     # We reference /dev/audio, since we want to have the same permissions
       
    27     chmod 0000 "${DEVICE}"
       
    28     chown --reference=/dev/audio "${DEVICE}"
       
    29     chmod 0600 "${DEVICE}"
       
    30 fi