Yocto startup scripts sysvinit

From embeddedTS Manuals

Yocto Daisy uses SysVinit by default to control the startup of applications. This handles launching applications and their dependencies. If your application does not use X11 you can create a custom init script to handle launching it. As an example, edit the file /etc/init.d/customstartup to contain this:

 #! /bin/sh
 # /etc/init.d/customstartup
 
 case "$1" in
   start)
     /path/to/your/application
     ## 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
     /path/to/your/shutdown/scripts
     ;;
   *)
     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 make this run during startup and shutdown:

update-rc.d customstartup defaults

To manually start and stop the script:

/etc/init.d/customstartup start
/etc/init.d/customstartup stop

For applications using X11, the xsession script should be customized. The last two lines of /usr/bin/x-session-manager include the window manager and application:

matchbox-terminal&
exec matchbox-window-manager

In this case you would replace matchbox-terminal with the full path to your application.