码迷,mamicode.com
首页 > 其他好文 > 详细

配置yum源并安装dhcp脚本

时间:2018-07-08 14:44:37      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:echo   else   火墙   exit   镜像   ase   def   router   dhcpd   

执行前提是:
关闭防火墙和selinux
配置好本机IP
配置本地原iso镜像文件
vim /etc/fstab写入:
/dev/cdrom /mnt/cdrom iso9660 defaults loop 0 0


以下是脚本内容:
#!/bin/sh
echo "
  1. install dhcp
  2. configer dhcp
  "

echo "Please input you choice:"
read shu

if [ $shu -eq 1 ]; then
  mkdir /mnt/cdrom
  rm -rf /etc/yum.repos.d/*
  cd /etc/yum.repos.d

touch my.repo
echo "[my_repo]" > /etc/yum.repos.d/my.repo
echo "name=my local repo" >> /etc/yum.repos.d/my.repo
echo "baseurl=file:///mnt/cdrom" >> /etc/yum.repos.d/my.repo
echo "enabled=1" >> /etc/yum.repos.d/my.repo
echo "gpgchech=0" >> /etc/yum.repos.d/my.repo

mount /dev/cdrom /mnt/cdrom -o loop
yum install dhcp -y

elif [ $shu -eq 2 ];then
  echo "please input your subnet:"
read subnet
echo "please input you netmask"
read netmask
echo "subnet $subnet netmask $netmask" >> /etc/dhcp/dhcpd.conf
echo "{" >> /etc/dhcp/dchpd.conf

echo "please input you ip range:"
read range
echo " range $range" >> /etc/dhcp/dhcpd/conf

echo "pkease input your option routers:"
read routers
echo " option routers $routers;" >> /etc/dhcp/dhcpd.conf

echo "default-lease-time:"
read xianzhi
echo "default-lease-time $xianzhi;" >> /etc/dhcp/dhcpd.conf
else
exit
fi

 

配置yum源并安装dhcp脚本

标签:echo   else   火墙   exit   镜像   ase   def   router   dhcpd   

原文地址:https://www.cnblogs.com/fzlsss/p/9279901.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!