Blame SOURCES/selinux-autorelabel-generator.sh

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