From c245e529bec5522fbe7cfa584d2ce4c1437bd3ce Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 9 Jan 2023 09:29:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- os/get-os-init.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/os/get-os-init.sh b/os/get-os-init.sh index 3514b25..ea92c8c 100644 --- a/os/get-os-init.sh +++ b/os/get-os-init.sh @@ -1,5 +1,6 @@ #!/usr/bin/bash +set -e color(){ unset c declare -A c=([Error]=31 [Success]=32 [Warning]=33 [Info]=34) @@ -71,15 +72,17 @@ init(){ color Info "核心品牌 $(grep -E '^model name' /proc/cpuinfo |head -n 1 |awk -F: '{print $2}')" color Info "启动时长 $(uptime |awk -F',' '{print $1}')" color Success "开始配置静态ip" - color Info "修改文件打开数、进程打开数" cat >>/etc/security/limits.conf <> /etc/sysctl.conf + color Success "已经开启系统路由转发" sed -i 's/#UseDNS.*/UseDNS no/' /etc/ssh/sshd_config + color Success "已经优化ssh服务连接速度" static_addr if [ $? -eq 10 ];then color Success "静态ip配置并检测完成" @@ -88,8 +91,11 @@ sed -i 's/#UseDNS.*/UseDNS no/' /etc/ssh/sshd_config fi color Info "正在关闭防火墙、selinux" color Warning "注意,这将降低服务器安全性" - systemctl disable firewalld postfix --now && \ - setenforce 0 ; sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config && \ + systemctl disable firewalld postfix --now + if [ `getenforce` = 'Enforcing' ];then + setenforce 0 + fi + sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config && \ color Success "配置完成" || color Error "配置异常,请检查" color Info "配置yum源, 此操作将备份您的历史源" ping -w 1 -c 1 10.8.161.40 &>/dev/null