CentOS-7基础配置脚本

#!/bin/bash

currentTime=$(date +"%Y-%m-%d_%H:%M:%S")

echo "blacklist i2c_piix4"  >> /etc/modprobe.d/blacklist.conf
echo "blacklist pcspkr" >> /etc/modprobe.d/blacklist.conf

sed -i '/SELINUX=enforcing/s/^/#/'  /etc/selinux/config
sed -i '/#SELINUX=enforcing/a SELinux=disabled'  /etc/selinux/config

sed -i '/UseDNS yes/s/^/#/' /etc/ssh/sshd_config
sed -i '/#UseDNS yes/a UseDNS no' /etc/ssh/sshd_config
sed -i '/#UseDNS no/a UseDNS no' /etc/ssh/sshd_config

# firewall-cmd --zone=public --add-port=5432/tcp --permanent
firewall-cmd --reload

systemctl stop postfix
systemctl disable postfix
yum -y remove postfix
mariadb_rpm=$(yum list installed | grep mariadb | awk '{print $1}')
yum -y remove $mariadb_rpm

###yum_conf
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup$currentTime

cat > /etc/yum.repos.d/CentOS-Base.repo << EOF
[base]
name=CentOS-\$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=os
baseurl=https://mirrors.ustc.edu.cn/centos/\$releasever/os/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-\$releasever - Updates
# mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=updates
baseurl=https://mirrors.ustc.edu.cn/centos/\$releasever/updates/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-\$releasever - Extras
# mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=extras
baseurl=https://mirrors.ustc.edu.cn/centos/\$releasever/extras/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-\$releasever - Plus
# mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=centosplus
baseurl=https://mirrors.ustc.edu.cn/centos/\$releasever/centosplus/\$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF

yum makecache
yum -y install java-1.8.0-openjdk
yum -y groupinstall "Development Tools"

posted @ 2019-03-19 13:57  javaite  阅读(211)  评论(0编辑  收藏  举报