[Fwd: Re: is it possible to make my camera on usb (dev/sda1) to automountwhen i plug it in?]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Around about 05/12/02 11:03, Neil Bird scribbled ...
I'll try to get a copy of my fujicam script, as there's a bit I can't remember the details for: you can set up a 'remove' script that does a umount when you unplug the thing. Works a treat.
Here 'tis (/etc/hotplug/usb/fujicam). Still not tried it under RH8 yet, though (worked under RH7.3, don't expect any problems).

--
[neil@fnx ~]# rm -f .signature
[neil@fnx ~]# ls -l .signature
ls: .signature: No such file or directory
[neil@fnx ~]# exit
#!/bin/bash
# $Id: usbcam.console,v 1.3 2002/05/25 19:38:02 hun Exp $
#
# /etc/hotplug/usb/usbcam
#
# Sets up newly plugged in USB camera 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/usermap that corresponds to the 
#    camera you are using. You can get the correct lines for all cameras 
#    supported by gphoto2 by running "gphoto2 --print-usb-usermap".
# 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/)
#
# In the usermap file, the first field "usb module" should be named 
# "usbcam" like this script.
# 

printenv > /tmp/usb
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.lock ]
    then
        CONSOLEOWNER=`cat /var/run/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

    # Fuji mounting
    if [ "X$REMOVER" != "X" ]; then
        [ -d "/var/run/usb" ] || mkdir /var/run/usb
        echo 'umount /mnt/camera' > $REMOVER
        chmod +x $REMOVER
    fi
    mount /mnt/camera

fi


[Index of Archives]     [Fedora General Discussion]     [Red Hat General Discussion]     [Centos]     [Kernel]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat 9]     [Gimp]     [Yosemite News]

  Powered by Linux