#!/bin/bash
# $Id: usbcell 3772 2006-12-11 04:45:15Z djpham $
#
# /etc/hotplug/usb/usbcell
#
# Sets up newly plugged in USB cell phone and then notifies BitPim of this
# new device.
#
# 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 
#    phone 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) /etc/hotplug/usb/usbcam script to set the proper permission on the device.
# d) a Linux kernel supporting hotplug and usbdevfs
# e) the hotplug package (http://linux-hotplug.sourceforge.net/)
#
# In the usermap file, the first field "usb module" should be named 
# "usbcell" like this script.
# 
#

logfile='/var/bitpim/dnotify.log'
rm -f "${logfile}"

if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ] && [ -x /etc/hotplug/usb/usbcam ]
then
    /etc/hotplug/usb/usbcam "$@"
    if [ -d /var/bitpim ]
    then
        echo add "${DEVICE}" > "${logfile}"
    fi
fi
