Группа :: Система/Основа
Пакет: libifp
Главная Изменения Спек Патчи Исходники Загрузить Gear Bugs and FR Repocop
#!/bin/bash
#
# /sbin/libifp-hotplug
#
# Cloned off the usbcam hotplug script that is shipped by
# Red Hat with gphoto2. In principle we could just call that one,
# but it's ugly to depend on a camera driver in order to talk
# to an audio player...
#
# Sets up newly plugged-in iRiver iFP device so that the user who owns
# the console according to pam_console can access it from user space
#
# Note that for this script to work, you'll need all of the following:
# a) a line in the file /etc/hotplug/usb/libifp.usermap that corresponds
# to the iFP device you are using.
# b) a setup using pam_console creates the respective lock files
# containing the name of the respective user. You can check for that
# by executing "echo `cat /var/{run,lock}/console.lock`" and
# verifying the appropriate user is mentioned somewhere there.
# c) a Linux kernel supporting hotplug and usbdevfs
# d) the hotplug package (http://linux-hotplug.sourceforge.net/)
#
# All of the above are expected to be true on recent Red Hat and Fedora
# distributions in the default install.
#
# In the usermap file, the first field "usb module" should be named
# "libifp" like this script.
#
if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
then
# New code, using lock files instead of copying /dev/console permissions
# This also works with non-gdm logins (e.g. on a virtual terminal)
# Idea and code from Nalin Dahyabhai <nalin@redhat.com>
if [ -f /var/run/console/console.lock ]
then
CONSOLEOWNER=`cat /var/run/console/console.lock`
elif [ -f /var/lock/console.lock ]
then
CONSOLEOWNER=`cat /var/lock/console.lock`
else
CONSOLEOWNER=
fi
if [ -n "$CONSOLEOWNER" ]
then
chmod 0000 "${DEVICE}"
chown "$CONSOLEOWNER" "${DEVICE}"
chmod 0600 "${DEVICE}"
fi
fi