head	1.10;
access;
symbols
	TIGRIS_1_1_0RC2:1.2
	TIGRIS_1_1_0RC1:1.2
	TIGRIS_1_1:1.2.0.6
	TIGRIS_1_0_8:1.2
	TIGRIS_1_0_8RC3:1.2
	TIGRIS_1_0_8RC2:1.2
	TIGRIS_1_0_8RC1:1.2
	TIGRIS_1_0_7:1.2
	TIGRIS_1_0_7RC3:1.2
	TIGRIS_1_0_7RC2:1.2
	TIGRIS_1_0_7RC1:1.2
	TIGRIS_1_0_6:1.2
	TIGRIS_1_0_6RC5:1.2
	TIGRIS_1_0_6RC4:1.2
	TIGRIS_1_0_6RC3:1.2
	TIGRIS_1_0_6RC2:1.2
	TIGRIS_1_0_6RC1:1.2
	TIGRIS_1_0_5:1.2
	TIGRIS_1_0_5RC6:1.2
	TIGRIS_1_0_5RC5:1.2
	TIGRIS_1_0_5RC4:1.2
	TIGRIS_1_0_5RC3:1.2
	TIGRIS_1_0_5RC2:1.2
	TIGRIS_1_0_5RC1:1.2
	TIGRIS_1_0_4:1.2
	TIGRIS_1_0_3:1.2
	TIGRIS_1_0_2:1.2
	TIGRIS_1_0_1:1.2
	TIGRIS_1_0:1.2.0.8
	TIGRIS_1_0_0:1.2
	TIGRIS_1_0_0_RC1:1.2.0.4
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.2
	TIGRIS_0_9_2_3:1.2
	HELM_PEER_PORT_BRANCH:1.1.1.1
	TURBINE_PEER:1.2
	TIGRIS_0_9_2_1:1.2
	TIGRIS_0_9_2:1.2.0.2;
locks; strict;
comment	@# @;


1.10
date	2001.08.14.19.59.05;	author kmaples;	state Exp;
branches;
next	1.9;

1.9
date	2001.07.30.18.07.19;	author kmaples;	state Exp;
branches;
next	1.8;

1.8
date	2001.06.19.01.09.12;	author kmaples;	state Exp;
branches;
next	1.7;

1.7
date	2001.06.05.22.36.18;	author kmaples;	state Exp;
branches;
next	1.6;

1.6
date	2001.04.25.17.14.58;	author kmaples;	state Exp;
branches;
next	1.5;

1.5
date	2001.04.18.02.02.58;	author kmaples;	state Exp;
branches;
next	1.4;

1.4
date	2001.04.17.04.44.54;	author kmaples;	state Exp;
branches;
next	1.3;

1.3
date	2001.04.07.00.02.14;	author kmaples;	state Exp;
branches;
next	1.2;

1.2
date	2001.01.13.02.04.52;	author kmaples;	state Exp;
branches;
next	1.1;

1.1
date	2001.01.05.23.31.11;	author kmaples;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2001.02.21.00.36.19;	author dlr;	state Exp;
branches;
next	;


desc
@@


1.10
log
@Unused, but keeping in sync w/ other support scripts.
@
text
@#!/usr/bin/perl

# ================================================================
# Copyright (c) 2000 Collab.Net.  All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# 
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 
# 3. The end-user documentation included with the redistribution, if
# any, must include the following acknowlegement: "This product includes
# software developed by Collab.Net (http://www.Collab.Net/)."
# Alternately, this acknowlegement may appear in the software itself, if
# and wherever such third-party acknowlegements normally appear.
# 
# 4. The hosted project names must not be used to endorse or promote
# products derived from this software without prior written
# permission. For written permission, please contact info@@collab.net.
# 
# 5. Products derived from this software may not use the "Tigris" name
# nor may "Tigris" appear in their names without prior written
# permission of Collab.Net.
# 
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# ====================================================================
# 
# This software consists of voluntary contributions made by many
# individuals on behalf of Collab.Net.
#


# 
# $Id: issuezilla-project-edit,v 1.9 2001/07/30 18:07:19 kmaples Exp $
# --------------------
# 

# Flush buffer, just in case:
$| = 1;

use strict;
use DBI;

