bugfix: install dhcp

modify dhcp template and don't copy template to /etc/dhcp/ dir

Change-Id: I9293c4bf86636791550ab847fccdeed97319a156
Signed-off-by: baigk <baiguoku@huawei.com>
This commit is contained in:
baigk 2016-02-02 21:15:05 +08:00
parent b3e56b081a
commit be47044989
2 changed files with 49 additions and 6 deletions

View File

@ -77,15 +77,15 @@ sudo cp -rf $DIR/dhcp.template /etc/cobbler/dhcp.template
export netaddr=$(ipcalc $IPADDR $NETMASK -n |cut -f 2 -d '=')
export netprefix=$(ipcalc $IPADDR $NETMASK -p |cut -f 2 -d '=')
export subnet=${netaddr}/${netprefix}
sudo sed -i "s/local-address \$server/local-address $IPADDR/g" /etc/cobbler/dhcp.template
sudo sed -i "s/subnet \$subnet netmask \$netmask/subnet $netaddr netmask $NETMASK/g" /etc/cobbler/dhcp.template
sudo sed -i "s/option routers \$gateway/option routers $OPTION_ROUTER/g" /etc/cobbler/dhcp.template
sudo sed -i "s/option routers \$gateway/option routers $IPADDR/g" /etc/cobbler/dhcp.template
sudo sed -i "s/option subnet-mask \$netmask/option subnet-mask $NETMASK/g" /etc/cobbler/dhcp.template
sudo sed -i "s/option domain-name-servers \$ipaddr/option domain-name-servers $IPADDR/g" /etc/cobbler/dhcp.template
sudo sed -i "s/range dynamic-bootp \$ip_range/range dynamic-bootp $IP_START $IP_END/g" /etc/cobbler/dhcp.template
sudo sed -i "s/local-address \$ipaddr/local-address $IPADDR/g" /etc/cobbler/dhcp.template
sudo sed -i "s/next-server \$next_server/next-server $NEXTSERVER/g" /etc/cobbler/dhcp.template
sudo chmod 644 /etc/cobbler/dhcp.template
sudo cp -f /etc/cobbler/dhcp.template /etc/dhcp/dhcpd.conf
# update tftpd.template
sudo cp -rn /etc/cobbler/tftpd.template /root/backup/cobbler/
@ -168,9 +168,9 @@ sudo systemctl restart httpd.service
sudo systemctl restart cobblerd.service
sudo systemctl restart named.service
sudo systemctl restart xinetd.service
sudo systemctl restart dhcpd.service
sudo sleep 10
sudo cobbler sync
echo "Checking if httpd is running"
sudo systemctl status httpd.service
@ -179,6 +179,7 @@ if [[ "$?" != "0" ]]; then
exit 1
fi
sudo systemctl restart dhcpd.service
echo "Checking if dhcpd is running"
sudo systemctl status dhcpd.service
if [[ "$?" != "0" ]]; then

View File

@ -13,7 +13,7 @@ ddns-update-style interim;
allow booting;
allow bootp;
deny unknown-clients;
local-address $ipaddr;
local-address $server;
log-facility local6;
ignore client-updates;
@ -49,8 +49,50 @@ subnet $subnet netmask $netmask {
}
# group for Cobbler : default
#for dhcp_tag in $dhcp_tags.keys():
## group could be subnet if your dhcp tags line up with your subnets
## or really any valid dhcpd.conf construct ... if you only use the
## default dhcp tag in cobbler, the group block can be deleted for a
## flat configuration
# group for Cobbler DHCP tag: $dhcp_tag
group {
#for mac in $dhcp_tags[$dhcp_tag].keys():
#set iface = $dhcp_tags[$dhcp_tag][$mac]
host $iface.name {
hardware ethernet $mac;
site-option-space "pxelinux";
option pxelinux.magic f1:00:74:7e;
if exists dhcp-parameter-request-list {
# Always send the PXELINUX options (specified in hexadecimal)
option dhcp-parameter-request-list = concat(option dhcp-parameter-request-list,d0,d1,d2,d3);
}
option pxelinux.reboottime 30;
#if $iface.hostname:
option host-name "$iface.hostname";
#end if
#if $iface.netmask:
option subnet-mask $iface.netmask;
#end if
#if $iface.gateway:
option routers $iface.gateway;
#end if
#if $iface.enable_gpxe:
if exists user-class and option user-class = "gPXE" {
filename "http://$cobbler_server/cblr/svc/op/gpxe/system/$iface.owner";
} else if exists user-class and option user-class = "iPXE" {
filename "http://$cobbler_server/cblr/svc/op/gpxe/system/$iface.owner";
} else {
filename "undionly.kpxe";
}
#else
filename "$iface.filename";
#end if
## Cobbler defaults to $next_server, but some users
## may like to use $iface.system.server for proxied setups
next-server $next_server;
## next-server $iface.next_server;
}
#end for
}
#end for