CENTOS 6.6初始化SHELL脚本,centos6.6在学习CENTOS的


这个脚本是在刚安装完CENTOS6.6后可能需要进行的操作。在学习CENTOS的时候,可以先运行这个脚本进行一些配置,可以帮助你不会被这些防火墙 yum selinux ip这些困扰。

#!/bin/bash

#判断是不是root用户

if[["$(whoami)"!="root"]];then

echo"pleaserunthisscriptasroot.">&2

exit1

fi

echo-e"33[31m这个是系统初始化脚本,请慎重运行!确定使用请注释指定行33[0m"

#请注释下一行

exit1;

#关闭SELINUX

selinux(){

sed-i's/SELINUX=enforcing/SELINUX=disabled/g'/etc/sysconfig/selinux

setenforce0

}

#设置动态ip

ip(){

sed-i's/ONBOOT=no/ONBOOT=yes/'/etc/sysconfig/network-scripts/ifcfg-eth0

servicenetworkrestart>/dev/null

}

#设置时间时区同步

zone_time(){

rm-rf/etc/localtime

ln-s/usr/share/zoneinfo/Asia/Shanghai/etc/localtime

#更新时间

/usr/sbin/ntpdatepool.ntp.org

echo'*/5****/usr/sbin/ntpdatepool.ntp.org>/dev/null2>&1'>/var/spool/cron/root;chmod600/var/spool/cron/root

/sbin/servicecrondrestart

}

#配置yum源

yum_update(){

yum-yinstallwget

cd/etc/yum.repos.d/

mkdirbak

mv./*.repobak

wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-6.repo

wget-O/etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-6.repo

}

#清空iptables规则并关闭

iptables(){

iptables-F

iptables-PINPUTACCEPT

iptables-POUTPUTACCEPT

serviceiptablessave

}

other(){

#可以在这里定制你想做的something

}

main(){

ip

yum_update

selinux

zone_time

iptables

other

}

main


相关内容

    暂无相关文章