#!/bin/bash
###
### BITPIM
###
### Copyright (C) 2007 Joe Pham <djpham@bitpim.org>
###
### This program is free software; you can redistribute it and/or modify
### it under the terms of the BitPim license as detailed in the LICENSE file.
###
### $Id: bpudev 4265 2007-06-05 01:39:10Z djpham $
#
# $1=$DEVNUM
# $2=kernel number
# $3=SYSFS{devnum}
#

# Some basic checking for args
if [ $# -ne 3 ]; then
     exit 1
fi
 
# udev fires off a whole bunch of devices, most of which we don't need.
# By visual inspection, the one that we want has the same Kernel No and
# SYSFS{devnum}.
if [ "$2" != "$3" ]; then
     exit 2
fi

# Change the device file group to "cellusers", if such group exists.
chgrp cellusers "$1" || true
# ensure the proper permission
chmod 0664 "$1" || true

# Notify BitPim that there's a new USB device
if [ ! -d /var/bitpim ]
then
     mkdir /var/bitpim
fi
echo add $1 > /var/bitpim/dnotify.log
