Blame SOURCES/selinux-autorelabel-generator.sh

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