Commit 780bcd01 authored by Leigh Stoller's avatar Leigh Stoller

Hacky little script (htmlinstall) that runs each html file through a

perl filter (at installation time) to replace hardwired Utah specific
tokens with configured values. Currently:

    s/www\.emulab\.net/www.@OURDOMAIN@/g;
    s/users\.emulab\.net/@USERNODE@/g;
    s/ops\.emulab\.net/@USERNODE@/g;
    s/boss\.emulab\.net/@BOSSNODE@/g;
    s/fs\.emulab\.net/@FSNODE@/g;
    s/(\s+[-\w]+)\.emulab\.net/$1.@OURDOMAIN@/g;
    s/testbed-ops\@emulab\.net/@TBOPSEMAIL@/g;
    if (! $TBMAINSITE) {
	s/testbed-ops\@flux\.utah\.edu/@TBOPSEMAIL@/g;
	s/\@flux\.utah\.edu/\@@OURDOMAIN@/g;
    }

Seems to catch most everything.
parent 5c355251
......@@ -16,6 +16,9 @@ OURDOMAIN = @OURDOMAIN@
CVSSUPPORT = @CVSSUPPORT@
CHATSUPPORT = @CHATSUPPORT@
# Filter program
HTMLINSTALL = $(INSTALL_SBINDIR)/htmlinstall
include $(OBJDIR)/Makeconf
SUBDIRS = garcia-telemetry
......@@ -24,7 +27,8 @@ SUBDIRS = garcia-telemetry
# Force dependencies to make sure configure regenerates if the .in file
# is changed.
#
all: defs.php3 dbdefs.php3 swish.conf websearch xmlrpc.php3 all-subdirs
all: defs.php3 dbdefs.php3 swish.conf websearch htmlinstall xmlrpc.php3 \
all-subdirs
include $(TESTBED_SRCDIR)/GNUmakerules
......@@ -160,7 +164,8 @@ ALLHY = $(notdir $(HYFILES))
ALLSDR = $(notdir $(SDRFILES))
ALLROBO = $(notdir $(ROBOTRACKFILES))
install: $(addprefix $(INSTALL_WWWDIR)/, $(ALLFILES)) \
install: $(addprefix $(INSTALL_SBINDIR)/, htmlinstall) \
$(addprefix $(INSTALL_WWWDIR)/, $(ALLFILES)) \
$(addprefix $(INSTALL_WWWDIR)/floormap/, $(ALLFLOORMAPS)) \
$(addprefix $(INSTALL_WWWDIR)/pix/, $(ALLPIXES)) \
$(addprefix $(INSTALL_WWWDIR)/tutorial/, $(ALLTUTS)) \
......@@ -174,6 +179,7 @@ install: $(addprefix $(INSTALL_WWWDIR)/, $(ALLFILES)) \
$(addprefix $(INSTALL_WWWDIR)/robotrack/, $(ALLROBO)) \
$(addprefix $(INSTALL_WWWDIR)/autostatus-icons/, $(ALLICONS)) \
$(addprefix $(INSTALL_LIBEXECDIR)/, websearch) \
$(addprefix $(INSTALL_SBINDIR)/, htmlinstall) \
$(addprefix $(INSTALL_WWWDIR)/cvsweb/, $(ALLCVSWEB)) \
$(addprefix $(INSTALL_DIR)/opsdir/www/cvsweb/, $(ALLOPSCVSWEB)) \
$(INSTALL_WWWDIR)/doc/LICENSE.txt \
......@@ -199,13 +205,23 @@ boss-install: install
$(INSTALL_WWWDIR)/doc/LICENSE.txt: $(TESTBED_SRCDIR)/LICENSE
@echo "Installing $<"
-mkdir -p $(patsubst %/,%,$(dir $@))
$(INSTALL_DATA) $(subst $$,\$$,$<) $(subst $$,\$$,$@)
$(INSTALL_DATA) $(subst $$,\$$,$<) $(subst $$,\$$,$@)
$(INSTALL_WWWDIR)/%.html: %.html htmlinstall
@echo "Installing $<"
-mkdir -p $(patsubst %/,%,$(dir $@))
$(HTMLINSTALL) $(subst $$,\$$,$<) $(subst $$,\$$,$@)
$(INSTALL_WWWDIR)/%: %
@echo "Installing $<"
-mkdir -p $(patsubst %/,%,$(dir $@))
$(INSTALL_DATA) $(subst $$,\$$,$<) $(subst $$,\$$,$@)
$(INSTALL_DIR)/opsdir/www/%.html: %.html htmlinstall
@echo "Installing $<"
-mkdir -p $(patsubst %/,%,$(dir $@))
$(HTMLINSTALL) $(subst $$,\$$,$<) $(subst $$,\$$,$@)
$(INSTALL_DIR)/opsdir/www/%: %
@echo "Installing $<"
-mkdir -p $(patsubst %/,%,$(dir $@))
......
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
use Getopt::Std;
use File::Basename;
#
# Install html files, filtering local goo (emulab.net to OURDOMAIN).
#
sub usage {
print STDERR "Usage: htmlinstall <src> <target>\n";
exit(-1);
}
my $optlist = "";
#
# Configure variables
#
my $TB = "@prefix@";
my $WWWHOST = "@WWWHOST@";
my $INSTALL = "@INSTALL@ -m 444";
my $tempfile = "/tmp/html.$$";
my $TBMAINSITE = 1;
#
# Hardcoded check against $WWWHOST, to prevent anyone from
# accidentally setting $TBMAINSITE when it should not be
#
if ($WWWHOST ne "www.emulab.net") {
$TBMAINSITE = 0;
}
# un-taint path
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
# Turn off line buffering on output
$| = 1;
usage()
if (@ARGV != 2);
my $source = $ARGV[0];
my $target = $ARGV[1];
#
# Open source file and filter to temporary file, then install.
#
open(IN, $source) or
die("$0: Could not open $source: $!\n");
open(OUT, "> $tempfile") or
die("$0: Could not open $tempfile: $!\n");
while (<IN>) {
s/www\.emulab\.net/www.@OURDOMAIN@/g;
s/users\.emulab\.net/@USERNODE@/g;
s/ops\.emulab\.net/@USERNODE@/g;
s/boss\.emulab\.net/@BOSSNODE@/g;
s/fs\.emulab\.net/@FSNODE@/g;
s/(\s+[-\w]+)\.emulab\.net/$1.@OURDOMAIN@/g;
s/testbed-ops\@emulab\.net/@TBOPSEMAIL@/g;
if (! $TBMAINSITE) {
s/testbed-ops\@flux\.utah\.edu/@TBOPSEMAIL@/g;
s/\@flux\.utah\.edu/\@@OURDOMAIN@/g;
}
print OUT $_;
}
close(IN);
close(OUT);
system("$INSTALL $tempfile $target") == 0
or exit($? >> 8);
exit(0);
#
# Make sure tempfile deleted.
#
END {
my $saved_exitcode = $?;
unlink($tempfile)
if (-e $tempfile);
$? = $saved_exitcode;
}
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