master
Your Name 2 years ago
parent 48ee8476ff
commit c245e529be
  1. 12
      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 <<EOF
* soft nofile 65535
* hard nofile 65535
* soft nproc 1024
* hard nproc 1024
EOF
color Success "已经优化系统文件打开数、进程打开数"
echo "net.ipv4.ip_forward=1" >> /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

Loading…
Cancel
Save