summaryrefslogtreecommitdiff
path: root/gpsd.hotplug.wrapper
blob: f589d0fe25091cb2d20e2af0f8a7cd6087e1a8d0 (plain)
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
#!/bin/sh
# $Id$

if [ -r /etc/default/gpsd ]; then
  . /etc/default/gpsd

  export GPSD_OPTIONS
  export GPSD_SOCKET

  [ "$USBAUTO" = "true" ] || exit 0
fi

if [ "$ACTION" = "remove" ] ; then
  if echo $DEVLINKS | grep -q /dev/gps; then
    exec /lib/udev/gpsd.hotplug "$ACTION" "$DEVNAME"
  fi
  exit 0
fi

# This was formerly in /lib/udev/hotplug.functions
wait_for_file() {
    [ -e "$1" ] && return 0
    local count=0
    while sleep 1; do
        count=$(( $count + 1 ))
         [ -e "$1" ] && return 0
        if [ $count -gt 60 ]; then
            return 1
        fi
    done
}

# wait for /usr & /var to be mounted
wait_for_file /usr/bin/python && \
wait_for_file /var/run && \
  exec /lib/udev/gpsd.hotplug "$ACTION" "$DEVNAME"