1SUMMARY = "GPIO shutdown bindings for SysV init"
2LICENSE = "GPL-2.0-only"
3LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6"
4
5SRC_URI = "file://bind_gpio_shutdown.tab \
6    file://gpio-shutdown-keymap.sh \
7"
8
9inherit  update-rc.d
10
11INITSCRIPT_NAME = "gpio-shutdown-keymap.sh"
12# Run only once during startup
13INITSCRIPT_PARAMS = "start 99 S ."
14
15do_install() {
16    # The files are only needed if using SysV init.
17    if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
18        install -d ${D}${sysconfdir} \
19            ${D}${sysconfdir}/inittab.d \
20            ${D}${sysconfdir}/init.d
21
22        install -m 0755 ${WORKDIR}/gpio-shutdown-keymap.sh ${D}${sysconfdir}/init.d/
23        install -m 0755 ${WORKDIR}/bind_gpio_shutdown.tab ${D}${sysconfdir}/inittab.d/
24    elif ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
25        # Systemd init does not require any configuration.
26        # Note: cannot have an empty branch, hence the redundant dir install.
27        install -d ${D}${sysconfdir}
28    else
29        bbwarn "Not using sysvinit or systemd. The gpio-shutdown may require additional configuration."
30    fi
31}
32