How to do it...

When using sysvinit as the initialization manager, Yocto offers the update-rc.d class as a helper to install initialization scripts so that services are started and stopped when needed.

When using this class, you need to specify the INITSCRIPT_NAME variable with the name of the script to install and the INITSCRIPT_PARAMS variable with the options to pass to the update-rc.d utility. You can optionally use the INITSCRIPT_PACKAGES variable to list the packages to contain the initialization scripts. By default, this contains the main package only, and if multiple packages are provided, INITSCRIPT_NAME and INITSCRIPT_PARAMS need to be specified for each using overrides. An example snippet is:

INITSCRIPT_PACKAGES = "${PN}-httpd ${PN}-ftpd" 
INITSCRIPT_NAME_${PN}-httpd = "httpd.sh" 
INITSCRIPT_NAME_${PN}-ftpd = "ftpd.sh" 
INITSCRIPT_PARAMS_${PN}-httpd = "defaults" 
INITSCRIPT_PARAMS_${PN}-ftpd = "start 99 5 2 . stop 20 0 1 6 ." 

When an initialization script is not tied to a particular recipe, we can add a specific recipe for it. For example, the following recipe will run a mount.sh script in the recipes-example/sysvinit-mount/sysvinit-mount_1.0.bb file:

DESCRIPTION = "Initscripts for mounting filesystems" 
LICENSE = "MIT" 
 
LIC_FILES_CHKSUM = 
"file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4
f302" SRC_URI = "file://mount.sh" INITSCRIPT_NAME = "mount.sh" INITSCRIPT_PARAMS = "start 09 S ." inherit update-rc.d S = "${WORKDIR}" do_install () { install -d ${D}${sysconfdir}/init.d/ install -c -m 755 ${WORKDIR}/${INITSCRIPT_NAME} ${D}${sysconfdir}/init.d/${INITSCRIPT_NAME} }

This recipe will install the mount.sh script in the /etc/init.d/ directory and will create all the appropriate symbolic links inside the /etc/rcN.d/ directories.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset