'How to add a script (bash script) to my linux image developed in yocto?
I develop a script in linux to install packages in a linux image developed in yocto. Currently, I send the .sh script by scp to my device with the linux image, but I want to install directly this script in my linux image and when I boot the device have the .sh file. How can I do this in yocto? I need to create a recipe for this script?
Thanks in advance.
Solution 1:[1]
You should create a recipe and a systemd services to enable it a boot time if you want to. The architecture should be like this:
my_script/
??? files
? ??? my_script.service
? ??? my_script.sh
??? my_recipe.bb
Your recipe should look like this,
my_recipe.bb:
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""
SRC_URI = "file://myscript.service"
SRC_URI += "file://myscript.sh"
inherit systemd
do_install() {
install -Dm0755 ${WORKDIR}/my_script.sh ${D}/usr/bin/my_script.sh
install -Dm0644 ${WORKDIR}/my_script.service ${D}${systemd_system_unitdir}/my_script.service
}
SYSTEMD_SERVICE_${PN} = "my_script.service"
Of course, this should be in a meta-layer that is already in your conf/bblayers.conf Otherwise create it and add it manually.
Solution 2:[2]
@amolina I guess you need add your shell script to /etc/init.d for the purposes of running it on OS boot.
You can inherit update-rc.d class and define INITSCRIPT_NAME/PARAMS in your recipe.
More details can be found in this link yocto manual
Reference : add custom script to yocto
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | amin |
| Solution 2 | Tapan Hegde |
