关闭SElinux应该用用户输入变量做替换,不过这样也好。


==========================================

#!bin/bash
clear
echo "--------------------"
echo -e " \033[34mThis file controls the state of SELinux on the system.\033[0m"
echo -e "\033[33m SELINUX\033[0m = can take one of these three values:"
echo -e "     \033[4me\033[0mnforcing - SELinux security policy is enforced."
echo -e "     \033[4mp\033[0mermissive - SELinux prints warnings instead of enforcing."
echo -e "     \033[4md\033[0misabled - No SELinux policy is loaded."
echo -e " \033[33mSELINUXTYPE\033[0m = can take one of these two values:"
echo -e "     \033[4mt\033[0margeted - Targeted processes are protected,"
echo -e "     \033[4mm\033[0mls - Multi Level Security protection."
echo "--------------------"
echo "Select SElinux mode(e,p,d):"
while :
do
read sel
case $sel in
 "e" | "E")
  selt="SELINUX=enforcig"
  break
 ;;
 "p" | "P")
  selt="SELINUX=permissive"
  break
 ;;
 "d" | "D")
  selt="SELINUX=disabled"
  break
 ;;
 *)
  echo "Re input"
 ;;
esac
done

echo "Select SElinuxtype mode(t,m):"
while :
do
read sele
case $sele in
 "t" | "T")
  selet="SELINUXTYPE=targeted"
  break
 ;;
 "m" | "M")
  selet="SELINUX=mls"
  break
 ;;
 *)
  echo "Re input"
 ;;
esac
done

echo "Press any key to continue...  (Ctrl+c to Exit)"
read -n 1
echo "#SELINUX=enforcig/permissive/disabled" > /etc/sysconfig/selinux
echo $selt >> /etc/sysconfig/selinux
echo "#SELINUX=tmargeted/mls" >> /etc/sysconfig/selinux
echo $selet >> /etc/sysconfig/selinux

echo "------------------------"
sed -n '2p' /etc/sysconfig/selinux
sed -n '4p' /etc/sysconfig/selinux
echo "------------------------"


========================================================

不效率。