How to add a startup script into init.d using Yocto Busybox

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to add a startup script into init.d using Yocto Busybox

7,490 Views
jiye
Contributor V

Hi,

LS1021A

I want to implement a script in the init.d since my distro has a poky-tiny version so there is no systemd, I want to add a script so that my system boots up it will run that script. Where should I save such a script under my build directory?

I am using busybox, should I add it into inittab please help.

Labels (2)
0 Kudos
Reply
4 Replies

7,362 Views
bpe
NXP Employee
NXP Employee


C is not a scripting language. You cannot run a C code directly from a SysV
startup script. If you are using Yocto, create a valid recipe to build your
program and install it, then the binary can be invoked from a startup
script.


Have a great day,
Platon

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

7,362 Views
jiye
Contributor V

Hi bpe,

I did add 

do_compile() {

    ${CC} ${WORKDIR}/myscript.c -o ${WORKDIR}/myscript

}

but after I did this and install the myscript to (this is my busybox recipe file name: busybox.bbapend

do_install_append_mydistro() {
   
    install -D -m 0755 ${WORKDIR}/fstrimsched ${D}${localstatedir}/fstrimsched
    install -D -m 0755 ${WORKDIR}/schedfstrim ${D}${sysconfdir}/init.d/schedfstrim
    ln -sf ${WORKDIR}/schedfstrim ${D}${bindir}/schedfstrim
}     
I got this error :
| sed: can't read busybox.links*: No such file or directory
| WARNING: /localdata/mm_beta_exp/broadband-build/build/tmp/work/armv7ahf-neon-vfpv4-picoos-linux-musleabi/busybox/1.30.1-r0/temp/run.do_install.11616:1 exit 2 from 'sed -i "s:^/bin/:BASE_BINDIR/:" busybox.links*'
MY QUESTION IS do I need to reconfig the busybox to add those files? i did mentiond those new files in         
SRC_URI_append_wl5e="
                             file://myscript \
"
                                                                                                                                                                                                                                                          
0 Kudos
Reply

7,362 Views
bpe
NXP Employee
NXP Employee

Below is the  link to an article that discusses possible ways to run a script
on each boot:

https://www.linux.com/training-tutorials/managing-linux-daemons-init-scripts/

As of the location of the script in your build directory, it can be anywhere,
important only is where your recipe do_install puts it on the target.


Have a great day,
Platon

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply

7,362 Views
jiye
Contributor V

Hi bpe,

Thanks for the reply, what if the file I want to call from init.d is a C file

I can't just put in the start)

section that 

start)

    gcc /home/myscrpt.c -o exe

    /home/exe 

(1)should i still do this in the build ? 

(2) also can I do cp myscrpt /usr/bin as well?

0 Kudos
Reply