Table of Contents

Initialization scripts

Initialization scripts are usually placed in /etc/init.d.

Start and stop functions are usually put in the same script.

Start scripts

Start scripts are executed at boot sequence. This can be used to launch automatically an application at startup. Start scripts are to be placed in directory: /etc/rcU.d (to be executed after all firmware init scripts).
The name of the script must start with letter S and a number between 0 and 99 (example: S01myscript).

Stop scripts

Stop scripts are executed at stop sequence. This can be used to properly stop an application before the shutdown. Stop scripts are to be placed in directory: /etc/rcK.d.
The name of the script must start with letter K and a number between 0 and 99 (example: K01myscript).

Example

For example, the following script, installed in /etc/init.d, will switch on the red backhaul led at startup (on Wirnet iFemtoCell):

switchled
#! /bin/sh
### BEGIN INIT INFO
# Short-Description:    Dummy init script
### END INIT INFO
 
set -e
 
case "$1" in
  start)
	echo -n "Starting Leds: "
        echo "heartbeat" > "/sys/class/leds/led2:red:backhaul/trigger"
	echo "done"
	;;
  stop)
	echo -n "Stopping LED: "
        echo "none" > "/sys/class/leds/led2:red:backhaul/trigger"
	echo "done"
	;;
  restart)
  	$0 stop
	$0 start
	;;
  *)
	echo "Usage: $0 { start | stop | restart }" >&2
	exit 1
	;;
esac
 
exit 0

Then create link in rcK.d and rcU.d directories as below:

ls -l /etc/rcU.d
drwxr-xr-x    2 root     root        4.0K Oct 29 19:44 .
drwxr-xr-x    5 root     root        4.0K Nov 13 14:00 ..
-rwxrwx---    1 root     root        1.0K Nov 24 08:07 S01switchled -> /etc/init.d/switchled
 
ls -l /etc/rcK.d
drwxr-xr-x    2 root     root        4.0K Oct 29 19:44 .
drwxr-xr-x    5 root     root        4.0K Nov 13 14:00 ..
-rwxrwx---    1 root     root        1.0K Nov 24 08:07 K01switchled -> /etc/init.d/switchled

Don't forget to make your script executable with command chmod +x.