Buildroot-ts Startup Scripts

From Technologic Systems Manuals

From Buildroot the most straightforward way to add an application to startup is to create a startup script. This is an example simple startup script that will toggle the red led on during startup, and off during shutdown. In this case the file is named customstartup, but you can replace this with any application name as well.

Edit the file /etc/init.d/S99customstartup to contain the following. Be sure to set the script as executable!

#! /bin/sh
# /etc/init.d/customstartup

case "$1" in
  start)
    echo 1 > /sys/class/leds/red-led/brightness
    ## If you are launching a daemon or other long running processes
    ## this should be started with
    # nohup /usr/local/bin/yourdaemon &
    ;;
  stop)
    # if you have anything that needs to run on shutdown
    echo 0 > /sys/class/leds/red-led/brightness
    ;;
  *)
    echo "Usage: customstartup start|stop" >&2
    exit 3
    ;;
esac
  
exit 0
Note: The $PATH variable is not set up by default in init scripts so this will either need to be done manually or the full path to your application must be included.

To manually start and stop the script:

/etc/init.d/S99customstartup start
/etc/init.d/S99customstartup stop