summaryrefslogtreecommitdiffstats
path: root/recipes-security/selinux/selinux-autorelabel/selinux-autorelabel.sh
blob: 25b692133ada868b38010a96bbc7d0644795c2b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh

/usr/sbin/selinuxenabled 2>/dev/null || exit 0

FIXFILES=/sbin/fixfiles
SETENFORCE=/usr/sbin/setenforce

for i in ${FIXFILES} ${SETENFORCE}; do
	test -x $i && continue
	echo "$i is missing in the system."
	echo "Please add \"selinux=0\" in the kernel command line to disable SELinux."
	exit 1
done

# If /.autorelabel placed, the whole file system should be relabeled
if [ -f /.autorelabel ]; then
	echo "SELinux: /.autorelabel placed, filesystem will be relabeled..."
	${SETENFORCE} 0
	${FIXFILES} -F -f relabel
	/bin/rm -f /.autorelabel
	echo " * Relabel done, rebooting the system."
	/sbin/reboot
fi

exit 0