#!/bin/bash
if [[ "$(whoami)" != "root" ]]; then
echo "please run this script as root ." >&2
exit 1
fi
echo -e "\033[31m 这个是系统初始化脚本,请慎重运行!确定使用请注释指定行 \033[0m"
exit 1;
selinux(){
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
setenforce 0
}
ip(){
sed -i 's/ONBOOT=no/ONBOOT=yes/' /etc/sysconfig/network-scripts/ifcfg-eth0
service network restart > /dev/null
}
zone_time(){
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
/usr/sbin/ntpdate pool.ntp.org
echo '*/5 * * * * /usr/sbin/ntpdate pool.ntp.org > /dev/null 2>&1' > /var/spool/cron/root ; chmod 600 /var/spool/cron/root
/sbin/service crond restart
}
yum_update(){
yum -y install wget
cd /etc/yum .repos.d/
mkdir bak
mv ./*.repo bak
wget -O /etc/yum .repos.d /CentOS-Base .repo http: //mirrors .aliyun.com /repo/Centos-6 .repo
wget -O /etc/yum .repos.d /epel .repo http: //mirrors .aliyun.com /repo/epel-6 .repo
}
iptables(){
iptables -F
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
service iptables save
}
other(){
}
main(){
ip
yum_update
selinux
zone_time
iptables
other
}
main
|