Jump to content

Run on boot / rc.local USB issue


SDFUK

Recommended Posts

Hi,

I've got kismet (the 2013 version in the openwrt repo) and an external USB GPS receiver working just fine on a Pineapple Nano. I've written a little rc.local script to autostart Kismet when the Nano is powered on. Nano is using the latest firmware.

The problem I am having is that the USB devices on the Nano are activated *after* the rc.local script based on my reading of the DMESG logs. When I mean activated, I mean that there is no /dev/ttyUSB0 until after the rc.local script finishes when it appears. However, I need the USB GPS to be active before kismet starts. My hacky /etc/rc.local script to start Kismet is below.

LOG=/tmp/kismet_boot.log
ls -al /dev > $LOG
date >> $LOG
export PATH=/usr/bin/pineapple:/bin:/sbin:/usr/bin:/usr/sbin:/sd/bin:/sd/sbin:/sd/usr/bin:/sd/usr/sbin
export LD_LIBRARY_PATH=/lib:usr/lib:/sd/lib:/sd/usr/lib

if [ -f /etc/run_kismet_on_boot ]; then
        echo "running kismet on boot" >> $LOG
        ls -al /dev >> $LOG
        sleep 90
        echo "back from sleep" >> $LOG
        ls -al /dev >> $LOG
        gpsctl -n /dev/ttyUSB0
        kismet_server --daemonize
else
        echo "not running kismet on boot" >> $LOG
fi
# Enter commands above this line
exit 0

DMESG logs

[   34.110000] br-lan: port 2(wlan0) entered forwarding state
[   36.110000] br-lan: port 2(wlan0) entered forwarding state
[  127.380000] usb 1-1.3: new full-speed USB device number 6 using ehci-platform
[  127.510000] pl2303 1-1.3:1.0: pl2303 converter detected
[  127.520000] usb 1-1.3: pl2303 converter now attached to ttyUSB0

 

If I change the sleep time to a different value X, the USB devices activate exactly X settings later.

 

Any tips on how to resolve this?

 

Thanks

 

 

 

Link to comment
Share on other sites

There are ways to start up a script after a wificard is if-up.d/ but I'm working with debian systemd

 

I'm unsure of the networking services openwrt runs.

 

I think your best bet is to write a small bit at the top of your bash script to check if the device is up. Just keep it simple.

 

until ifconfig|grep pl2301; do

echo 'its up. Run your code now'

done

 

 

Or maybe.

lsusb|grep pl2301

Link to comment
Share on other sites

Thanks for that code snippet, that's going to be really useful.

However, I'm trying it now and now it is just hanging in a deadlock - my theory is still that for some reason the USB is not activated until after the exit 0 in rc.local?

Link to comment
Share on other sites

2 hours ago, SDFUK said:

Thanks for that code snippet, that's going to be really useful.

However, I'm trying it now and now it is just hanging in a deadlock - my theory is still that for some reason the USB is not activated until after the exit 0 in rc.local?

Ill run my commands in rc like this.

.//projrcts/startup.sh &

dmesg > /tmp/dmsg.log &

Exit 0

 

This will start each process at the same time. 

 

Try it.

Link to comment
Share on other sites

why not make it a button script that way once the nano is up and running you just hit the reset button to run the script which will eliminate all this.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...