jiaoben.txt/centos.sh

81 lines
1.9 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/bash
list(){
echo "--------------------------------------"
echo "------------性能优化工具箱------------"
echo "------------1.更换YUM源---------------"
echo "------------2.关闭防火墙--------------"
echo "------------3.时间同步----------------"
echo "------------4.创建用户----------------"
echo "------------5.安装软件----------------"
echo "------------6.EXIT--------------------"
}
yuan(){
rm -rf /etc/yum.repos.d/*
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo &>/dev/null
curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo &>/dev/null
yum clean all
yum makecache fast
}
fire(){
systemctl stop firewalld
systemctl disable firewalld
setenforce 0 #临时关闭
sed -ri s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config #永久关闭
}
timed(){
rpm -qa |grep ntpdate
if [ $? -eq 0 ];then
ntpdate ntp.aliyun.com
else
yum -y install ntpdate &> /dev/null
ntpdate ntp.aliyun.com
fi
}
user(){
read -p "请输入你要创建的用户名字:" name
useradd $name
userpasswd=`echo $RANDOM`
echo $userpasswd|passwd --stdin $name &>/dev/null
if [ $? -eq 0 ];then
echo "用户名:$name的密码$userpasswd">>/opt/user.txt
echo "用户创建成功"
else
exit
fi
anzhuang(){
yum -y install vim lsof unzip wget &>/dev/null
}
}
while :
do
list
read -p "请输入您的选项:" num
case $num in
1)
yuan
sleep 3
;;
2)
fire
sleep 3
;;
3)
timed
sleep 3
;;
4)
user
sleep 3
;;
5)
anzhuang
sleep 3
;;
6)
exit
;;
*)
echo "请您按要求输入:(12345)"
;;
esac
done