<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.yoctoproject.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Cookbook%3AAppliance%3AStartup_Scripts</id>
	<title>Cookbook:Appliance:Startup Scripts - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.yoctoproject.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Cookbook%3AAppliance%3AStartup_Scripts"/>
	<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Cookbook:Appliance:Startup_Scripts&amp;action=history"/>
	<updated>2026-04-19T04:33:35Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Cookbook:Appliance:Startup_Scripts&amp;diff=4090&amp;oldid=prev</id>
		<title>Keylevel: Created</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Cookbook:Appliance:Startup_Scripts&amp;diff=4090&amp;oldid=prev"/>
		<updated>2011-11-19T00:17:31Z</updated>

		<summary type="html">&lt;p&gt;Created&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;NOTE : THIS IS WORK IN PROGRESS&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This cookbook item explains how to add startup scripts to a Yocto image.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
It is assumed that the following scripts have been written and are to be used by the target:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   startup-script --- A script to run at system boot (e.g. to restore persistent state)&lt;br /&gt;
   run-script     --- A script used to start the main appliance application at runlevel 5&lt;br /&gt;
   support-script --- A support script required by the above&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== BitBake Recipe ==&lt;br /&gt;
&lt;br /&gt;
The addition of the scripts to the image and their interaction with the various &amp;#039;&amp;#039;init&amp;#039;&amp;#039; runlevels is controlled be means of a BitBake recipe. A template is shown below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DESCRIPTON = &amp;quot;Startup scripts&amp;quot;&lt;br /&gt;
LICENSE = &amp;quot;MIT&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Recipe revision - don&amp;#039;t forget to &amp;#039;bump&amp;#039; when a new revision is created !&lt;br /&gt;
PR = &amp;quot;r0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Runtime dependencies&lt;br /&gt;
#&lt;br /&gt;
# Add a line similar to the following to ensure any packages needed for the scripts to run are installed in the image.&lt;br /&gt;
#&lt;br /&gt;
# RDEPENDS_${PN} = &amp;quot;parted&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# SRC_URI specifies the files that are to be used as the scripts.&lt;br /&gt;
#&lt;br /&gt;
# Any valid src_uri format can be used - this example assumes the&lt;br /&gt;
# scripts are stored in the &amp;#039;files&amp;#039; directory below the one in&lt;br /&gt;
# which this file is located.&lt;br /&gt;
#&lt;br /&gt;
SRC_URI = &amp;quot;              \&lt;br /&gt;
   file://startup-script \&lt;br /&gt;
   file://run-script     \&lt;br /&gt;
   file://support-script \&lt;br /&gt;
   &amp;quot;&lt;br /&gt;
&lt;br /&gt;
# This function is responsible for:&lt;br /&gt;
#  1) Ensuring the required directories exist in the image;&lt;br /&gt;
#  2) Installing the scripts in to the image;&lt;br /&gt;
#  3) Creating the desired runlevel links to the scripts.&lt;br /&gt;
#&lt;br /&gt;
do_install() {&lt;br /&gt;
    #&lt;br /&gt;
    # Create directories:&lt;br /&gt;
    #   ${D}${sysconfdir}/init.d - will hold the scripts&lt;br /&gt;
    #   ${D}${sysconfdir}/rcS.d  - will contain a link to the script that runs at startup&lt;br /&gt;
    #   ${D}${sysconfdir}/rc5.d  - will contain a link to the script that runs at runlevel=5&lt;br /&gt;
    #   ${D}${sbindir}           - scripts called by the above&lt;br /&gt;
    #&lt;br /&gt;
    # ${D} is effectively the root directory of the target system.&lt;br /&gt;
    # ${D}${sysconfdir} is where system configuration files are to be stored (e.g. /etc).&lt;br /&gt;
    # ${D}${sbindir} is where executable files are to be stored (e.g. /sbin).&lt;br /&gt;
    #&lt;br /&gt;
    install -d ${D}${sysconfdir}/init.d&lt;br /&gt;
    install -d ${D}${sysconfdir}/rcS.d&lt;br /&gt;
    install -d ${D}${sysconfdir}/rc1.d&lt;br /&gt;
    install -d ${D}${sysconfdir}/rc2.d&lt;br /&gt;
    install -d ${D}${sysconfdir}/rc3.d&lt;br /&gt;
    install -d ${D}${sysconfdir}/rc4.d&lt;br /&gt;
    install -d ${D}${sysconfdir}/rc5.d&lt;br /&gt;
    install -d ${D}${sbindir}&lt;br /&gt;
&lt;br /&gt;
    #&lt;br /&gt;
    # Install files in to the image&lt;br /&gt;
    #&lt;br /&gt;
    # The files fetched via SRC_URI (above) will be in ${WORKDIR}.&lt;br /&gt;
    #&lt;br /&gt;
    install -m 0755 ${WORKDIR}/startup-script  ${D}${sysconfdir}/init.d/&lt;br /&gt;
    install -m 0755 ${WORKDIR}/run-script      ${D}${sysconfdir}/init.d/&lt;br /&gt;
    install -m 0755 ${WORKDIR}/support-script  ${D}${sbindir}/&lt;br /&gt;
&lt;br /&gt;
    #&lt;br /&gt;
    # Symbolic links can also be installed. e.g.&lt;br /&gt;
    #&lt;br /&gt;
    # ln -s support-script-link ${D}${sbindir}/support-script&lt;br /&gt;
&lt;br /&gt;
    #&lt;br /&gt;
    # Create symbolic links from the runlevel directories to the script files.&lt;br /&gt;
    # Links of the form S... and K... mean the script when be called when&lt;br /&gt;
    # entering / exiting the runlevel designated by the containing directory.&lt;br /&gt;
    # For example:&lt;br /&gt;
    #   rc5.d/S90run-script will be called (with %1=&amp;#039;start&amp;#039;) when entering runlevel 5.&lt;br /&gt;
    #   rc5.d/K90run-script will be called (with %1=&amp;#039;stop&amp;#039;) when exiting runlevel 5.&lt;br /&gt;
    #&lt;br /&gt;
    ln -sf ../init.d/startup-script  ${D}${sysconfdir}/rcS.d/S90startup-script&lt;br /&gt;
    ln -sf ../init.d/run-script      ${D}${sysconfdir}/rc1.d/K90run-script&lt;br /&gt;
    ln -sf ../init.d/run-script      ${D}${sysconfdir}/rc2.d/K90run-script&lt;br /&gt;
    ln -sf ../init.d/run-script      ${D}${sysconfdir}/rc3.d/K90run-script&lt;br /&gt;
    ln -sf ../init.d/run-script      ${D}${sysconfdir}/rc4.d/K90run-script&lt;br /&gt;
    ln -sf ../init.d/run-script      ${D}${sysconfdir}/rc5.d/S90run-script&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Keylevel</name></author>
	</entry>
</feed>