I'm currently installing dnsmasq with Yocto, but I would like to remove the automatic start.
So I create a .bbappend file and I tried something like :
pkg_postinst_${PN} () {
update-rc.d dnsmasq -f remove
}
But it did not work, I don't know how to proceed to remove this init script with a bbappend file.
Thanks, Pierre-Olivier
bbappend file is to reference a modified version of the startup script to be copied in place of the original without changing the base openembedded-core and/or poky environments.
bbappend file resides in your layer, while the main . bb recipe file to which you are appending Metadata resides in a different layer. Being able to append information to an existing recipe not only avoids duplication, but also automatically applies recipe changes from a different layer into your layer.
The do_install_append function appends the provided block below the metadata already available in the original do_install function. It includes the command needed to copy our new configuration file into the package filesystem.
The correct way to disable a service under SysV is with INITSCRIPT_PARAMS
:
man update-rc.d
A common system administration error is to delete the links with
the thought that this will "disable" the service, i.e., that this
will pre‐ vent the service from being started. However, if all links
have been deleted then the next time the package is upgraded,
the package's postinst script will run update-rc.d again and this
will reinstall links at their factory default locations. The correct
way to disable services is to configure the service as stopped in
all runlevels in which it is started by default. In the System V
init system this means renaming the service's symbolic links from
S to K.
The correct way to disable services is to configure
the service as stopped in all runlevels in which it
is started by default.
But how we can know all runlevels in which a service is started by default?
Well, if "update-rc.d LSB header" does not exist for /etc/init.d/script
(which is the case for NGINX in Yocto - I use it as an example),
then it is simple:
NGINX is described by nginx.inc
file under Yocto meta-openembedded
layer:
meta-openembedded/meta-webserver/recipes-httpd/nginx/nginx.inc
NGINX defines initial scripts as follows in nginx.inc
file:
INITSCRIPT_NAME = "nginx"
INITSCRIPT_PARAMS = "defaults 92 20"
And the resulting service Start/Kill symlinks in Yocto rootfs are:
rootfs/etc/rc0.d/K20nginx -> ../init.d/nginx # Shutdown runlevel
rootfs/etc/rc1.d/K20nginx -> ../init.d/nginx # Single user mode runlevel
rootfs/etc/rc2.d/S92nginx -> ../init.d/nginx
rootfs/etc/rc3.d/S92nginx -> ../init.d/nginx
rootfs/etc/rc4.d/S92nginx -> ../init.d/nginx
rootfs/etc/rc5.d/S92nginx -> ../init.d/nginx
rootfs/etc/rc6.d/K20nginx -> ../init.d/nginx # Reboot runlevel
Also, this is confirmed by the update-rc.d.bbclass
thas executes
update-rc.d
during rootfs creation. So, the way update-rc.d
is
called in meta/classes/update-rc.d.bbclass
file is:
update-rc.d $OPT ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
Bingo!
To disable a service in SysV under Yocto we need to define:
INITSCRIPT_PARAMS = "stop 20 0 1 6 ."
The effective INITSCRIPT_PARAMS
environment variable should
be verified before re-creating rootfs. The proper and simple way
to do it is again using the great bitbake
command:
bitbake nginx -e | grep INITSCRIPT_PARAMS
Now, let's re-create the image (core-image-full-cmdline
in my case):
bitbake core-image-full-cmdline
We can easily see now, that all the remaining Start/Kill symlinks are:
rootfs/etc/rc0.d/K20nginx -> ../init.d/nginx # Shutdown runlevel
rootfs/etc/rc1.d/K20nginx -> ../init.d/nginx # Single user mode runlevel
rootfs/etc/rc6.d/K20nginx -> ../init.d/nginx # Reboot runlevel
Bingo once again!
Several things:
update-rc.d -f dnsmasq remove
(notice that -f
should be in front of name)INITSCRIPT_PARAMS
like INITSCRIPT_PARAMS = "stop 20 0 1 6 ."
?If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With