#!/bin/bash
#written by mofansheng@2015-11-03
#system optimization script
#The fllow apply to CentOS 6.x
. /etc/init.d/functions
function check_ok(){
if [ $? -eq 0 ]
then
echo ""
continue
else
echo "pls check error"
exit
fi
}
cat<<EOF
-----------------------------------------------------------------------
| system optimization |
-----------------------------------------------------------------------
EOF
#close unimportant system services
echo "===Close unimportant system services,it will take serval mintinues==="
for s in `chkconfig --list|grep 3:on|awk '{print $1}'|grep -Ev "crond|sshd|sysstat|rsyslog|network"`
do
chkconfig $s off
done
check_ok
action "Close unimportant system services" /bin/true
#close selinux
echo "===close SELINUX==="
if [ `getenforce` != "Disabled" ]
then
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
echo "selinux is disabled,you must reboot!"
else
action "SELINUX is closed" /bin/true
fi
check_ok
action "Close SELINUX" /bin/true