meta-agl-bsp: Add reference hardware GPS support
[AGL/meta-agl.git] / meta-agl-bsp / meta-agl-refhw-gen3 / recipes-navigation / gpsd / files / refhw-gpsd-helper.sh.bak
1 #!/bin/sh
2 #
3 # Script to detect AGL Reference Hardware and switch gpdf configuration
4 # as needed.
5 #
6 # NOTE:
7 # For the most part errors are ignored and the script returns
8 # 0/success so gpsd still be started if the script is somehow
9 # run on a board without the expected hardware.
10
11 COMPAT=/sys/firmware/devicetree/base/compatible
12 GPSTTY=/dev/ttySC3
13
14 if [ ! \( -f "$COMPAT" -a -c "$GPSTTY" -a -f /etc/default/gpsd.refhw \) ]; then
15     exit 0
16 fi
17
18 found=false
19 for c in `cat $COMPAT | tr '\0' ' '`; do
20     echo "c = $c"
21     if echo $c | grep -q '^agl,refhw-h3$'; then
22         found=true
23         break
24     fi
25 done
26
27 if $found; then
28     update-alternatives --install /etc/default/gpsd gpsd-defaults /etc/default/gpsd.refhw 20
29 else
30     update-alternatives --remove gpsd-defaults /etc/default/gpsd.refhw
31 fi
32 exit 0