Use custom script to start/stop 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 gpt keep_on_during_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         ;;
33         *)
34                 echo "Usage: $0 {start|stop|status}." >&2
35                 exit 1
36         ;;
37 esac
38
39 exit 0