blob: 0b9a63686c98fdc4676dee94763b1f658567b6eb [file] [log] [blame]
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "Run gpsd when the system starts"
author "chromium-os-dev@chromium.org"
# Uncomment the next line if to have gpsd start automatically on boot:
#start on stopped boot-complete
env GPS_DEVICE='/dev/ttyUSB2'
env GPSD_PARAMS='-D 1'
pre-start script
GPSD_LOG='/tmp/gpsd.log'
retry=0
exec > "${GPSD_LOG}" 2>&1
check_and_increment_retries() {
local msg="$1"
if [ "${retry}" = "20" ]; then
echo "${msg}"
exit 1
fi
sleep 1
retry=$((retry + 1))
}
while [ ! -e "${GPS_DEVICE}" ]
do
check_and_increment_retries "${GPS_DEVICE} not found"
done
echo "Found ${GPS_DEVICE} after ${retry} seconds"
retry=0
while ! dbus-send --system --print-reply \
--dest=org.chromium.ModemManager /org/chromium/ModemManager/Gobi/0 \
org.chromium.ModemManager.Modem.Gobi.SetAutomaticTracking \
boolean:true boolean:true
do
check_and_increment_retries "dbus-send failed"
done
echo "Dbus succeeded after ${retry} seconds"
echo '$GPS_START' > "${GPS_DEVICE}"
end script
expect fork
exec /usr/sbin/gpsd ${GPSD_PARAMS} "${GPS_DEVICE}"