Commit 4e83629d authored by Leigh Stoller's avatar Leigh Stoller

Finish up genelists for Mac. Added proxy script to handle installing

the new list files the users node, instead of using NFS.
parent 2672877a
......@@ -1019,7 +1019,8 @@ outfiles="$outfiles Makeconf GNUmakefile \
assign/GNUmakefile \
capture/GNUmakefile \
db/GNUmakefile db/nalloc db/nfree db/if2port db/backup \
db/webcontrol db/node_status db/genelists discvr/GNUmakefile \
db/webcontrol db/node_status db/genelists db/genelists.proxy \
discvr/GNUmakefile \
db/libdb.pm db/inuse db/avail db/mac2if db/nodeip db/showgraph \
ipod/GNUmakefile \
lib/GNUmakefile \
......
......@@ -141,7 +141,8 @@ outfiles="$outfiles Makeconf GNUmakefile \
assign/GNUmakefile \
capture/GNUmakefile \
db/GNUmakefile db/nalloc db/nfree db/if2port db/backup \
db/webcontrol db/node_status db/genelists discvr/GNUmakefile \
db/webcontrol db/node_status db/genelists db/genelists.proxy \
discvr/GNUmakefile \
db/libdb.pm db/inuse db/avail db/mac2if db/nodeip db/showgraph \
ipod/GNUmakefile \
lib/GNUmakefile \
......
......@@ -10,12 +10,13 @@ include $(OBJDIR)/Makeconf
BIN_SCRIPTS = mac2if nalloc nfree nodeip
SBIN_SCRIPTS = avail inuse showgraph if2port backup webcontrol node_status \
genelists
genelists genelists.proxy
LIBEXEC_SCRIPTS =
LIB_SCRIPTS = libdb.pm
# Stuff installed on plastic for mere users.
USERBINS = nalloc nfree
# Stuff installed on plastic.
USERBINS = nalloc nfree
USERSBINS = genelists.proxy
#
# Force dependencies on the scripts so that they will be rerun through
......@@ -37,7 +38,7 @@ post-install:
#
# Control node installation (okay, plastic)
#
control-install:
control-install: $(addprefix $(INSTALL_SBINDIR)/, $(USERSBINS))
cd $(INSTALL_BINDIR) && \
list='$(USERBINS)'; for file in $$list; do \
rm -f $$file; \
......
#!/usr/bin/perl -wT
use Fcntl ':flock';
use English;
$ENV{'PATH'} = '@prefix@/sbin:@prefix@/bin:/bin';
sub usage() {
print STDOUT "Usage: genelists\n".
......@@ -14,19 +13,49 @@ my $optlist = "";
my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@";
# Should be configure variable!
my $TBACTIVE = "testbed-active-users-archive\@flux.cs.utah.edu";
my $TBALL = "testbed-users-archive\@flux.cs.utah.edu";
# Note no -n option. We redirect stdin from the new exports file below.
my $SSH = "$TB/bin/sshtb -l root users.emulab.net";
my $PROG = "/usr/testbed/sbin/genelists.proxy";
my $lockfile = "/var/tmp/testbed_genelists_lockfile";
my $tempfile = "/var/tmp/testbed_genelists_tempfile";
my $userlist;
my $d = 0;
if (@ARGV != 0) { usage(); }
$| = 1; # Turn off line buffering on output
#
# Turn off line buffering on output
#
$| = 1;
# Load the Testbed support stuff.
push(@INC, "$TB/lib");
require libdb;
require libtestbed;
#
# We don't want to run this script unless its the real version.
#
if ($EUID != 0) {
die("Must be root! Maybe its a development version?");
}
# XXX Hacky!
#if ($TB ne "/usr/testbed") {
# die("Wrong version. Maybe its a development version?");
#}
#
# un-taint path
#
$ENV{'PATH'} = '/bin:/usr/bin:/usr/sbin:/usr/local/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
if (@ARGV != 0) {
usage();
}
# Set up a mutex so this doesn't get run twice at the same time
open(LOCK, ">>$lockfile") || fatal("Couldn't open $lockfile\n");
......@@ -40,62 +69,71 @@ while (flock(LOCK, LOCK_EX|LOCK_NB) == 0) {
}
foreach my $active ( 0, 1 ) {
if ($active) {
print "Getting Active Users\n" if $d;
# All active users on the testbed
if (! ($query_result =
DBQuery("SELECT DISTINCT u.usr_email from experiments as e ".
"left join proj_memb as p on e.pid=p.pid ".
"left join users as u on u.uid=p.uid ".
"where u.status='active' order by u.usr_email"))
) {
DBFatal("Getting Active Users!");
my $progarg;
if ($active) {
print "Getting Active Users\n" if $d;
# All active users on the testbed
if (! ($query_result =
DBQuery("SELECT DISTINCT u.usr_email from experiments as e ".
"left join proj_memb as p on e.pid=p.pid ".
"left join users as u on u.uid=p.uid ".
"where u.status='active' order by u.usr_email"))) {
DBFatal("Getting Active Users!");
}
$userlist = "$TBOPS\n".
"$TBACTIVE\n";
$progarg = "-active";
}
$userlist =
"$TBOPS\n".
"testbed-active-users-archive\@flux.cs.utah.edu\n";
open(LIST,"> /n/ops/usr/site/lib/lists/testbed-active-users.new") ||
fatal("Couldn't open testbed-active-users: $!\n");
print "Opened testbed-active-users\n" if $d;
} else {
print "Getting All Users\n" if $d;
# All approved users on the testbed
if (!($query_result =
DBQuery("SELECT DISTINCT usr_email FROM users ".
"where status='active' order by usr_email"))
) {
DBFatal("Getting Users!");
else {
print "Getting All Users\n" if $d;
# All approved users on the testbed
if (! ($query_result =
DBQuery("SELECT DISTINCT usr_email FROM users ".
"where status='active' order by usr_email"))) {
DBFatal("Getting Users!");
}
$userlist = "$TBOPS\n".
"$TBALL\n";
$progarg = "-all";
}
$userlist =
"$TBOPS\n".
"testbed-users-archive\@flux.cs.utah.edu\n";
open(LIST,"> /n/ops/usr/site/lib/lists/testbed-users.new") ||
fatal("Couldn't open testbed-users: $!\n");
print "Opened testbed-users list\n" if $d;
}
for ($i = 0; $i < $query_result->numrows; $i++) {
$user_email = ($query_result->fetchrow_array())[0];
if (! defined($user_email)) { next; }
if ($userlist) { $userlist .= "$user_email\n"; }
else { $userlist = "$user_email\n"; }
}
print LIST $userlist;
print $userlist if $d;
close(LIST);
}
if (system("mv /n/ops/usr/site/lib/lists/testbed-active-users.new ".
"/n/ops/usr/site/lib/lists/testbed-active-users")) {
fatal("Couldn't move testbed-active-users.new: $!\n");
}
open(LIST,"> $tempfile") ||
fatal("Couldn't open $tempfile: $!\n");
print LIST "#\n";
print LIST "# WARNING! THIS FILE IS AUTOGENERATED. DO NOT EDIT!\n";
print LIST "#\n";
for ($i = 0; $i < $query_result->numrows; $i++) {
$user_email = ($query_result->fetchrow_array())[0];
if (! defined($user_email)) {
next;
}
if ($userlist) {
$userlist .= "$user_email\n";
}
else {
$userlist = "$user_email\n";
}
}
print LIST $userlist;
print $userlist if $d;
close(LIST);
if (system("mv /n/ops/usr/site/lib/lists/testbed-users.new ".
"/n/ops/usr/site/lib/lists/testbed-users")) {
fatal("Couldn't move testbed-users.new: $!\n");
#
# Fire the new file over to the fileserver to finish up.
#
$UID = 0;
system("$SSH $PROG $progarg < $tempfile") == 0 or
fatal("Failed: $SSH $PROG $progarg < $tempfile: $?");
unlink("$tempfile");
}
#
# Close the lock file. Exiting releases it, but might as well.
#
close(LOCK);
exit 0;
sub fatal {
......
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