#!/bin/sh -e

MODE=$1
test "$MODE" = "0" && MODE=permissive

CONF=/etc/selinux/config

if [ "$MODE" = "permissive" ]; then
  sed -e "s/^SELINUX=.*$/SELINUX=permissive/" < $CONF > $CONF.new
  echo "Configured permissive mode in $CONF for the next boot."
  echo "This can be overridden by \"enforcing=1\" on the kernel command line."
else
  sed -e "s/^SELINUX=.*$/SELINUX=enforcing/" < $CONF > $CONF.new
  echo "Configured enforcing mode in $CONF for the next boot."
  echo "This can be overridden by \"enforcing=0\" on the kernel command line."
fi
mv $CONF.new $CONF
