#!/bin/bash
#----------------------系统初始化--------————————————————————————————————————————————#
Systemctlenv() {
startTime=date +%Y%m%d-%H:%M:%S
startTime_s=date +%s
base=/etc/yum.repos.d/CentOS-Base.repo
if [ $base -e ]
then
echo "$base 存在,开始备份 "
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
echo " 文件已备份至/etc/yum.repos.d/CentOS-Base.repo.backup "
elif [ cat /etc/yum.repos.d/CentOS-Base.repo | grep "aliyuncs" ] ;then
echo " 该源已经是aliyuncs "
else
echo " 无法找到/etc/yum.repos.d/CentOS-Base.repo "
fi
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
echo "正在下载新的base源,请勿进行其他操作"
yum makecache
echo "正在进行生成缓存数据"
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
echo "开始安装扩展源"
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo $>/dev/null
echo "正在升级镜像,请勿操作~大致1-3分钟内升级完毕!(如果网络好)"
yum update -y $>/dev/null
echo "恭喜~ yum源配置完毕!"
systemctl stop firewalld.service
systemctl disable firewalld.service
sed -ri '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
echo " firewalld & selinux 均已关闭"
echo "开始执行安装axel"
yum -y install axel &> /dev/null
echo "axel安装完毕 "
endTime=date +%Y%m%d-%H:%M:%S
endTime_s=date +%s
sumTime=$[ $endTime_s - $startTime_s ]
echo "开始执行$startTime ---> 结束执行$endTime" "任务共计耗时:$sumTime s"
}