Commit 451c11a4 authored by Leigh Stoller's avatar Leigh Stoller

Add flyspray support to install. This turned out to be trickier then I

thought it would be cause of our current hacked up source code. I also
chased a cookie bug that is caused by domain confusion between inner
and outer emulab. No solutions for this yet, but its not likely to
bother anyone, except the dope that is trying to debug the inner
flyspray web site.
parent 3a7261ae
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# Copyright (c) 2000-2006 University of Utah and the Flux Group.
# All rights reserved.
#
......
......@@ -68,6 +68,7 @@ sub FlysprayUserid($);
sub FlysprayProjectid($);
sub FlysprayGroupid($$);
sub NewFlySprayGroup($$$$);
sub FlySpraySetup();
sub AddUser(@);
sub DelUser(@);
sub AddProject(@);
......@@ -96,6 +97,9 @@ if (! @ARGV) {
# hopefully not group readable. Open and parse that file, then open a
# connection to the DB.
#
$FLYCONF = "$TB/etc/flyspray.conf.php"
if (! -e $FLYCONF);
open(FLY, $FLYCONF) or
die("*** $0:\n".
" Could not open $FLYCONF for reading!\n");
......@@ -145,6 +149,9 @@ elsif ($action eq "setgroups") {
elsif ($action eq "xlogin") {
exit(xLogin(@ARGV));
}
elsif ($action eq "setup") {
exit(FlySpraySetup());
}
else {
die("*** $0:\n".
" Do not know what to do with '$action'!\n");
......@@ -405,18 +412,33 @@ sub DelUser(@)
sub AddProject(@)
{
usage()
if (@_ != 1);
if (@_ < 1 || @_ > 2);
my ($pid) = @_;
my ($pid, $setup) = @_;
my $project_id = FlysprayProjectid($pid);
if ($project_id >= 0) {
print("*** $pid already exists in the flyspray DB! Skipping\n");
return 0;
}
my $intro = "This is the Emulab Bug DB for the $pid project";
my $project_email = "${pid}-users\@${OURDOMAIN}";
my $intro;
my $project_email;
my $others_view;
if (defined($setup)) {
$intro = "This is the Bug DB for Emulab. This DB is intended ".
"for bugs related to the Emulab software. If you want to manage ".
"bugs for your own software/experiments, use the selector above ".
"to change the view.";
$project_email = $TBOPS;
$others_view = 1;
}
else {
$intro = "This is the Emulab Bug DB for the $pid project";
$project_email = "${pid}-users\@${OURDOMAIN}";
$others_view = 0;
}
# Easy ...
my $query_result =
DBQueryFatal("insert into flyspray_projects set ".
......@@ -428,7 +450,7 @@ sub AddProject(@)
" project_is_active='1', ".
" visible_columns='".
"id tasktype severity summary status dueversion progress', ".
" others_view='0', ".
" others_view='$others_view', ".
" anon_open='0', ".
" notify_email='$project_email', ".
" notify_email_when='0', ".
......@@ -603,6 +625,18 @@ sub xLogin(@)
"where user_id=$user_id");
return 0;
}
#
# Setup Flyspray at the beginning of time. This creates the Emulab project
# and munges a couple of fields.
#
sub FlySpraySetup()
{
my @args = ("Emulab", 1);
return AddProject(@args);
}
sub fatal($)
{
......
......@@ -27,6 +27,7 @@ my $DBNAME = "@TBDBNAME@";
my $ELABINELAB = @ELABINELAB@;
my $WINSUPPORT = @WINSUPPORT@;
my $MAILMANSUPPORT = @MAILMANSUPPORT@;
my $BUGDBSUPPORT = @BUGDBSUPPORT@;
my $OURDOMAIN = '@OURDOMAIN@';
my $LOGFACIL = '@TBLOGFACIL@';
......@@ -1053,6 +1054,18 @@ Phase "named", "Setting up initial named configuration", sub {
};
};
if ($BUGDBSUPPORT) {
my $BUGDBPROXY = "$PREFIX/sbin/bugdbproxy";
Phase "flyspray", "Finalizing flyspray installation", sub {
PhaseSkip("flyspray not supported")
if ($FBSD_VERSION < 6);
ExecQuietFatal("$SSH -o 'BatchMode=yes' root\@${USERNODE} ".
" '$BUGDBPROXY setup' ");
};
}
Phase "firstuser", "Setting up initial user (elabman)", sub {
PhaseSkip("elabman already created")
if (-d "/users/elabman");
......
......@@ -34,10 +34,12 @@ my $BOSSNODE_IP = '@BOSSNODE_IP@';
my $USERNODE_IP = '@USERNODE_IP@';
my $FSNODE_IP = '@FSNODE_IP@';
my $LOGFACIL = '@TBLOGFACIL@';
my $TBOPSEMAIL = '@TBOPSEMAIL@';
my $ELABINELAB = @ELABINELAB@;
my $WINSUPPORT = @WINSUPPORT@;
my $MAILMANSUPPORT = @MAILMANSUPPORT@;
my $CVSSUPPORT = @CVSSUPPORT@;
my $BUGDBSUPPORT= @BUGDBSUPPORT@;
my $QUOTA_FSLIST= '@FS_WITH_QUOTAS@';
my $LOGDIR = "$PREFIX/log";
my $ETCDIR = "$PREFIX/etc";
......@@ -139,6 +141,8 @@ my $MV = "/bin/mv";
my $GMAKE = "/usr/local/bin/gmake";
my $ENV = "/usr/bin/env";
my $MOUNT = "/sbin/mount";
my $TAR = "/usr/bin/tar";
my $MD5 = "/sbin/md5";
#
# Some files we edit/create
......@@ -345,6 +349,26 @@ Phase "ports", "Installing ports", sub {
ExecQuietFatal("$ENV PKG_PATH=$packagedir $PKG_ADD $pname");
};
}
if ($BUGDBSUPPORT) {
Phase "flyspray", "Installing flyspray package support", sub {
PhaseSkip("flyspray not supported on ops")
if ($FBSD_VERSION < 6);
if (!ExecQuiet("$PKG_INFO -x -e adodb")) {
PhaseSkip("adodb package already installed");
}
if (!$packagedir) {
PhaseSkip("No package directory provided");
}
# Lets not hardwire the package name; whatever it is will do.
my $pname = `ls $packagedir/adodb-*.tbz`;
PhaseFail("Cannot find adodb package in $packagedir!")
if ($?);
chomp($pname);
ExecQuietFatal("$ENV PKG_PATH=$packagedir $PKG_ADD $pname");
};
}
PhaseSkip("Package directory provided; not installing from source")
if ($packagedir);
......@@ -962,7 +986,6 @@ if ($MAILMANSUPPORT) {
my $MAILMANLISTS = "$MAILMANDIR/lists";
my $MAILMANPWD = "$ETCDIR/mailman.pwd";
my $MAILMANALIAS = "/etc/mail/aliases.mailman";
my $TBOPSEMAIL = "@TBOPSEMAIL@";
Phase "Mailman", "Setting up Mailman", sub {
PhaseSkip("mailman not supported on ops")
......@@ -1092,6 +1115,137 @@ if ($CVSSUPPORT) {
};
}
if ($BUGDBSUPPORT) {
my $FLYSPRAYPWD = "$ETCDIR/flyspray.pwd";
my $FLYSPRAYDIR = "/usr/local/www/data/flyspray";
my $FLYSPRAYURL = "http://www.emulab.net/downloads/flyspray-0.9.9.tgz";
my $FLYSPRAYCONF = "$ETCDIR/flyspray.conf.php";
my $PHPCONFIG = "/usr/local/etc/php.ini";
my $localtarfile = "/tmp/flyspray.tgz";
my $ADODBPATH = "/usr/local/share/adodb/adodb.inc.php";
Phase "flyspray", "Installing flyspray", sub {
PhaseSkip("flyspray not supported on ops")
if ($FBSD_VERSION < 6);
# Get a password for the installation.
Phase "password", "Generating flyspray password", sub {
DoneIfExists($FLYSPRAYPWD);
my $string = substr(GenSecretKey(), 0, 10);
PhaseFail("Invalid password supplied")
if (!defined($string) || $string eq "");
CreateFileFatal("$FLYSPRAYPWD", "$string");
ExecQuietFatal("$CHMOD 750 $FLYSPRAYPWD");
ExecQuietFatal("$CHGRP tbadmin $FLYSPRAYPWD");
};
my $secret = `cat $FLYSPRAYPWD`;
chomp($secret);
Phase "php", "Patching up PHP config file", sub {
DoneIfExists($PHPCONFIG);
CreateFileFatal($PHPCONFIG,
"[PHP]",
";",
"; For ADODB, which is needed by flyspray.",
";",
"include_path=\"/usr/local/share/adodb\"");
};
Phase "dbcreate", "Creating flyspray DB", sub {
if (! -d "$MYSQLDBDIR/flyspray") {
ExecQuietFatal("$MYSQLADMIN -u root -p${password} ".
" create flyspray");
}
ExecQuietFatal("echo 'grant all on flyspray.* to ".
" flyspray\@localhost ".
" identified by \"$secret\"' | ".
"$MYSQL -s -u root -p${password} mysql");
};
Phase "fetching", "Fetching flyspray distribution", sub {
DoneIfExists($localtarfile);
FetchFileFatal($FLYSPRAYURL, $localtarfile);
};
Phase "unpacking", "Unpacking flyspray distribution", sub {
if (! -e "$FLYSPRAYDIR") {
mkdir("$FLYSPRAYDIR", 0770) or
PhaseFail("Unable to make $FLYSPRAYDIR : $!");
}
ExecQuietFatal("$CHOWN nobody $FLYSPRAYDIR");
PhaseSkip("Flyspray already unpacked")
if (-e "$FLYSPRAYDIR/.htaccess");
ExecQuietFatal("$TAR zxf $localtarfile -C $FLYSPRAYDIR");
};
Phase "dbinit", "Initializing flyspray DB", sub {
if (!ExecQuiet("$MYSQLDUMP -d -u flyspray -p${secret} ".
"flyspray flyspray_groups")) {
PhaseSkip("DB already initialized");
}
ExecQuietFatal("$MYSQL -u flyspray -p${secret} flyspray ".
" < $FLYSPRAYDIR/sql/flyspray-0.9.8.mysql");
ExecQuietFatal("$MYSQL -u flyspray -p${secret} flyspray ".
" < $FLYSPRAYDIR/sql/flyspray-0.9.9-devel.mysql");
};
Phase "dbpatch", "Patching up flyspray DB", sub {
if (!ExecQuiet("$MYSQLDUMP -d -u flyspray -p${secret} ".
"flyspray emulab_project_mapping")) {
PhaseSkip("DB already patched");
}
ExecQuietFatal("$MYSQL -u flyspray -p${secret} flyspray ".
" < $TOP_SRCDIR/bugdb/sqlextras");
};
#
# Fix up the password for the flyspray "superuser"
#
my $md5_secret = `$MD5 -q -s $secret`;
PhaseFail("Could not take MD5 of flyspray password!")
if ($?);
chomp($md5_secret);
ExecQuietFatal("echo 'update flyspray_users set ".
" user_pass=\"${md5_secret}\", ".
" jabber_id=\"\", ".
" email_address=\"${TBOPSEMAIL}\"' | ".
"$MYSQL -u flyspray -p${secret} flyspray");
Phase "configfile", "Creating flyspray config file", sub {
DoneIfExists($FLYSPRAYCONF);
CreateFileFatal($FLYSPRAYCONF,
";",
"; Flyspray configuration",
";",
"[general]",
"basedir = \"${FLYSPRAYDIR}\"",
"baseurl = \"https://${USERNODE}/flyspray/\"",
"adodbpath = \"$ADODBPATH\"",
"cookiesalt= 130918332",
"output_buffering = \"on\"",
"passwdcrypt = \"md5\"",
"address_rewriting = \"0\"",
"reminder_daemon = \"0\"",
"[database]",
"dbtype = \"mysql\"",
"dbhost = \"localhost\"",
"dbname = \"flyspray\"",
"dbprefix = \"flyspray_\"",
"dbuser = \"flyspray\"",
"dbpass = \"$secret\""
);
ExecQuietFatal("$CHOWN nobody:tbadmin $FLYSPRAYCONF");
ExecQuietFatal("$CHMOD 750 $FLYSPRAYCONF");
};
};
}
exit(0)
if ($ELABINELAB);
......
......@@ -87,7 +87,8 @@ RUN_DEPENDS+= smbd:${PORTSDIR}/net/samba3
.endif
.if ${OSMAJOR} >= 6
RUN_DEPENDS+= ${LOCALBASE}/sbin/cvsd:${PORTSDIR}/devel/cvsd
RUN_DEPENDS+= ${LOCALBASE}/sbin/cvsd:${PORTSDIR}/devel/cvsd \
${LOCALBASE}/share/adodb/adodb.inc.php:${PORTSDIR}/databases/adodb
.endif
NO_BUILD= yes
......
......@@ -1492,6 +1492,15 @@ sub CreateDefsFile($)
}
last SWITCH;
};
/^BUGDBSUPPORT$/ && do {
if ($FBSD_VERSION == 6) {
print OUTDEFS "BUGDBSUPPORT=1\n";
}
else {
print OUTDEFS "BUGDBSUPPORT=0\n";
}
last SWITCH;
};
print OUTDEFS $_;
}
......
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