#!/bin/bash

SELINUX_STATUS=`/usr/sbin/getenforce 2>>/dev/null || echo "Not Installed"`
SELPOLCY_VERSION=`(/usr/bin/checkmodule -V 2>>/dev/null || echo "7+") | sed -e's/.*\-//'`
if [ "${SELINUX_STATUS}" = "Enforcing" -a -x /usr/sbin/semodule ]; then
    case ${SELPOLCY_VERSION} in
	6)
        	TARGET_POLICY="./SELinuxExceptionsv6.pp"
	;;

	*)
        	TARGET_POLICY="./SELinuxExceptions.pp"
	;;
    esac

    echo "Installing SELinux \"CustomPrintDriver\" policy (${SELPOLCY_VERSION})"
    /usr/sbin/semodule -i ${TARGET_POLICY} || echo 'SELinux policy failed to load' 1>> /tmp/PrtDrvInstaller.log 2>>/tmp/PrtDrvInstaller.log
fi
