@xxliixin1993
2016-01-08T03:12:45.000000Z
字数 1176
阅读 1432
linux
#!/bin/bashif [[ "$(whoami)" != "root" ]]; thenecho "please run this script as root ." >&2exit 1fiecho -e "\033[31m 这个是系统初始化脚本,请慎重运行!确定使用请注释指定行 \033[0m"#请注释下一行exit 1;#设置动态ipip(){sed -i 's/ONBOOT=no/ONBOOT=yes/' /etc/sysconfig/network-scripts/ifcfg-eth0service network restart > /dev/null}yum_update(){yum -y install wgetcd /etc/yum.repos.d/mkdir bakmv ./*.repo bakwget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repowget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo# yum clean all && yum makecache# yum -y install vim unzip openssl-client gcc gcc-c++ ntp}#关闭SELINUXselinux(){sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinuxsetenforce 0}#设置时间时区同步zone_time(){rm -rf /etc/localtimeln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime# Update time/usr/sbin/ntpdate pool.ntp.orgecho '*/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}# iptablesiptables(){iptables -Fiptables -P INPUT ACCEPTiptables -P OUTPUT ACCEPTservice iptables save}other(){# initdefault# sed -i 's/^id:.*$/id:3:initdefault:/' /etc/inittab# /sbin/init q}main(){ipyum_updateselinuxzone_timeiptables}main