From 5f758da3f5d29afa1ad2e84a66069b15b3fac23f Mon Sep 17 00:00:00 2001 From: ZhuoQinghui <1302344380@qq.com> Date: Thu, 3 Mar 2022 11:02:49 +0800 Subject: [PATCH] centos-7-init-1.2.sh --- CentOS/7/all/centos-7-init-1.1.sh | 7 -- CentOS/7/all/centos-7-init-1.2.sh | 70 +++++++++++++++++++ .../7/docker/docker-centos-7-install-1.0.sh | 2 +- 3 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 CentOS/7/all/centos-7-init-1.2.sh diff --git a/CentOS/7/all/centos-7-init-1.1.sh b/CentOS/7/all/centos-7-init-1.1.sh index eba954e..24eda82 100644 --- a/CentOS/7/all/centos-7-init-1.1.sh +++ b/CentOS/7/all/centos-7-init-1.1.sh @@ -4,7 +4,6 @@ read -p "是否安装宝塔?(y/n)" isBaota read -p "是否安装Docker?(y/n)" isDocker -read -p "是否安装JDK8?(y/n)" isJDK8 echo "更改YUM为阿里源" @@ -62,9 +61,3 @@ if [ $isJDK8 = "y" ]; then java -version echo "JDK安装完成" fi - -if [ $isBaota = "y" ]; then - echo "安装宝塔" - yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh - echo "宝塔安装完成" -fi diff --git a/CentOS/7/all/centos-7-init-1.2.sh b/CentOS/7/all/centos-7-init-1.2.sh new file mode 100644 index 0000000..eba954e --- /dev/null +++ b/CentOS/7/all/centos-7-init-1.2.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# curl -o init.sh https://git.zykeji.club/open/server-init/raw/master/CentOS/7/all/centos-7-init-1.1.sh && sh init.sh + +read -p "是否安装宝塔?(y/n)" isBaota +read -p "是否安装Docker?(y/n)" isDocker +read -p "是否安装JDK8?(y/n)" isJDK8 + + +echo "更改YUM为阿里源" +mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak +curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo +yum clean all +yum makecache + +echo "安装wget" +yum install -y wget + +echo "安装 net-tools" +yum install -y net-tools + +echo "安装 vim" +yum install -y vim + +echo "升级所有包同时也升级软件和系统内核" +yum -y update + +if [ $isDocker = "y" ]; then + echo "安装Docker" + echo "清除旧版本" + yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine + yum remove docker-ce + echo "安装相关依赖" + yum install -y yum-utils device-mapper-persistent-data lvm2 + echo "配置YUM源加速" + yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo + echo "安装Docker" + yum install -y docker-ce docker-ce-cli containerd.io + echo "启动并设置自启" + systemctl start docker + systemctl enable docker + echo "设置Docker镜像加速" + mkdir -p /etc/docker + tee /etc/docker/daemon.json <<-'EOF' + { + "registry-mirrors": ["https://qu3lgucz.mirror.aliyuncs.com"] + } + EOF + echo "刷新配置" + systemctl daemon-reload + systemctl restart docker + echo "Docker安装完成" +fi + +if [ $isJDK8 = "y" ]; then + echo "安装JDK8" + echo "清除旧版本" + rpm -qa | grep java | xargs rpm -e --nodeps + echo "安装" + yum install java-1.8.0-openjdk* -y + echo "查看JDK版本信息" + java -version + echo "JDK安装完成" +fi + +if [ $isBaota = "y" ]; then + echo "安装宝塔" + yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh + echo "宝塔安装完成" +fi diff --git a/CentOS/7/docker/docker-centos-7-install-1.0.sh b/CentOS/7/docker/docker-centos-7-install-1.0.sh index 1816149..6382dd2 100644 --- a/CentOS/7/docker/docker-centos-7-install-1.0.sh +++ b/CentOS/7/docker/docker-centos-7-install-1.0.sh @@ -1,6 +1,6 @@ #!/bin/bash -# curl -o init.sh https://git.zykeji.club/open/server-init/raw/master/CentOS/7/docker/docker-centos-7-install-1.0.sh && sh init.sh +# curl -o docker-install.sh https://git.zykeji.club/open/server-init/raw/master/CentOS/7/docker/docker-centos-7-install-1.0.sh && sh docker-install.sh echo "安装Docker" echo "清除旧版本"