Topic: gpsd run at startup

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?

Re: gpsd run at startup

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

1x ASUS WL-700g Encore (Kamikaze 7.09, BCM947xx//953xx [2.4])
1x ASUS WL-500g Premium with Wistron CM9 WiFi card (Kamikaze 7.09, BCM947xx//953xx [2.4])
1x Linksys WRT54GL v1.1 with 512MB MMC card mod, optimized MMC driver (Kamikaze trunk r9548, BCM947xx//953xx [2.4])
NO support via PM.

Re: gpsd run at startup

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 }'`
        }

Re: gpsd run at startup

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.

5 (edited by forum2006 2007-07-30 18:40:26)

Re: gpsd run at startup

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.

1x ASUS WL-700g Encore (Kamikaze 7.09, BCM947xx//953xx [2.4])
1x ASUS WL-500g Premium with Wistron CM9 WiFi card (Kamikaze 7.09, BCM947xx//953xx [2.4])
1x Linksys WRT54GL v1.1 with 512MB MMC card mod, optimized MMC driver (Kamikaze trunk r9548, BCM947xx//953xx [2.4])
NO support via PM.

Re: gpsd run at startup

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?

Re: gpsd run at startup

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 }'`
        }

Re: gpsd run at startup

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.