#! /bin/bash
#Author: Matt Song
#Date: 2011/04/16
#Variable Setting:
ntpserver=ntp.api.bz
#show variable:
echo "NTP Server: $ntpserver"
#echo "others..."
sleep 1
echo -e "\e[1;32m"
cat << EOF
+--------------------------------------------------------------+
| === Welcome to Centos System init === |
+--------------------------------------------------------------+
+----------------------Author: Matt Song-----------------------+
EOF
echo -e "\e[1;33m"
cat << EOF
+--------------------------------------------------------------+
| === Turning off services === |
+--------------------------------------------------------------+
EOF
for i in `chkconfig --list | grep 3:on | awk '{print $1}'`
do
echo -e "\e[1;33m========== Processing Service: \e[1;31m$i\t\e[1;33m============="
case $i in
sshd | syslog | network | crond | iptables )
echo -e "\e[1;32mSkipping Services: $i"
;;
*)
echo -e "\e[1;31mTurning off $i"
chkconfig $i off
service $i stop
;;
esac
done
echo ""
echo -e "\e[1;31mRunning Services: \e[0m"
chkconfig --list | grep 3:on
# Setting ntpdate's Crontab, Sync at 00:00 everyday
echo -e "\e[1;33m"
cat << EOF
+--------------------------------------------------------------+
| === Setting NTP === |
+--------------------------------------------------------------+
EOF
echo -e "\e[1;31mInstalling NTP...\e[0m"
yum -y install ntp
echo
echo -e "\e[1;32mInstallation finished, Setting NTP..."
echo "00 00 * * * /usr/sbin/ntpdate $ntpserver > /dev/null 2>&1 " >> /var/spool/cron/root
echo -e "\e[1;32mNTP setting is done! below is the crontab list:"
echo -en "\e[0m"; crontab -l
echo ""
echo -e "\e[1;32mAll the Jobs have been Done! :)"
echo -e "\e[0m"