Skip to content

Latest commit

 

History

History
29 lines (24 loc) · 739 Bytes

selinux-autorelabel-generator.sh

File metadata and controls

29 lines (24 loc) · 739 Bytes
 
Oct 16, 2018
Oct 16, 2018
1
2
3
4
5
6
7
8
9
#!/bin/sh
# This systemd.generator(7) detects if SELinux is running and if the
# user requested an autorelabel, and if so sets the default target to
# selinux-autorelabel.target, which will cause the filesystem to be
# relabelled and then the system will reboot again and boot into the
# real default target.
PATH=/usr/sbin:$PATH
Oct 16, 2018
Oct 16, 2018
10
unitdir=/lib/systemd/system
Oct 16, 2018
Oct 16, 2018
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# If invoked with no arguments (for testing) write to /tmp.
earlydir="/tmp"
if [ -n "$2" ]; then
earlydir="$2"
fi
set_target ()
{
ln -sf "$unitdir/selinux-autorelabel.target" "$earlydir/default.target"
}
if selinuxenabled; then
if test -f /.autorelabel; then
set_target
elif grep -sqE "\bautorelabel\b" /proc/cmdline; then
set_target
fi
fi