OpenWRT: Start a python script at boot time

The following script will start a python weather parsing script at boot time (that script not included here). Place the script in

/etc/init.d/weather

 

#!/bin/sh /etc/rc.common
# Copyright (C) 2008 OpenWrt.org

START=99
start() {
        sleep 5   # make sure boot process is done, no more console msgs
        echo "Weather VFD App Started"
        . /etc/profile
        echo $PATH
        python /opt/scripts/wunderground_parse.py &
}

START=99 will create an entry in rc.d named S99weather when the script is enabled.

chmod +x /etc/init.d/weather

/etc/init.d/weather enable  #places entry S99weather in /etc/rc.d/

 

The profile command is [dot] [SPACE]/etc/profile. This will invoke the environment variables which otherwise wouldn't be included at boot time. Those variables will include the

LD_LIBRARY_PATH

and other env variables.

This can also be started with /etc/init.d/weather start. You can stop the init script from starting up with 

/etc/init.d/weather disable

You could optionally add other commands to this startup script.

See the entry at the OpenWRT wiki.