#!/usr/bin/perl # fillbugzilla # copyright (c) 2002 Guillaume Rousse # $Id: fillbugzilla 448 2005-07-09 08:49:13Z guillomovitch $ use strict; use warnings; use Getopt::Long; use Bugzilla; use Mail::Sendmail; # constants my $name = "fillbugzilla"; my $version = "1.0"; # command-line parameters my ($base, $user, $pass, $project, $mode, $help); GetOptions( "base=s" => \$base, "user=s" => \$user, "pass=s" => \$pass, "mode=s" => \$mode, "help" => \$help, ); # mandatory argument die usage() unless ($base && $user && $pass); die usage() unless ($mode eq 'package' || $mode eq 'packager'); usage() && exit 0 if $help; my $bugzilla = Bugzilla->new('localhost', $base, $user, $pass); if ($mode eq 'packager') { while (my $packager = <>) { chomp $packager; my ($name, $login) = split(/\t/, $packager); # random passwd my @chars = (0..9, 'A'..'Z', 'a'..'z', '-', '_', '!', '@', '#', '$', '%', '^', '&', '*'); my $password = join('', map { $chars[rand(scalar @chars)] } 1 .. 8); # insert into database $bugzilla->add_packager($name, $login, $password); # mail user my %mail = ( smtp => 'localhost', To => $login, From => 'bugmaster@zarb.org', Subject => 'bugzilla password', 'X-Mailer' => "$name $version", ); $mail{Message} .= "login: $login\n"; $mail{Message} .= "password: $password\n"; sendmail(%mail) or warn $Mail::Sendmail::error; } } if ($mode eq 'package') { while (my $line = <>) { chomp $line; my ($name, $summary, $version, $maintainer) = split(/\t/, $line); $bugzilla->add_package($name, $summary, $version, $maintainer); } } sub usage { print < --user --pass --mode < $file Options: --base bugzilla base name --user bugzilla base user --pass bugzilla base password --mode package or packager EOF }