标签:域名 ges x86 lse pack inux bak out 清除
#!/bin/bash
#挂载yum仓库
read -p "请输入你yum仓库的挂载点: " dir
echo "正在挂载光盘..."
mount | grep -q "/dev/sr0" && umount /dev/sr0
[ -d $dir ] || mkdir $dir
mount /dev/sr0 $dir &> /dev/null
echo "正在修改repo文件..."
cd /etc/yum.repos.d/
[ -d bak ] || mkdir bak
mv *.repo bak
cat << END > local.repo
[xxx]
name=xxx
baseurl=file://$dir
enabled=1
gpgcheck=0
END
echo "正在清除yum缓存..."
yum clean all &> /dev/null
echo "正在建立yum缓存..."
yum makecache &> /dev/null
[ -d $dir/Packages ] && echo "yum构建成功"
#安装DHCP
echo "正在检测本机是否安装dhcp..."
if [ $(rpm -q dhcp ) = "dhcp-4.2.5-58.el7.centos.x86_64" ] &> /dev/null
then echo "dhcp已经安装"
else
echo "将要安装dhcp"
yum -y install dhcp &> /dev/null
if [ $(rpm -q dhcp ) = "dhcp-4.2.5-58.el7.centos.x86_64" ] &> /dev/null
then echo "dhcp安装完成 "
fi
fi
#修改主配置文件
echo "修改主配置文件,请根据提示输入相应内容"
read -p "请输入你要解析的域名(例如crushlinux.com): " abc
read -p "请输入你要分配的网段(例如192.168.12):" ip
read -p "请输入你要分配的ip范围的起止(2-255)(例100 200)):" begin end
read -p "请输入分配的默认时间和最大时间(单位s)(如 600 7200):" lesstime maxtime
cat << END >/etc/dhcp/dhcpd.conf
option domain-name "$abc";
option domain-name-servers 202.106.0.20,8.8.8.8;
default-lease-time $lesstime;
max-lease-time $maxtime;
subnet $ip.0 netmask 255.255.255.0 {
range $ip.$begin $ip.$end;
option routers 192.168.12.2;
}
END
#启动DHCP 设置开机自启
systemctl start dhcpd
systemctl restart dhcpd &> /dev/null
systemctl enable dhcpd &> /dev/null
systemctl status dhcpd | grep running &> /dev/null && echo "dhcp服务已启动"
标签:域名 ges x86 lse pack inux bak out 清除
原文地址:https://www.cnblogs.com/zhiyuan-yu/p/11405054.html