码迷,mamicode.com
首页 > 系统相关 > 详细

初见shell,设置SElinux参数

时间:2016-12-09 01:43:54      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:shell

关闭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 "------------------------"


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

不效率。

初见shell,设置SElinux参数

标签:shell

原文地址:http://codemaid.blog.51cto.com/7331065/1880695

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!