Blame SOURCES/selinux-autorelabel-generator.sh

9bbebd
#!/bin/sh
9bbebd
9bbebd
# This systemd.generator(7) detects if SELinux is running and if the
9bbebd
# user requested an autorelabel, and if so sets the default target to
9bbebd
# selinux-autorelabel.target, which will cause the filesystem to be
9bbebd
# relabelled and then the system will reboot again and boot into the
9bbebd
# real default target.
9bbebd
9bbebd
PATH=/usr/sbin:$PATH
9bbebd
unitdir=/usr/lib/systemd/system
9bbebd
9bbebd
# If invoked with no arguments (for testing) write to /tmp.
9bbebd
earlydir="/tmp"
9bbebd
if [ -n "$2" ]; then
9bbebd
    earlydir="$2"
9bbebd
fi
9bbebd
9bbebd
set_target ()
9bbebd
{
9bbebd
    ln -sf "$unitdir/selinux-autorelabel.target" "$earlydir/default.target"
9bbebd
}
9bbebd
9bbebd
if selinuxenabled; then
9bbebd
    if test -f /.autorelabel; then
9bbebd
        set_target
9bbebd
    elif grep -sqE "\bautorelabel\b" /proc/cmdline; then
9bbebd
        set_target
9bbebd
    fi
9bbebd
fi