Home | History | Annotate | Download | only in libmtp
      1 #!/bin/sh
      2 # Lifts a plugged in MTP device to user space and
      3 # optionally runs a client program.
      4 # Written by Linus Walleij 2006, based on the "usbcam"
      5 # script by Nalin Dahyabhai.
      6 DEVICEOWNER=root
      7 DEVICEPERMS=666
      8 
      9 # Special quirk for SuSE systems using "resmgr"
     10 # (see http://rechner.lst.de/~okir/resmgr/)
     11 if [ -f /sbin/resmgr ]
     12 then
     13     /sbin/resmgr "${ACTION}" "${DEVICE}" desktop usb
     14     exit 0
     15 fi
     16 
     17 # This is for most other distributions
     18 if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
     19 then
     20     # New code, using lock files instead of copying /dev/console permissions
     21     # This also works with non-gdm logins (e.g. on a virtual terminal)
     22     # Idea and code from Nalin Dahyabhai <nalin (at] redhat.com>
     23     if [ "x$DEVICEOWNER" = "xCONSOLE" ]
     24     then
     25 	if [ -f /var/run/console/console.lock ]
     26 	then
     27 	    DEVICEOWNER=`cat /var/run/console/console.lock`
     28 	elif [ -f /var/run/console.lock ]
     29 	then
     30 	    DEVICEOWNER=`cat /var/run/console.lock`
     31 	elif [ -f /var/lock/console.lock ]
     32 	then
     33 	    DEVICEOWNER=`cat /var/lock/console.lock`
     34 	else
     35 	    DEVICEOWNER="nobody"
     36 	    DEVICEPERMS="666"
     37 	fi
     38     fi
     39     if [ -n "$DEVICEOWNER" ]
     40     then
     41         chmod 0000 "${DEVICE}"
     42         chown "${DEVICEOWNER}" "${DEVICE}"
     43         chmod "${DEVICEPERMS}" "${DEVICE}"
     44     fi
     45 fi
     46