diff -r f479c2af0825 tools/examples/vif-nat --- a/tools/examples/vif-nat Thu Jan 10 22:58:05 2008 +0000 +++ b/tools/examples/vif-nat Wed Jan 16 15:04:41 2008 -0700 @@ -34,9 +34,10 @@ then then dhcpd_conf_file=$(find_dhcpd_conf_file) dhcpd_init_file=$(find_dhcpd_init_file) - if [ -z "$dhcpd_conf_file" ] || [ -z "$dhcpd_init_file" ] + dhcpd_arg_file=$(find_dhcpd_arg_file) + if [ -z "$dhcpd_conf_file" ] || [ -z "$dhcpd_init_file" ] || [ -z "$dhcpd_arg_file" ] then - echo 'Failed to find dhcpd configuration or init file.' >&2 + echo 'Failed to find dhcpd configuration or init or args file.' >&2 exit 1 fi fi @@ -88,6 +89,27 @@ then hostname="$hostname-$vifid" fi +dhcparg_remove_entry() +{ + local tmpfile=$(mktemp) + sed -e "s/ *$vif//" "$dhcpd_arg_file" >"$tmpfile" + if diff "$tmpfile" "$dhcpd_arg_file" >/dev/null + then + rm "$tmpfile" + else + mv "$tmpfile" "$dhcpd_arg_file" + fi +} + +dhcparg_add_entry() +{ + dhcparg_remove_entry + local tmpfile=$(mktemp) +# this could use some work to handle more cases +# currently causes problems for "service dhcpd status" + sed -e "s/\(D.*\)$/\1 $vif/" "$dhcpd_arg_file" >"$tmpfile" && + mv "$tmpfile" "$dhcpd_arg_file" +} dhcp_remove_entry() { @@ -99,6 +121,7 @@ dhcp_remove_entry() else mv "$tmpfile" "$dhcpd_conf_file" fi + dhcparg_remove_entry } @@ -109,6 +132,7 @@ dhcp_up() mac=$(xenstore_read "$XENBUS_PATH/mac") echo >>"$dhcpd_conf_file" \ "host $hostname { hardware ethernet $mac; fixed-address $vif_ip; option routers $router_ip; option host-name \"$hostname\"; }" + dhcparg_add_entry release_lock "vif-nat-dhcp" "$dhcpd_init_file" restart || true } diff -r f479c2af0825 tools/examples/xen-network-common.sh --- a/tools/examples/xen-network-common.sh Thu Jan 10 22:58:05 2008 +0000 +++ b/tools/examples/xen-network-common.sh Wed Jan 16 15:04:41 2008 -0700 @@ -87,6 +87,11 @@ find_dhcpd_init_file() find_dhcpd_init_file() { first_file -x /etc/init.d/{dhcp3-server,dhcp,dhcpd} +} + +find_dhcpd_arg_file() +{ + first_file -f /etc/sysconfig/dhcpd } # configure interfaces which act as pure bridge ports: