Commit fa68f6da authored by Leigh Stoller's avatar Leigh Stoller

Somewhat simplistic addition to allow a local dhcpd template file

to be inserted into the main template before generating the file config
file. Handy when there are relatively simple local customizations that
are independent of the main template.
parent 01ceaf86
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# Copyright (c) 2000-2015 University of Utah and the Flux Group. # Copyright (c) 2000-2018 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -50,6 +50,7 @@ my $restart = 0; ...@@ -50,6 +50,7 @@ my $restart = 0;
# #
# Configure variables # Configure variables
# #
my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@"; my $TBOPS = "@TBOPSEMAIL@";
my $ELABINELAB = @ELABINELAB@; my $ELABINELAB = @ELABINELAB@;
my $BOSSNODE_IP = "@BOSSNODE_IP@"; my $BOSSNODE_IP = "@BOSSNODE_IP@";
...@@ -242,9 +243,36 @@ while (my %row = $query_result->fetchhash()) { ...@@ -242,9 +243,36 @@ while (my %row = $query_result->fetchhash()) {
} }
} }
#
# First process the template and insert fragments.
#
my @lines = ();
open(IF,"<$template") or open(IF,"<$template") or
fatal("Unable to open $template for reading"); fatal("Unable to open $template for reading");
while (<IF>) { while (<IF>) {
if (/^(\s*)\%\%fragment=([-\w]+)/) {
my $file = "$TB/etc/dhcpd.conf.frag.${2}";
if (! -e $file) {
push(@lines, $1 . "#" . $_);
next;
}
open(FRAG, "$file") or
fatal("Unable to open $file for reading");
while (<FRAG>) {
push(@lines, $1 . $_);
}
close(FRAG);
next;
}
push(@lines, $_);
}
close(IF);
#
# Now run through the updated template lines.
#
foreach (@lines) {
if (/^(\s*)range\s*;/) { if (/^(\s*)range\s*;/) {
# Comment out a null DHCPD_DYNRANGE line. # Comment out a null DHCPD_DYNRANGE line.
my $spaces = $1; my $spaces = $1;
...@@ -531,7 +559,6 @@ while (<IF>) { ...@@ -531,7 +559,6 @@ while (<IF>) {
print $OUT $_; print $OUT $_;
} }
} }
close(IF);
if ($install) { if ($install) {
close(OF) or close(OF) or
......
...@@ -101,6 +101,9 @@ shared-network emulab { ...@@ -101,6 +101,9 @@ shared-network emulab {
} }
} }
# /usr/testbed/etc/dhcpd.conf.frag.one
%%fragment=one
%%management %%management
# #
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment