View | Details | Raw Unified | Return to bug 15188
Collapse All | Expand All

(-)a/misc/migration_tools/remove_unused_authorities.pl (-2 / +20 lines)
Lines 30-38 use Getopt::Long; Link Here
30
my @authtypes;
30
my @authtypes;
31
my $want_help = 0;
31
my $want_help = 0;
32
my $test = 0;
32
my $test = 0;
33
my $force = 0;
33
GetOptions(
34
GetOptions(
34
    'aut|authtypecode:s' => \@authtypes,
35
    'aut|authtypecode:s' => \@authtypes,
35
    't|test'             => \$test,
36
    't|test'             => \$test,
37
    'f|force'            => \$force,
36
    'h|help'             => \$want_help
38
    'h|help'             => \$want_help
37
);
39
);
38
40
Lines 59-64 $rqselect->execute; Link Here
59
my $counter=0;
61
my $counter=0;
60
my $totdeleted=0;
62
my $totdeleted=0;
61
my $totundeleted=0;
63
my $totundeleted=0;
64
my @to_delete;
62
while (my $data=$rqselect->fetchrow_hashref){
65
while (my $data=$rqselect->fetchrow_hashref){
63
    my $query;
66
    my $query;
64
    $query= "an=".$data->{'authid'};
67
    $query= "an=".$data->{'authid'};
Lines 72-84 while (my $data=$rqselect->fetchrow_hashref){ Link Here
72
    print "$counter\n" unless $counter++ % 100;
75
    print "$counter\n" unless $counter++ % 100;
73
    # if found, delete, otherwise, just count
76
    # if found, delete, otherwise, just count
74
    if ($used>=$thresholdmin and $used<=$thresholdmax){
77
    if ($used>=$thresholdmin and $used<=$thresholdmax){
75
        DelAuthority($data->{'authid'}) unless $test;
78
        push @to_delete, $data->{'authid'};
76
        $totdeleted++;
79
        $totdeleted++;
77
    } else {
80
    } else {
78
        $totundeleted++;
81
        $totundeleted++;
79
    }
82
    }
80
}
83
}
81
84
85
if ($totdeleted >= $counter && !$force) {
86
    print "\nTo many authorities to deleted ($totdeleted)\n";
87
    print "Please check zebra daemon is running. Use --force option to delete all authorities\n";
88
    exit;
89
}
90
91
unless ($totdeleted) {
92
    print "\n Nothing to delete\n";
93
    exit 1;
94
}
95
96
unless ($test) {
97
    print "Deleting $totdeleted ...\n";
98
    DelAuthority($_) for @to_delete;
99
}
100
82
print "$counter authorities parsed, $totdeleted deleted and $totundeleted unchanged because used\n";
101
print "$counter authorities parsed, $totdeleted deleted and $totundeleted unchanged because used\n";
83
102
84
103
85
- 

Return to bug 15188