#!/bin/bash

sed -i "s/#UseDNS yes/UseDNS no/"  /etc/ssh/sshd_config
systemctl restart sshd

CheckAllOs=`cat /etc/os-release | grep ID | sed s/ID=//g | grep -v 'VERSION' | grep -v "ID_LIKE" | sed 's/"//g'`
CheckCent6=`cat /etc/system-release | awk '{print $1}'`

centos6(){
cat > /etc/yum.repos.d/CentOS-Base.repo <<'EOF'
[base]
name=CentOS-6.10 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://vault.centos.org/6.10/os/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-6.10 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://vault.centos.org/6.10/updates/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-6.10 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://vault.centos.org/6.10/extras/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6
EOF

resize2fs /dev/sda1
}

if [ "$CheckCent6" = "CentOS" ] || [ "$CheckAllOs" = "centos" ];then
    checkOsVer=`rpm --eval '%{centos_ver}'`
    case $checkOsVer in
    6)
    centos6
    exit;;

    7)
    centos7
    exit;;

    8)
    centos7
    exit;;

    esac

elif [ "$CheckAllOs" = "debian" ];then
    debian
    exit;

elif [ "$CheckAllOs" = "ubuntu" ];then
    ubuntu
    exit;
else
    echo "No supported OS is found!!!"
fi