585N/A#!/bin/bash
585N/A# $Id$
585N/A#
585N/A# /etc/hotplug/usb/usbcam
585N/A#
585N/A# Sets up newly plugged in USB camera so that the user who owns
585N/A# the console according to pam_console can access it from user space
585N/A#
585N/A# Note that for this script to work, you'll need all of the following:
585N/A# a) a line in the file /etc/hotplug/usermap that corresponds to the
585N/A# camera you are using. You can get the correct lines for all cameras
585N/A# supported by gphoto2 by running "gphoto2 --print-usb-usermap".
585N/A# b) a setup using pam_console creates the respective lock files
585N/A# containing the name of the respective user. You can check for that
585N/A# by executing "echo `cat /var/{run,lock}/console.lock`" and
585N/A# verifying the appropriate user is mentioned somewhere there.
585N/A# c) a Linux kernel supporting hotplug and usbdevfs
585N/A# d) the hotplug package (http://linux-hotplug.sourceforge.net/)
585N/A#
585N/A# In the usermap file, the first field "usb module" should be named
585N/A# "usbcam" like this script.
585N/A#
585N/A
585N/Aif [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
585N/Athen
585N/A # We reference /dev/audio, since we want to have the same permissions
585N/A chmod 0000 "${DEVICE}"
585N/A chown --reference=/dev/audio "${DEVICE}"
585N/A chmod 0600 "${DEVICE}"
585N/Afi