new_system_set/newset.sh

77 lines
2.1 KiB
Bash

#!/bin/bash
#新系统脚本
#by author of wzj
#2021年8月20日
#####################
#安装基本工具
BASE_INSTALL()
{
echo -e "\033[32m------------------------------------------ 安装基本工具 --------------------------------------------\033[0m"
sleep 1.5
for i in wget
do
yum install -y ${i}
done
}
REPO_REPLACE()
{
echo -e "\033[32m------------------------------------------ 备份旧yum源并导入阿里源 --------------------------------------------\033[0m"
sleep 1.5
DATE=`date +"%Y-%m-%d"`
if [ ! -d /etc/yum.repos.d/bak/${DATE} ];then
mkdir -p /etc/yum.repos.d/bak/${DATE}
fi
for i in `ls /etc/yum.repos.d|grep -v bak`
do
\mv /etc/yum.repos.d/${i} /etc/yum.repos.d/bak/${DATE}
done
wget http://mirrors.aliyun.com/repo/Centos-7.repo -O /etc/yum.repos.d/CentOS-Base.repo
wget http://mirrors.aliyun.com/repo/Centos-7.repo -P /etc/yum.repos.d
wget http://mirrors.aliyun.com/repo/epel-7.repo -P /etc/yum.repos.d/
yum clean all
yum makecache
}
TOOL_INSTALL()
{
echo -e "\033[32m-------------------------------------------- 安装常用工具 --------------------------------------------\033[0m"
sleep 1.5
for TOOL in net-tools lrzsz vim unzip git screen nethogs speedtest-cli lm_sensors
do
echo -e "\033[33m安装${TOOL}...\033[0m"
sleep 1
#rpm -qa|grep ${TOOL} >>/dev/null 2>&1
#if [ $? -ne 0 ];then
yum -y install ${TOOL}
#fi
done
}
FIREWALLD()
{
#echo -e "\033[32m关闭防火墙FIREWALLD\033[0m"
#sleep 1.5
#systemctl disable firewalld
#systemctl stop firewalld
echo -e "\033[32m-------------------------------------------- 下载firewalld简便工具 --------------------------------------------\033[0m"
wget -O /usr/bin/fwd https://mirror.liuyan.wang/shell/fwd.sh && chmod +x /usr/bin/fwd
}
IPTABLES()
{
echo -e "\033[32m-------------------------------------------- 关闭防火墙IPTABLES --------------------------------------------\033[0m"
sleep 1.5
setenforce 0
if [ ! -f /etc/selinux/config.bak ];then
cp -r /etc/selinux/config /etc/selinux/config.bak
fi
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
}
BASE_INSTALL
REPO_REPLACE
TOOL_INSTALL
FIREWALLD
IPTABLES