Add package to autostart


#1

Hi,

I have added/enabled OpenVPN to my Linux Distribution from the OpenEmbedded-Layer. The package created also a file /etc/init.d/openvpn. From there, I can start openvpn with the following command too:

/etc/init.d/openvpn start

But I want OpenVPN to start automatically when the Linux boots up. Does anybody know, how this can be done?

Thanks!


#2

Hi,
Yocto docs says that you can use update-rc.d class to add init script. Link: http://www.yoctoproject.org/docs/1.7.2/mega-manual/mega-manual.html#ref-classes-update-rc.d

Use can try to use it, please write here if you succeed.

But for me it never worked, and I use this workaround:

do_install(){
...
install -d ${D}${sysconfdir}/init.d
install -d ${D}${sysconfdir}/rcS.d
install -d ${D}${sysconfdir}/rc1.d
install -d ${D}${sysconfdir}/rc2.d
install -d ${D}${sysconfdir}/rc3.d
install -d ${D}${sysconfdir}/rc4.d
install -m 0755 ${WORKDIR}/openvpn ${D}${sysconfdir}/init.d/
ln -sf ../init.d/openvpn ${D}${sysconfdir}/rcS.d/S97openvpn
ln -sf ../init.d/openvpn ${D}${sysconfdir}/rcS.d/K97openvpn
ln -sf ../init.d/openvpn ${D}${sysconfdir}/rc1.d/K97openvpn
ln -sf ../init.d/openvpn ${D}${sysconfdir}/rc2.d/K97openvpn
ln -sf ../init.d/openvpn ${D}${sysconfdir}/rc3.d/K97openvpn
ln -sf ../init.d/openvpn ${D}${sysconfdir}/rc4.d/K97openvpn
ln -sf ../init.d/openvpn ${D}${sysconfdir}/rc3.d/S97openvpn
...
}

...

FILES_${PN} += "${sysconfdir}/init.d/*"
FILES_${PN} += "${sysconfdir}/rc*.d/*"

Basically it’s like doing what update-rc.d does manually.


#3

Damn! Thats perfect! It works! Thanks a lot! :slight_smile:
And yes, I tried update-rc.d before, but was also not able to enable autostart for openvpn with that…

Have a nice day!


#4

If you look in the log.do_install you would find some info about why the update-rc.d doesn’t work, but yeah with 1.7 I find this feature flaky at best.
Hopefully they fixed it (or at least improved it) in more recent versions of Yocto.

Thanks for the tip!