From 519791e6c1094a53ba4b0459ebab667561732b4f Mon Sep 17 00:00:00 2001 From: zwb <1465302821@qq.com> Date: Tue, 22 Oct 2024 12:08:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20centos.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- centos.sh | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 centos.sh diff --git a/centos.sh b/centos.sh new file mode 100644 index 0000000..b200677 --- /dev/null +++ b/centos.sh @@ -0,0 +1,81 @@ +#!/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 \ No newline at end of file