Blame SOURCES/selinux-autorelabel-generator.sh

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