aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-security/selinux-scripts/selinux-initsh.inc
blob: f6a3d854fbe56f9dcb6459e1f2d460ca0322ce3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
S ?= "${WORKDIR}"
SECTION ?= "base"

# Default is for script name to be the same as the recipe name.
# Script must have .sh suffix.
SELINUX_SCRIPT_SRC ?= "${BPN}"
SELINUX_SCRIPT_DST ?= "${SELINUX_SCRIPT_SRC}"

INITSCRIPT_NAME ?= "${SELINUX_SCRIPT_DST}"
INITSCRIPT_PARAMS ?= "start 00 S ."

CONFFILES:${PN} += "${sysconfdir}/init.d/${SELINUX_SCRIPT_DST}"

PACKAGE_ARCH ?= "${MACHINE_ARCH}"

inherit update-rc.d systemd

SYSTEMD_SERVICE:${PN} = "${SELINUX_SCRIPT_SRC}.service"

FILES:${PN} += "/.autorelabel"

do_install () {
	install -d ${D}${sysconfdir}/init.d/
	install -m 0755 ${WORKDIR}/${SELINUX_SCRIPT_SRC}.sh ${D}${sysconfdir}/init.d/${SELINUX_SCRIPT_DST}
	# Insert the relabelling code which is only needed with sysvinit
	sed -i -e '/HERE/r ${WORKDIR}/${SELINUX_SCRIPT_SRC}.sh.sysvinit' \
	       -e '/.*HERE$/d' -e '/.*Contents.*sysvinit/d' \
	       ${D}${sysconfdir}/init.d/${SELINUX_SCRIPT_DST}

    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
        install -d ${D}${systemd_unitdir}/system
        install -m 0644 ${WORKDIR}/${SELINUX_SCRIPT_SRC}.service ${D}${systemd_unitdir}/system
        install -d ${D}${bindir}
        install -m 0755 ${WORKDIR}/${SELINUX_SCRIPT_SRC}.sh ${D}${bindir}
        sed -i -e '/.*HERE$/d' ${D}${bindir}/${SELINUX_SCRIPT_SRC}.sh
    fi
}

sysroot_stage_all:append () {
	sysroot_stage_dir ${D}${sysconfdir} ${SYSROOT_DESTDIR}${sysconfdir}
}