cleanup specfile for packaging
[profile/ivi/gpsd.git] / gpsd.hotplug.wrapper
1 #!/bin/sh
2 #
3 # This file is Copyright (c) 2010 by the GPSD project
4 # BSD terms apply: see the file COPYING in the distribution root for details.
5
6 if [ -r /etc/default/gpsd ]; then
7   . /etc/default/gpsd
8 elif [ -r /etc/sysconfig/gpsd ]; then
9   . /etc/sysconfig/gpsd
10 fi
11
12 if [ -n $GPSD_OPTIONS ]; then
13   export GPSD_OPTIONS
14 fi
15 if [ -n $GPSD_SOCKET ]; then
16   export GPSD_SOCKET
17 fi
18
19 if [ -n $USBAUTO ]; then
20   [ "$USBAUTO" = "true" ] || exit 0
21 fi
22
23 if [ "$ACTION" = "remove" ] ; then
24   if echo $DEVLINKS | grep -q /dev/gps; then
25     exec /lib/udev/gpsd.hotplug "$ACTION" "$DEVNAME"
26   fi
27   exit 0
28 fi
29
30 # This was formerly in /lib/udev/hotplug.functions
31 wait_for_file() {
32     [ -e "$1" ] && return 0
33     local count=0
34     while sleep 1; do
35         count=$(( $count + 1 ))
36          [ -e "$1" ] && return 0
37         if [ $count -gt 60 ]; then
38             return 1
39         fi
40     done
41 }
42
43 # wait for /usr & /var to be mounted
44 wait_for_file /usr/bin/python && \
45 wait_for_file /var/run && \
46   exec /lib/udev/gpsd.hotplug "$ACTION" "$DEVNAME"
47