#!/usr/bin/bash
#更改主机名
read -p “1、请输入要设置的主机名:” h
echo “$h” > /etc/hostname
echo -e " 2、关闭防火墙和selinux"
systemctl stop firewalld && systemctl disable firewalld
sed -ri ‘s/^SELINUX=enforcing/SELINUX=disabled/’ /etc/selinux/config
#设置本机/etc/hosts域名解析
read -p “3、请输入要设置的域名:” name
a=ip a | grep 24 | awk '{print $2}'| awk -F/ '{print $1}'
echo “$a $name” >> /etc/hosts
echo “4、正在配置默认源、下载常用命令”
sed -i ‘s/^mirrorlist/#mirrorlist/’ /etc/yum.repos.d/CentOS-Base.repo
sed -i ‘s/^#baseurl/baseurl/’ /etc/yum.repos.d/CentOS-Base.repo
yum -y install vim wget lsof lrzsz bash-completion psmisc lftp tree ntp
read -p “5、是否配置epel源[y/n]:” input
case “$input” in
y)
yum -y install epel-release
sed -i ‘s/^#baseurl/baseurl/’ /etc/yum.repos.d/epel.repo
sed -i ‘s/^metalink/metalink/’ /etc/yum.repos.d/epel.repo
;;
n)
break
esac
echo “6、重新建立缓存”
yum clean all && yum makecache
echo “7、同步时间中…”
ntpdate ntp.sjtu.edu.cn