diff --git a/dhcp-dns/apply.cgi b/dhcp-dns/apply.cgi new file mode 100755 index 000000000..843f7b674 --- /dev/null +++ b/dhcp-dns/apply.cgi @@ -0,0 +1,14 @@ +#!/usr/local/bin/perl +# Apply the current configuration + +require './dhcp-dns-lib.pl'; +&ReadParse(); +&error_setup($text{'apply_err'}); +$err = &apply_configuration(); +if ($err) { + &error($err); + } +else { + &redirect(""); + } + diff --git a/dhcp-dns/delete.cgi b/dhcp-dns/delete.cgi index 11d98ffea..1b6381a12 100644 --- a/dhcp-dns/delete.cgi +++ b/dhcp-dns/delete.cgi @@ -15,7 +15,7 @@ foreach $d (@d) { &dhcpd::save_directive($host->{'parent'}, [ $host ], [ ], $indent); } ($fn, $recs) = &get_dns_zone(); - ($old) = grep { $_->{'name'} eq $d.'.' } @$recs; + ($old) = grep { lc($_->{'name'}) eq lc($d).'.' } @$recs; if ($old) { &bind8::delete_record($fn, $old); &bind8::bump_soa_record($fn, $recs); @@ -24,5 +24,4 @@ foreach $d (@d) { # Apply config &flush_file_lines(); -&apply_configuration(); &redirect(""); diff --git a/dhcp-dns/dhcp-dns-lib.pl b/dhcp-dns/dhcp-dns-lib.pl index 8b8b187af..b1fe1fcdb 100644 --- a/dhcp-dns/dhcp-dns-lib.pl +++ b/dhcp-dns/dhcp-dns-lib.pl @@ -112,6 +112,10 @@ else { } $rv .= &ui_table_start($text{'form_header'}, "width=100%", 2); +# Description +$rv .= &ui_table_row($text{'form_comment'}, + &ui_textbox("comment", $host->{'comment'}, 50)); + # Hostname local $short = &short_hostname($h->{'values'}->[0]); local $indom = $new || $short ne $h->{'values'}->[0]; @@ -133,7 +137,7 @@ $rv .= &ui_table_row($text{'form_ip'}, # MAC address local $hard = &dhcpd::find("hardware", $h->{'members'}); -$rv .= &ui_hidden("oldmac", $hard->{'values'}->[0]) if ($hard); +$rv .= &ui_hidden("oldmac", $hard->{'values'}->[1]) if ($hard); $rv .= &ui_table_row($text{'form_mac'}, # &ui_select("media", $hard ? $hard->{'values'}->[0] : "ethernet", # [ [ "ethernet", $text{'form_ethernet'} ], @@ -183,8 +187,11 @@ return ( $fn, \@recs ); sub apply_configuration { -&dhcpd::restart_dhcpd(); -&bind8::restart_bind(); +local $err = &dhcpd::restart_dhcpd(); +return "DHCPD failed : $err" if ($err); +$err = &bind8::restart_bind(); +return "BIND failed : $err" if ($err); +return undef; } 1; diff --git a/dhcp-dns/edit.cgi b/dhcp-dns/edit.cgi new file mode 100644 index 000000000..e512ff36c --- /dev/null +++ b/dhcp-dns/edit.cgi @@ -0,0 +1,13 @@ +#!/usr/local/bin/perl +# Show one existing host + +require './dhcp-dns-lib.pl'; +&ReadParse(); +($host) = grep { $_->{'values'}->[0] eq $in{'host'} } &list_dhcp_hosts(); +$host || &error($text{'edit_egone'}); + +&ui_print_header(undef, $text{'edit_title'}, ""); +print &host_form($host); +&ui_print_footer("", $text{'index_return'}); + + diff --git a/dhcp-dns/index.cgi b/dhcp-dns/index.cgi index 68e245f01..49b54b2de 100644 --- a/dhcp-dns/index.cgi +++ b/dhcp-dns/index.cgi @@ -39,19 +39,36 @@ if (@hosts) { print &ui_links_row(\@links); print &ui_columns_start([ "", $text{'index_host'}, + $text{'index_subnet'}, $text{'index_ip'}, $text{'index_mac'}, + $text{'index_desc'}, ], 100, 0, \@tds); foreach $h (@hosts) { $fixed = &dhcpd::find("fixed-address", $h->{'members'}); $hard = &dhcpd::find("hardware", $h->{'members'}); + my $parentdesc; + my $par = $h->{'parent'}; + if ($par) { + if ($par->{'name'} eq 'subnet') { + $parentdesc = $par->{'values'}->[0]; + } + elsif ($par->{'name'} eq 'group') { + $parentdesc = $par->{'comment'} || 'Group'; + } + elsif ($par->{'name'} eq 'shared-network') { + $parentdesc = $par->{'values'}->[0]; + } + } print &ui_checked_columns_row([ "[0]). - "'>". - &html_escape(&short_hostname($h->{'values'}->[0])). - "", + "'>". + &html_escape(&short_hostname($h->{'values'}->[0])). + "", + $parentdesc, $fixed ? $fixed->{'values'}->[0] : undef, $hard ? $hard->{'values'}->[1] : undef, + &html_escape($h->{'comment'}), ], \@tds, "d", $h->{'values'}->[0]) } print &ui_columns_end(); @@ -63,5 +80,11 @@ else { print &ui_links_row(\@links); } +print "