Reset keep-on-in-suspend when stopping the gps
[gregoa/zavai.git] / hooks / gps
1 #!/bin/sh
2 case "$1" in
3         # At the start of zavai
4         status)
5                 if [ `om gps power` = 1 ]
6                 then
7                         if [ `pgrep -c gpsd` != 0 ]
8                         then
9                                 echo on
10                         else
11                                 echo off
12                         fi
13                 else
14                         echo off
15                 fi
16         ;;
17         # When starting the gps
18         start)
19                 old=`om gps --swap power 1`
20                 if [ $old = 0 ]
21                 then
22                         om gps keep-on-in-suspend 1
23                         /etc/init.d/gpsd stop
24                         # TODO: configure to UBX mode
25                         /etc/init.d/gpsd start
26                 fi
27         ;;
28         # When stopping the gps
29         stop)
30                 /etc/init.d/gpsd stop
31                 om gps power 0
32                 om gps keep-on-in-suspend o
33         ;;
34         *)
35                 echo "Usage: $0 {start|stop|status}." >&2
36                 exit 1
37         ;;
38 esac
39
40 exit 0