您的位置:首页 > 运维架构 > Linux

Linux System basic setting script

2011-04-17 20:21 453 查看
#! /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"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux 职场 script