aboutsummaryrefslogtreecommitdiffstats
path: root/systemd/rhel-autorelabel
diff options
context:
space:
mode:
authorLukas Nykryn <lnykryn@redhat.com>2013-07-12 13:03:45 +0200
committerLukas Nykryn <lnykryn@redhat.com>2013-07-12 13:03:45 +0200
commit7cda43cae585d3a40e0a2d65992388623093e35f (patch)
treee1dcbaabd5c00b05784f8e34e5981415dafcbe16 /systemd/rhel-autorelabel
parent4aa178674056dfc0930ad69dd77ec6490d9c5770 (diff)
downloadinitscripts-7cda43cae585d3a40e0a2d65992388623093e35f.tar
initscripts-7cda43cae585d3a40e0a2d65992388623093e35f.tar.gz
initscripts-7cda43cae585d3a40e0a2d65992388623093e35f.tar.bz2
initscripts-7cda43cae585d3a40e0a2d65992388623093e35f.tar.xz
initscripts-7cda43cae585d3a40e0a2d65992388623093e35f.zip
rename fedora-* to rhel-*
Diffstat (limited to 'systemd/rhel-autorelabel')
-rwxr-xr-xsystemd/rhel-autorelabel41
1 files changed, 41 insertions, 0 deletions
diff --git a/systemd/rhel-autorelabel b/systemd/rhel-autorelabel
new file mode 100755
index 00000000..7cb9b40c
--- /dev/null
+++ b/systemd/rhel-autorelabel
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# Do automatic relabelling
+#
+
+. /etc/init.d/functions
+
+relabel_selinux() {
+ # if /sbin/init is not labeled correctly this process is running in the
+ # wrong context, so a reboot will be required after relabel
+ AUTORELABEL=
+ . /etc/selinux/config
+ echo "0" > /sys/fs/selinux/enforce
+ [ -x /bin/plymouth ] && plymouth --hide-splash
+
+ if [ "$AUTORELABEL" = "0" ]; then
+ echo
+ echo $"*** Warning -- SELinux ${SELINUXTYPE} policy relabel is required. "
+ echo $"*** /etc/selinux/config indicates you want to manually fix labeling"
+ echo $"*** problems. Dropping you to a shell; the system will reboot"
+ echo $"*** when you leave the shell."
+ sulogin
+
+ else
+ echo
+ echo $"*** Warning -- SELinux ${SELINUXTYPE} policy relabel is required."
+ echo $"*** Relabeling could take a very long time, depending on file"
+ echo $"*** system size and speed of hard drives."
+
+ FORCE=`cat /.autorelabel`
+ /sbin/fixfiles $FORCE restore > /dev/null 2>&1
+ fi
+ rm -f /.autorelabel
+ systemctl --force reboot
+}
+
+# Check to see if a full relabel is needed
+if [ "$READONLY" != "yes" ]; then
+ restorecon $(awk '!/^#/ && $4 !~ /noauto/ && $2 ~ /^\// { print $2 }' /etc/fstab) >/dev/null 2>&1
+ relabel_selinux
+fi