Add package to autostart



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?



Yocto docs says that you can use update-rc.d class to add init script. Link:

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

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

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.


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!


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!