| 1 | #!/bin/sh |
| 2 | |
| 3 | set -eu |
| 4 | |
| 5 | |
| 6 | if [ ! -f /etc/selinux/config ]; then |
| 7 | return |
| 8 | fi |
| 9 | |
| 10 | if ! command -v sefcontext_compile >/dev/null 2>&1; then |
| 11 | echo "Pre-compiled SELinux file contexts not built: sefcontext_compile not found (missing package selinux-utils)" |
| 12 | return |
| 13 | fi |
| 14 | |
| 15 | . /etc/selinux/config |
| 16 | |
| 17 | if [ -z ${SELINUXTYPE+x} ]; then |
| 18 | echo "Pre-compiled SELinux file contexts not built: SELINUXTYPE not defined in /etc/selinux/config" |
| 19 | return |
| 20 | fi |
| 21 | |
| 22 | if [ ! -d "/etc/selinux/$SELINUXTYPE/contexts/files" ]; then |
| 23 | echo "Pre-compiled SELinux file contexts not build: configuration for policy $SELINUXTYPE not found" |
| 24 | return |
| 25 | fi |
| 26 | |
| 27 | if [ -f "/etc/selinux/$SELINUXTYPE/contexts/files/file_contexts" ]; then |
| 28 | sefcontext_compile "/etc/selinux/$SELINUXTYPE/contexts/files/file_contexts" || true |
| 29 | fi |
| 30 | |
| 31 | if [ -f "/etc/selinux/$SELINUXTYPE/contexts/files/file_contexts.homedirs" ]; then |
| 32 | sefcontext_compile "/etc/selinux/$SELINUXTYPE/contexts/files/file_contexts.homedirs" || true |
| 33 | fi |
| 34 | |
| 35 | if [ -f "/etc/selinux/$SELINUXTYPE/contexts/files/file_contexts.local" ]; then |
| 36 | sefcontext_compile "/etc/selinux/$SELINUXTYPE/contexts/files/file_contexts.local" || true |
| 37 | fi |