I want to execute a script which is present in rootfs everytime system boots to indicate successful update and reset bootloader variables.
For example, the "custom-script" script in present in /etc
as:
/etc
----/init.d
-----------custom-script.sh
The first step I did is to install this script in rootfs of the linux image. I have created a recipe in my custom Yocto layer. meta-custom\recipes-support\images
layer directory is as follows:
.
├── files
│ ├── custom-script.sh
└── core-image-base.bb
The core-image-base.bb is:
DESCRIPTION = "Install script to Rootfs"
SUMMARY = "Install script to Rootfs and run after boot"
LICENSE = "CLOSED"
SRC_URI = "file://custom-script.sh"
do_install_append() {
install -d 644 ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/custom-script.sh ${D}${sysconfdir}/init.d/custom-script.sh
FILES_${PN} = "${sysconfdir}/init.d"
And in the conf/layer.conf
I added IMAGE_INSTALL_append = " core-image-base"
.
Now I want to execute this script every time the linux system boots (afrer successfully loading rootfs). Can someone please help me to accomplish this? As per my understanding, I can use systemd services to do this and this service should be executed each time the system boots. Any help would be much appreciated.
Thanks in advance.
P.S: I am using Ubuntu 20.04 and this is my first time using systemd services in Yocto with Dunfell version.