# For the sake of -T:
$ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin";
# Detaint the args by brute force:
@@ARGV = detaint_array(@@ARGV);


# Process arguments
my $sandbox            = $ARGV[0] || '';
my $project_name       = $ARGV[1] || '';
my $dbname             = $ARGV[2] || '';
my $is_public          = $ARGV[3] || '';
my $multiple_dbs       = $ARGV[4] || '';  
my $new_project_name   = $ARGV[5] || '';

# Some email address for issuezilla:
my $login_name = "issues\@@$project_name";

# Updated values:
my $new_login_name = "issues\@@$new_project_name";

# String for current sql statement
my $command;

# Placeholder vars for db work:
my ($select, $ret);
 
# NOTE - this script requires the info necessary to connect
# to the correct DB, e.g., username/password, DB name, etc.

my $dbuser         = $ENV{DATABASE_USER}     || '';
my $dbpass         = $ENV{DATABASE_PASSWORD} || '';

my $dbrootuser     = $ENV{DATABASE_ROOTUSER} || '';
my $dbrootpass     = $ENV{DATABASE_ROOTPASS} || '';

# Grab just the filename portion of this script to use as a 
# log identifier:
my $script_name = $0;
$script_name =~ s/^.*\/([^\/]+)$/  $1/;

#---------------------------------------------------------------
# MAIN
#---------------------------------------------------------------
# First, create the database.  We presume that project == database,
# even for installations where there's only one database - that
# is interpreted as 'there's only one project':  
chdir("$sandbox/issuezilla") or die "$script_name: unable to chdir to issuezilla: $!\n";

# Fail if we don't have what we need to talk to the database:
unless($dbname && $dbuser && $dbpass){
    print "$script_name: envrionmentals for DB access not set\n";
    exit(1);
}

my $dbc = join(':',"DBI:mysql:$dbname",$ENV{DATABASE_HOST},$ENV{DATABASE_PORT});
my $CONN = DBI->connect($dbc, $dbuser, $dbpass);

# Check for a good connection:
unless( $CONN =~ m/HASH/){
    print "$script_name: no connection to database: $!\n";
    exit(1);
}

# Do the sql quoting for the values we're gonna play with:
foreach($project_name,  
    $login_name, $new_project_name, 
    $new_login_name){
    $_ = $CONN->quote( $_ );
}

## 1. change issues mailing list
## 2. update components
## 3. update versions
## 4. update milestones
# delete params, versioncache 

print "$script_name: updating 'components' table\n";

$command = qq[
    UPDATE components 
    SET 
        component   = $new_project_name, 
        description = $new_project_name
    WHERE component = $project_name
];

$select = $CONN->prepare($command);
$ret    = $select->execute;

unless($ret){
    print "$script_name: unable to perform update components: $!\n";
    $CONN->disconnect;
    exit(1);
}    

print "$script_name: updating 'profiles' table\n";

$command = qq[
    UPDATE profiles_internal
    SET
        login_name     = $new_login_name,
    WHERE login_name   = $login_name        
];

$select = $CONN->prepare($command);
$ret    = $select->execute;

unless($ret){
    print "$script_name: unable to perform insert: $!\n";
    $CONN->disconnect;
    exit(1);
}    

print "$script_name: updating 'versions' table\n";

$command = qq[
    UPDATE versions
    SET
        program = $new_project_name
    WHERE program = $project_name
];

$select = $CONN->prepare($command);
$ret    = $select->execute;

unless($ret){
    print "$script_name: unable to perform insert: $!\n";
    $CONN->disconnect;
    exit(1);
}    

print "$script_name: updating 'milestones' table\n";

$command = qq[
    UPDATE milestones
    SET
        component = $new_project_name
    WHERE component = $project_name
];

$select = $CONN->prepare($command);
$ret    = $select->execute;

unless($ret){
    print "$script_name: unable to perform insert: $!\n";
    $CONN->disconnect;
    exit(1);
}

# Clean up and leave quietly:
$select->finish();
$CONN->disconnect;

my ($datadir, $shadowdir);
$datadir   = $sandbox . '/data/issuezilla/data/';
$shadowdir = $sandbox . '/data/issuezilla/shadow/';

# Clean up the cache files:
if($multiple_dbs){
    $datadir   .= $dbname . '/';
    $shadowdir .= $dbname . '/';
}

