CENTOS 6.6 SHELL Initialization Script
This script may be required after CENTOS6.6 is installed. When learning about CENTOS, you can run this script to perform some configuration, which helps you not to be troubled by the yum selinux ip addresses of these firewalls.
#!/bin/bash
# Determine if it is a root user
if
[[
"$(whoami)"
!=
"root"
]];
then
echo
"pleaserunthisscriptasroot."
>&2
exit
1
fi
echo
-e
"\ 033 [31m this is the system initialization script. Please run it with caution! Are you sure you want to annotate the specified row \ 033 [0 m"
# Comment out the next line
exit
1;
# Disable SELINUX
selinux(){
sed
-i
's/SELINUX=enforcing/SELINUX=disabled/g'
/etc/sysconfig/selinux
setenforce0
}
# Setting Dynamic IP addresses
ip(){
sed
-i
's/ONBOOT=no/ONBOOT=yes/'
/etc/sysconfig/network-scripts/ifcfg-eth0
servicenetworkrestart>
/dev/null
}
# Set Time and time zone Synchronization
zone_time(){
rm
-rf
/etc/localtime
ln
-s
/usr/share/zoneinfo/Asia/Shanghai
/etc/localtime
# Update Time
/usr/sbin/ntpdate
pool.ntp.org
echo
'*/5****/usr/sbin/ntpdatepool.ntp.org>/dev/null2>&1'
>
/var/spool/cron/root
;
chmod
600
/var/spool/cron/root
/sbin/service
crondrestart
}
# Configure yum Source
yum_update(){
yum-y
install
wget
cd
/etc/yum
.repos.d/
mkdir
bak
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
}
# Clear iptables rules and disable them
iptables(){
iptables-F
iptables-PINPUTACCEPT
iptables-POUTPUTACCEPT
serviceiptablessave
}
other(){
# Here you can customize the something you want to do
}
main(){
ip
yum_update
selinux
zone_time
iptables
other
}
main