CentOS7 reset脚本,用于初始化新的虚拟机

能用,有待完善

CentOS7测试

哈哈


reset2.0.sh(20190906)


#!/bin/bash
#**************************************************************
#Author:                     28
#QQ:                         599503252
#Date:                       2019-08-01
#FileName:                   reset.sh
#URL:                        https://blog.51cto.com/14012942
#Description:                The test script
#Copyright (C):              2019 Copyright ©  站点名称  版权所有
#************************************************************
#set -e
RED="\033[0;31m"
GREEN="\033[0;32m"
NO_COLOR="\033[0m"

# 修改别名
modify_alias() {
cat >> ~/.bashrc <> /etc/profile.d/env.sh
}

# 安装基本软件
install_software() {
    yum install   gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl  openssl-devel systemd-devel zlib-devel  vim lrzsz tree screen  lsof tcpdump wget  ntpdate net-tools iotop bc  zip unzip nfs-utils -y
}

# 替换yum源
replace_yum() {
    #wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
    #wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
    curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
    yum makecache
}

# vim
# vimrc复制过来
modify_vimrc() {
cat > ~/.vimrc </dev/null' >> /var/spool/cron/root
}

#ssh调优
ssh_adjust(){
    cp /etc/ssh/sshd_config{,_bak}
    sed '/^GSSAPIAuthentication/d' /etc/ssh/sshd_config -i
    sed '/^UseDNS/d' /etc/ssh/sshd_config -i
    echo "GSSAPIAuthentication no" >> /etc/ssh/sshd_config
    echo "UseDNS no" >> /etc/ssh/sshd_config
    systemctl restart sshd
}

#最大文件打开数
limits_tune(){
    echo '
*   soft nofile 128000
*   hard nofile 256000

root soft nofile 128000
root hard nofile 256000
' >> /etc/security/limits.conf
}

main() {
    judge_root
    Check_release
    replace_yum
    install_software
    iptables_selinux_stop
    modify_alias
    modify_vimrc
    timezone_adjust
    time_sync
    limits_tune
    ssh_adjust 
    modify_PS1
    modify_eth_card
    bash_completion
}

main

reset1.0.sh(20190808)


#!/bin/bash
#**************************************************************
#Author:                     28
#QQ:                         599503252
#Date:                       2019-08-01
#FileName:                   reset.sh
#URL:                        https://blog.51cto.com/14012942
#Description:                The test script
#Copyright (C):              2019 Copyright ©  站点名称  版权所有
#************************************************************
#set -e
RED="\033[0;31m"
GREEN="\033[0;32m"
NO_COLOR="\033[0m"

# 修改别名
modify_alias() {
cat >> ~/.bashrc <> /etc/profile.d/env.sh
}

# 安装基本软件
install_software() {
    yum install   gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl  openssl-devel systemd-devel zlib-devel  vim lrzsz tree screen  lsof tcpdump wget  ntpdate net-tools iotop bc  zip unzip nfs-utils -y
}

# 替换yum源
replace_yum() {
    #wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
    #wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
    curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
    yum makecache
}

# vim
# vimrc复制过来
modify_vimrc() {
cat > ~/.vimrc <

你可能感兴趣的:(CentOS7 reset脚本,用于初始化新的虚拟机)