File: bpudev

package info (click to toggle)
bitpim 1.0.7%2Bdfsg1-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 31,384 kB
  • ctags: 64,877
  • sloc: python: 267,746; cpp: 2,076; perl: 600; ansic: 409; sh: 231; makefile: 142; sed: 1
file content (56 lines) | stat: -rwxr-xr-x 1,416 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
###
### 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}
#

if [ "x$1" = "x--del" ]; then
    action=del
    # Compensate for udev quirkiness
    test -n "$2"  ||  set del "$DEVNAME" "$3" "$4"
    shift
else
    action=add
fi

# udev fires off a whole bunch of devices, most of which we don't need.
# Historically, checking for identical kernel number ($2) and
# SYSFS{devnum} ($3) picked out the right one; however, with recent
# versions of udev that's no longer guaranteed, so it's also necessary
# to allow any nonempty $2 as long as $1 matches /dev/bus/usb/*/*.
case "$1:$2:$3" in
    $1:$3:$2 ) ;;
    /dev/bus/usb/*/*:?*:* ) ;;
    * ) exit 2 ;;
esac

BPUDEV_USER=
BPUDEV_GROUP=
BPUDEV_MODE=0664

if test -r /etc/default/bitpim; then
    . /etc/default/bitpim
fi

if [ "$action" = "add" ]; then
    [ -z "$BPUDEV_USER"  ] || chown "$BPUDEV_USER"  "$1" || true
    [ -z "$BPUDEV_GROUP" ] || chgrp "$BPUDEV_GROUP" "$1" || true
    chmod "$BPUDEV_MODE" "$1" || true
fi

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