Commit d2f1436c authored by Thomas Sibley's avatar Thomas Sibley
Browse files

Support skipping users or groups during import

You may want to update just one or the other manually while between
cronjobs.
parent a49b3801
......@@ -22,27 +22,40 @@ RT::Init;
use RT::Extension::LDAPImport;
my ($debug,$import,$help);
my %OPT = (
users => 1,
groups => 1,
);
use Getopt::Long;
GetOptions ( "debug" => \$debug, "help" => \$help, "import" => \$import );
if ($help) {
GetOptions(
\%OPT,
'debug', 'help',
'import', 'users!', 'groups!',
);
if ($OPT{help}) {
print <<USAGE;
$0: [--debug] [--import] [--help]
--help This usage statement.
--debug Enable debugging.
--import Do the import.
--no-users Skip users.
--no-groups Skip groups.
USAGE
exit 0;
}
my $importer = RT::Extension::LDAPImport->new;
$importer->screendebug(1) if $debug;
$importer->screendebug(1) if $OPT{debug};
if ($import) {
print "Starting import\n";
$importer->import_users(import => 1);
print "Starting group import\n";
$importer->import_groups(import => 1);
if ($OPT{import}) {
if ($OPT{users}) {
print "Starting import\n";
$importer->import_users(import => 1);
}
if ($OPT{groups}) {
print "Starting group import\n";
$importer->import_groups(import => 1);
}
print "Finished import\n";
} else {
print <<TESTING;
......@@ -50,8 +63,10 @@ Running test import, no data will be changed
Rerun command with --import to perform the import
Rerun command with --debug for more information
TESTING
$importer->import_users;
print "Testing group import\n";
$importer->import_groups();
$importer->import_users if $OPT{users};
if ($OPT{groups}) {
print "Testing group import\n";
$importer->import_groups();
}
print "Finished test\n";
}
Supports Markdown
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