一键install centos、rhel脚本(简易版)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_34889607/article/details/81567892
#!/bin/bash
# install centos7 or rhel6.5
read -p "please select what version do you want to install, centos7 or rhel6.5: " version
if [ "$version" = "centos7" ]
then
    echo "===*stop firewalld,NetworkManager,selinux*==="
    systemctl stop firewalld
    systemctl disable firewalld
    systemctl stop NetworkManager
    systemctl disable NetworkManager
    setenforce 0
    sed -i '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
    echo "===*mount*==="
    mkdir /mnt/iso
    mount /dev/sr0 /mnt/iso
    echo "mount /dev/sr0 /mnt/iso" >> /etc/rc.d/rc.local
    chmod +x /etc/rc.d/rc.local
    source /etc/rc.d/rc.local
    cat > /etc/yum.repos.d/iso.repo << EOF
[centos7]
name=centos7
baseurl=file:///mnt/iso
enabled=1
gpgcheck=0
EOF
    yum clean all
    yum repolist
    yum install -y vim telnet-server
    echo -e "pts/0\npts/1\pts/2\npts/3" >> /etc/securetty
    systemctl start telnet.socket
    systemctl enable telnet.socket
    cat > ~/.vimrc << EOF
set nu
set ai
set ts=4
set sw=4
EOF
    sed -i '/^root/a\\hy    ALL=(ALL)    ALL' /etc/sudoers
    su - hy
    cat > ~/.vimrc << EOF
set nu
set ai
set ts=4
set sw=4
EOF
    exit
else
    echo "===*stop firewalld,NetworkManager,selinux*==="
    /etc/init.d/iptables stop
    chkconfig iptables off
    /etc/init.d/NetworkManager stop
    chkconfig NetworkManager off
    setenforce 0
    sed -i '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
    echo "===*mount*==="
    mkdir /mnt/iso
    mount /dev/sr0 /mnt/iso
    echo "mount /dev/sr0 /mnt/iso" >> /etc/rc.d/rc.local
    chmod +x /etc/rc.d/rc.local
    source /etc/rc.d/rc.local
    cat > /etc/yum.repos.d/iso.repo << EOF
[rhel6.5]
name=rhel6.5
baseurl=file:///mnt/iso
enabled=1
gpgcheck=0
EOF
    yum clean all
    yum repolist
    echo -e "pts/0\npts/1\pts/2\npts/3" >> /etc/securetty
    cat > ~/.vimrc << EOF
set nu
set ai
set ts=4
set sw=4
EOF
    sed -i '/^root/a\\hy    ALL=(ALL)    ALL' /etc/sudoers
    cp /etc/xinetd.d/telnet{,.bak}
    sed -i 's/yes/no/g' /etc/xinetd.d/telnet
    /etc/init.d/xinetd restart
    chkconfig xinetd on
    su - hy
    cat > ~/.vimrc << EOF
set nu
set ai
set ts=4
set sw=4
EOF
    exit
    #shutdown -h now
fi

参考文档:https://blog.csdn.net/qq_34889607/article/details/81901767

猜你喜欢

转载自blog.csdn.net/qq_34889607/article/details/81567892