diff options
-rwxr-xr-x | perl-install/standalone/drakTermServ | 86 |
1 files changed, 59 insertions, 27 deletions
diff --git a/perl-install/standalone/drakTermServ b/perl-install/standalone/drakTermServ index b7db294d2..935364216 100755 --- a/perl-install/standalone/drakTermServ +++ b/perl-install/standalone/drakTermServ @@ -46,6 +46,7 @@ my $main_buttons; my $in_wizard = 0; my $config_written = 0; my $clients_set = 0; +my @nothing = (0..10); my $nfs_subnet; my $nfs_mask; @@ -1163,7 +1164,9 @@ sub dhcpd_config() { my @resolve; my %netconfig; my @nservers; - + my $button_msg; + my $new_config = 0; + #- entry boxes for data entry my $box_subnet = new Gtk2::HBox(0,0); my $label_subnet = new Gtk2::Label(N("Subnet:")); @@ -1260,7 +1263,15 @@ sub dhcpd_config() { $entry_name_server1->set_text($nservers[1]); $entry_name_server2->set_text($nservers[2]); $entry_name_server3->set_text($nservers[3]); - + + my @dhcpd = cat_("/etc/dhcpd.conf"); + if (-e "/etc/dhcpd.conf" && @dhcpd[0] !~ /drakTermServ/) { + $button_msg = N("Append TS Includes To Existing Config"); + } else { + $button_msg = N("Write Config"); + $new_config = 1; + } + gtkpack($status_box, $dhcpd_box = gtkpack_(new Gtk2::HBox(1,10), 0, gtkadd(new Gtk2::VBox, @@ -1289,21 +1300,27 @@ sub dhcpd_config() { gtkadd($entry_ip_range_end), ), ), - gtkadd(new Gtk2::HBox), - gtksignal_connect(new Gtk2::Button(N("Write Config")), clicked => - sub { write_dhcpd_config( - $entry_subnet->get_text, - $entry_netmask->get_text, - $entry_routers->get_text, - $entry_subnet_mask->get_text, - $entry_broadcast->get_text, - $entry_domain->get_text, - $entry_name_server1->get_text, - $entry_name_server2->get_text, - $entry_name_server3->get_text, - $entry_ip_range_start->get_text, - $entry_ip_range_end->get_text, - ) }), + gtkadd(new Gtk2::HBox), + gtksignal_connect(new Gtk2::Button($button_msg), clicked => + sub { + if ($new_config == 1) { + write_dhcpd_config("full", + $entry_subnet->get_text, + $entry_netmask->get_text, + $entry_routers->get_text, + $entry_subnet_mask->get_text, + $entry_broadcast->get_text, + $entry_domain->get_text, + $entry_name_server1->get_text, + $entry_name_server2->get_text, + $entry_name_server3->get_text, + $entry_ip_range_start->get_text, + $entry_ip_range_end->get_text) + } else { + write_dhcpd_config("append", @nothing) unless any { /dhcpd.conf.terminal-server/ } @dhcpd; + } + } + ), new Gtk2::HBox(0,10), ), ), @@ -1367,11 +1384,23 @@ sub get_ip_from_sys() { } sub write_dhcpd_config { - my ($subnet, $netmask, $routers, $subnet_mask, $broadcast, $domain, $ns1, $ns2, $ns3, $pool_start, $pool_end) = @_; + my ($mode, $subnet, $netmask, $routers, $subnet_mask, $broadcast, $domain, $ns1, $ns2, $ns3, $pool_start, $pool_end) = @_; + + if ($mode eq "append") { + append_to_file("/etc/dhcpd.conf", qq(include "/etc/dhcpd.conf.terminal-server";\n)); + local *FHANDLE; + open(FHANDLE, "> /etc/dhcpd.conf.terminal-server"); + print FHANDLE qq(# Include Etherboot definitions and defaults\ninclude "/etc/dhcpd.conf.etherboot.include";\n); + print FHANDLE qq(# Include Etherboot default kernel version\ninclude "/etc/dhcpd.conf.etherboot.kernel";\n); + print FHANDLE qq(# Include client machine configurations\ninclude "$client_cfg";\n); + close FHANDLE; + $config_written = 1; + return; + } $nfs_subnet = $subnet; $nfs_mask = $subnet_mask; - + local *FHANDLE; open(FHANDLE, "> /etc/dhcpd.conf"); print FHANDLE "#dhcpd.conf - generated by drakTermServ\n\n"; @@ -1449,17 +1478,19 @@ sub enable_ts { @buff = (); $buff[0] = "Enabling Terminal Server...\n\n"; - $buff[1] = "\tChecking default /etc/dhcpd.conf...\n"; + $buff[1] = "\tChecking default /etc/dhcpd.conf...\n"; my @my_conf = cat_("/etc/dhcpd.conf"); if ($my_conf[0] !~ /drakTermServ/) { - if ($cmd_line == 1) { - print("No /etc/dhcpd.conf built yet - use GUI to create!!\n"); - return; + if (-e "/etc/dhcpd.conf") { + write_dhcpd_config("append", @nothing) if ! any { /dhcpd.conf.terminal-server/ } @my_conf; } else { - $in->ask_warn(N("Error"), N("Need to create /etc/dhcpd.conf first!")); - #$central_widget->destroy; - dhcpd_config(); - return; + if ($cmd_line == 1) { + print("No /etc/dhcpd.conf built yet - use GUI to create!!\n"); + } else { + $in->ask_warn(N("Error"), N("Need to create /etc/dhcpd.conf first!")); + dhcpd_config(); + } + return; } } #- suggestion from jmdault - not always needed @@ -1504,6 +1535,7 @@ sub disable_ts { $buff[0] = "Disabling Terminal Server...\n\n"; $buff[1] = "\tRestoring original /etc/dhcpd.conf...\n"; cp_af("/etc/dhcpd.conf.mdkTS", "/etc/dhcpd.conf") if -e "/etc/dhcpd.conf.mdkTS"; + substInFile { s|include "/etc/dhcpd.conf.terminal-server";|| } "/etc/dhcpd.conf"; my $buff_index = toggle_chkconfig("off", "dhcpd", 2); $buff[$buff_index] = "\tRestoring default /etc/exports...\n"; cp_af("/etc/exports.mdkTS", "/etc/exports") if -e "/etc/exports.mdkTS"; |