OpenWrt Forum Archive

Topic: gpsd run at startup

The content of this topic has been archived on 29 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I'm trying to make gpsd run when boot the system.  I'm using Kamikaze 7.07 on an NSLU2 and I can't figure out how to get it to run at startup.  I have made a script using the guidelines in the howtos put in /etc/init.d/.  the script is called gps and I have enabled it with a priority of 99.  So it shows up as S99gps in /etc/rc.d/.  If I do /etc/init.d/gps start after I'm logged in everything works great and the daemon starts, but when I reboot the daemon does not start.  The script is getting executed though, because I have an echo command that updates a text file when it runs.

gpsd is installed on a flash drive using ipkg, and I am using an absolute path in my script to make sure it can find it.

Does anyone know any other way to make it run at boot or do you know why it won't run when I reboot?

Can you post your init script so we can have a look?

I've tried several variations of different sleep times, used the -N & -D flag on gpsd. No luck so far

#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
START=99

boot() {
       sleep 30
          }
start() {
        /opt/usr/sbin/gpsd /dev/ttyUSB0
       }
stop() {
        kill `ps -ef | grep 'gpsd' | awk '{ print $1 }'`
        }

BTW, I tried replacing gpsd with ser2net connecting to /dev/ttyUSB0. again it works manually but not at startup from init script. I'm worried /dev/ttyUSB0 isn't available for some reason at startup. But since this is running at level 99, I'm not sure why this would be the case. The only other thing this high is sysctl which I am unfamiliar with.

blinux wrote:

I'm worried /dev/ttyUSB0 isn't available for some reason at startup. But since this is running at level 99, I'm not sure why this would be the case.

Add a extra line for testing in the start() fuction.

Are you sure you need the boot() function at all?

Try with this:

#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
START=99

start() {
        ls -al /dev/ttyUSB* > /tmp/test.txt
        /opt/usr/sbin/gpsd /dev/ttyUSB0
}

stop() {
        kill `ps -ef | grep 'gpsd' | awk '{ print $1 }'`
}
/etc/init.d/gpsd start
/etc/init.d/gpsd enable

Also make sure the init script is executable.

EDIT: I just saw you're using /opt/. Make sure it's mounted also before the init script is started.

(Last edited by forum2006 on 30 Jul 2007, 18:40)

No I'm not sure the boot() function is required, I was just trying to make things work. I removed it in this case.  I enabled this service & rebooted. /tmp/test.txt exists, but is empty.
Any idea why /dev/ttyUSB0 wouldn't exist yet?

I tried again with the sleep. This time /tmp/test.txt exists and has /dev/ttyUSB0 listed, but gpsd still did not start (ie does not appear in ps -ef). Still works starting manually.
Here's the modified script:
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
START=99

start() {
        sleep 60
        ls -al /dev/ttyUSB* > /tmp/test.txt
        ls -al /opt > /tmp/test2.txt
        ls -al / > /tmp/test3.txt
        /opt/usr/sbin/gpsd /dev/ttyUSB0
       }
stop() {
        kill `ps -ef | grep 'gpsd' | awk '{ print $1 }'`
        }

ok, I've solved my problem. For the curious out there. There is a delay before /dev/ttyUSB0 exists and also a delay before /opt is mounted. A sleep time takes care of that. I was also having an issue with my LD_LIBRARY_PATH. When I added a sleep time & exported the LD_LIBRARY_PATH inside this script then all started working.

The discussion might have continued from here.