Initial shell, set SELinux parameters

Source: Internet
Author: User

Turning off SELinux should be replaced with user input variables, but that's fine.


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

#! 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 the These values:"
ECHO-E "\033[4mt\033[0margeted-targeted processes is 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 "------------------------"


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

Not efficient.

Initial shell, set SELinux parameters

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.