All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 6e804095 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add boot time stuff, so that public repos get the NFS mounts they

need, when ops reboots.
parent 10d2a7d7
......@@ -15,10 +15,13 @@ use Fcntl ':flock';
#
sub usage()
{
print(STDOUT "Usage: cvsrepo_ctrl pid\n");
print(STDOUT "Usage: cvsrepo_ctrl pid\n" .
" cvsrepo_ctrl -b\n");
exit(-1);
}
my $optlist = "";
my $optlist = "b";
my $booting = 0;
my $pid;
#
# Configure variables
......@@ -29,6 +32,7 @@ my $TBOPS = "@TBOPSEMAIL@";
my $TBAUDIT = "@TBAUDITEMAIL@";
my $PROJROOT = "/proj";
my $CVSREPOS = "$PROJROOT/cvsrepos";
my $CVSSUPPORT = @CVSSUPPORT@;
my $TESTMODE = @TESTMODE@;
my $SSH = "$TB/bin/sshtb -l root -host $FSNODE";
......@@ -71,6 +75,14 @@ use libaudit;
use libdb;
use libtestbed;
#
# If no CVS support, just exit.
#
if (! $CVSSUPPORT) {
print "CVS repo support is not enabled. Exit ...\n";
exit(0);
}
# Be careful not to exit on transient error
$libdb::DBQUERY_MAXTRIES = 30;
......@@ -82,22 +94,28 @@ $libdb::DBQUERY_MAXTRIES = 30;
if (! getopts($optlist, \%options)) {
usage();
}
if (defined($options{b})) {
$booting = 1;
}
usage()
if (@ARGV != 1);
my $pid = $ARGV[0];
if (@ARGV > 1);
# Untaint
if ($pid =~ /^([-\w]+)$/) {
$pid = $1;
}
else {
die("*** Tainted project name: $pid\n");
if (@ARGV) {
$pid = $ARGV[0];
# Untaint
if ($pid =~ /^([-\w]+)$/) {
$pid = $1;
}
else {
die("*** Tainted project name: $pid\n");
}
}
#
# This script is always audited. Mail is sent automatically upon exit.
#
if (AuditStart(0)) {
if (!$booting && AuditStart(0)) {
#
# Parent exits normally
#
......@@ -168,23 +186,25 @@ if (!$TESTMODE) {
my $now = time;
utime $now, $now, $lockfile;
#
# Grab DB data.
#
my $query_result =
DBQueryFatal("select cvsrepo_public from projects where pid='$pid'");
if (defined($pid)) {
#
# Grab DB data.
#
my $query_result =
DBQueryFatal("select cvsrepo_public from projects where pid='$pid'");
if (!$query_result->numrows) {
die("*** $0:\n".
" DB error getting info for project $pid!\n");
}
my ($cvsrepo_public) = $query_result->fetchrow_array();
my $prot = ($cvsrepo_public ? 0775 : 0770);
printf("Setting permission on $CVSREPOS/$pid to %o\n", $prot);
if (!$query_result->numrows) {
die("*** $0:\n".
" DB error getting info for project $pid!\n");
}
my ($cvsrepo_public) = $query_result->fetchrow_array();
my $prot = ($cvsrepo_public ? 0775 : 0770);
printf("Setting permission on $CVSREPOS/$pid to %o\n", $prot);
if (! chmod($prot, "$CVSREPOS/$pid")) {
die("*** $0:\n".
" Could not chmod($prot) directory $CVSREPOS/$pid: $!");
if (! chmod($prot, "$CVSREPOS/$pid")) {
die("*** $0:\n".
" Could not chmod($prot) directory $CVSREPOS/$pid: $!");
}
}
#
......@@ -206,9 +226,11 @@ close(CONF);
# right into it.
#
if (!$TESTMODE) {
my $optarg = ($booting ? "-m" : "");
$UID = 0;
system("$SSH $PROG < $tailfile") == 0 or
system("$SSH $PROG $optarg < $tailfile") == 0 or
fatal("Failed: $SSH $PROG < $tailfile: $?");
unlink("$tailfile");
close(LOCK);
......@@ -218,8 +240,8 @@ exit(0);
sub fatal($) {
my ($msg) = @_;
SENDMAIL($TBOPS, "CVSD Setup Failed", $msg);
die($msg);
die("*** $0:\n".
" $msg\n");
}
......@@ -14,10 +14,11 @@ use Getopt::Std;
#
sub usage()
{
print(STDOUT "Usage: cvsrepo_ctrl.proxy\n");
print(STDOUT "Usage: cvsrepo_ctrl.proxy [-m]\n");
exit(-1);
}
my $optlist = "";
my $optlist = "m";
my $domounts = 0;
#
# Configure variables
......@@ -41,7 +42,8 @@ my %pubrepos = ();
# We don't want to run this script unless its the real version.
#
if ($UID != 0) {
die("Must be root!");
die("*** $0:\n".
" Must be root to run this script!");
}
# un-taint path
......@@ -60,6 +62,20 @@ sub fatal($);
use lib "@prefix@/lib";
use libtestbed;
#
# Parse command arguments. Once we return from getopts, all that should be
# left are the required arguments.
#
my %options = ();
if (! getopts($optlist, \%options)) {
usage();
}
if (defined($options{m})) {
$domounts = 1;
}
usage()
if (@ARGV);
#
# Take our input and get the list of repos we need to make public.
#
......@@ -118,6 +134,34 @@ system("mv $CVSDCONFNEW $CVSDCONF") == 0 or
# Avoid accidental editing.
chmod(0444, $CVSDCONF);
#
# In mounts mode, just do the NFS mounts and exit. This is intended to
# be called at bootup, from boss.
#
if ($domounts) {
foreach my $repo (keys(%pubrepos)) {
my $dir = $repo;
if (! -d "$JAILREPODIR/$dir") {
system("/bin/mkdir $JAILREPODIR/$dir") == 0 or
fatal("Could not mkdir $JAILREPODIR/$dir");
}
#
# Now mount it, if not already done so.
#
if (! -d "$JAILREPODIR/$dir/CVSROOT") {
print "Mount: localhost:${PROJREPODIR}/$dir $JAILREPODIR/$dir\n";
system("$MOUNT localhost:${PROJREPODIR}/$dir $JAILREPODIR/$dir");
if ($?) {
fatal("Could not NFS mount localhost:${PROJREPODIR}/$dir");
}
}
}
exit(0);
}
#
# Must stop cvsd before doing the next step.
#
......
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