if(-d $datadir){
    print "$script_name: deleting contents of '$datadir' directory\n"; 
    system('rm -rf ' . $datadir . '*') == 0 
        or die "$script_name: unable to remove files from $datadir: $!\n";
} else {
    print "$script_name: WARNING: directory $datadir doesn't exist\n";
}

if(-d $shadowdir){
    print "$script_name: deleting contents of '$shadowdir' directory\n"; 
    system('rm -rf ' . $shadowdir . '*') == 0 
        or die "$script_name: unable to remove files from $shadowdir: $!\n";
} else {
    print "$script_name: WARNING: directory $shadowdir doesn't exist\n";
}

#---------------------------------------------------------------
# END MAIN
#---------------------------------------------------------------


# A crude attempt to overcome data tainting in perl:
#-------------------
sub detaint_array {
#-------------------
    my @@unclean = @@_;
    my @@clean = ();

    foreach(@@unclean){
        # We don't really have rules for this, so at the moment
        # this acts as a passthrough:
        $_ =~ m/^(.*)$/;
        push(@@clean,$1);
    }

    return(@@clean);
}

@


1.9
log
@Issue number: 4544, 4242
Making the world a better place by removing the scripts the taskrunner
used to need to run to create IZ users.
@
text
@d51 1
a51 1
# $Id: issuezilla-project-edit,v 1.8 2001/06/19 01:09:12 kmaples Exp $
a76 1
my $realname   = "$project_name issues mailing list";
a79 1
my $new_realname   = "$new_project_name issues mailing list";
d126 2
a127 2
    $login_name, $realname, $new_project_name, 
    $new_login_name, $new_realname){
d159 1
a159 1
    UPDATE profiles
a161 1
        realname       = $new_realname
@


1.8
log
@Changes to store IZ's data under $SANDBOX/data/issuezilla/, along with
everyone else.  This relocates IZ's data/ and shadow/ directories there.
@
text
@d51 1
a51 1
# $Id: issuezilla-project-edit,v 1.7 2001/06/05 22:36:18 kmaples Exp $
d71 3
a73 4
my $domain_name        = $ARGV[3] || ''; 
my $is_public         = $ARGV[4] || '';
my $multiple_dbs       = $ARGV[5] || '';  
my $new_project_name   = $ARGV[6] || '';
d76 1
a76 2
my $mail_pfx   = $ENV{MAIL_PREFIX} || ''; 
my $login_name = $mail_pfx . "issues\@@$project_name". '.' . "$domain_name";
d80 1
a80 1
my $new_login_name = $mail_pfx . "issues\@@$new_project_name". '.' . "$domain_name";
d127 1
a127 1
foreach($project_name, $domain_name, 
@


1.7
log
@Issue number: 4242
Completely removing IZ's password and LDAP code.  This is in advance of
more signifigant changes to persuade IZ to obtain permission information
directly from Helm.

This is a large-scale cleanup of code which is useless to IZ, since it
obtains the information it uses for authentication from Helm in any event.
Password information was merely dummy strings that acted as placeholders
in the profiles table; as of now, it is sufficient to have an entry in
the profiles table (non-disabled, of course) for access.

Related changes can be found in issuezilla/
@
text
@d51 1
a51 1
# $Id: issuezilla-project-edit,v 1.6 2001/04/25 17:14:58 kmaples Exp $
d220 3
d225 2
a226 5
    $datadir   = 'data/'. $dbname . '/';
    $shadowdir = 'shadow/'. $dbname . '/';
} else {
    $datadir   = 'data';
    $shadowdir = 'shadow';
@


1.6
log
@Added a filter and some shared logging routine to quiet the output of the
scripts in production.  Lines which do not explicitly use the routines are
interpreted as debug.

Changed the arguments (unimplemented) from 'is_private' to 'is_public' to
conform with helm.
@
text
@d51 1
a51 1
# $Id: issuezilla-project-edit,v 1.5 2001/04/18 02:02:58 kmaples Exp $
a75 2
my $issues_password    = $ENV{ISSUZILLA_PASSWORD};

d129 1
a129 1
foreach($project_name, $domain_name, $issues_password, 
@


1.5
log
@Undoing yesterday's commit - my hastiness to implement some sort of logging
level notion into these scripts caused me great pain.
@
text
@d51 1
a51 1
# $Id: issuezilla-project-edit,v 1.3 2001/04/07 00:02:14 kmaples Exp $
d72 1
a72 1
my $is_private         = $ARGV[4] || '';
@


1.4
log
@Scripts now use IN_PRODUCTION to determine logging level
@
text
@a54 5
my $scripts_dir = $ENV{'SANDBOX'} . '/helm/perl/scripts';

require "$scripts_dir/ParentChildArgumentBridge.pl"
    or die "Require failed: $!\n";

d117 1
a117 1
    print_log(1, "$script_name: envrionmentals for DB access not set\n");
d126 1
a126 1
    print_log(1, "$script_name: no connection to database: $!\n");
d143 1
a143 1
print_log(1, "$script_name: updating 'components' table\n");
d157 1
a157 1
    print_log(1, "$script_name: unable to perform update components: $!\n");
d162 1
a162 1
print_log(1, "$script_name: updating 'profiles' table\n");
d176 1
a176 1
    print_log(1, "$script_name: unable to perform insert: $!\n");
d181 1
a181 1
print_log(1, "$script_name: updating 'versions' table\n");
d194 1
a194 1
    print_log(1, "$script_name: unable to perform insert: $!\n");
d199 1
a199 1
print_log(1, "$script_name: updating 'milestones' table\n");
d212 1
a212 1
    print_log(1, "$script_name: unable to perform insert: $!\n");
d232 1
a232 1
    print_log(1, "$script_name: deleting contents of '$datadir' directory\n");
d236 1
a236 1
    print_log(1, "$script_name: WARNING: directory $datadir doesn't exist\n");
d240 1
a240 1
    print_log(1, "$script_name: deleting contents of '$shadowdir' directory\n");
d244 1
a244 1
    print_log(1, "$script_name: WARNING: directory $shadowdir doesn't exist\n");
@


1.3
log
@Added preliminary support for 'is_private'
@
text
@d51 1
a51 1
# $Id: issuezilla-project-edit,v 1.2 2001/01/13 02:04:52 kmaples Exp $
d55 5
d122 1
a122 1
    print "$script_name: envrionmentals for DB access not set\n";
d131 1
a131 1
    print "$script_name: no connection to database: $!\n";
d148 1
a148 1
print "$script_name: updating 'components' table\n";
d162 1
a162 1
    print "$script_name: unable to perform update components: $!\n";
d167 1
a167 1
print "$script_name: updating 'profiles' table\n";
d181 1
a181 1
    print "$script_name: unable to perform insert: $!\n";
d186 1
a186 1
print "$script_name: updating 'versions' table\n";
d199 1
a199 1
    print "$script_name: unable to perform insert: $!\n";
d204 1
a204 1
print "$script_name: updating 'milestones' table\n";
d217 1
a217 1
    print "$script_name: unable to perform insert: $!\n";
d237 1
a237 1
    print "$script_name: deleting contents of '$datadir' directory\n"; 
d241 1
a241 1
    print "$script_name: WARNING: directory $datadir doesn't exist\n";
d245 1
a245 1
    print "$script_name: deleting contents of '$shadowdir' directory\n"; 
d249 1
a249 1
    print "$script_name: WARNING: directory $shadowdir doesn't exist\n";
@


1.2
log
@First furtive attempts to support remote databases.
@
text
@d51 1
a51 1
# $Id: issuezilla-project-edit,v 1.1 2001/01/05 23:31:11 kmaples Exp $
d72 3
a74 2
my $multiple_dbs       = $ARGV[4] || '';  
my $new_project_name   = $ARGV[5] || '';
@


1.1
log
@It may or may not be a good idea, but here it is - the ability to edit
(rename) projects.
@
text
@d51 1
a51 1
# $Id: issuezilla-project-edit,v 1.4 2000/12/27 22:57:44 kmaples Exp $
d120 1
a120 1
my $dbc = "DBI:mysql:$dbname";
@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d51 1
a51 1
# $Id: issuezilla-project-edit,v 1.2 2001/01/13 02:04:52 kmaples Exp $
d120 1
a120 1
my $dbc = join(':',"DBI:mysql:$dbname",$ENV{DATABASE_HOST},$ENV{DATABASE_PORT});
@


