-sub usage { print STDERR "Usage: $usage\n"; exit 1 }
-usage() unless @dirs;
-
-foreach my $k (keys %$config) {
- $k =~ /\Apublicinbox\.([^\.]+)\.mainrepo\z/ or next;
- my $name = $1;
- my $v = $config->{$k};
- for my $i (0..$#dirs) {
- next if $dirs[$i] ne $v;
- my $ibx = $config->lookup_name($name);
- $dirs[$i] = $ibx if $ibx;
- }
-}
-
-foreach my $dir (@dirs) {
- if (!ref($dir) && -f "$dir/inbox.lock") { # v2
- my $ibx = { mainrepo => $dir, name => 'unnamed' };
- $dir = PublicInbox::Inbox->new($ibx);
- }
- index_dir($dir);
-}
-
-sub index_dir {
- my ($repo) = @_;
- if (!ref $repo && ! -d $repo) {
- die "$repo does not appear to be an inbox repository\n";
- }
- if (ref($repo) && ($repo->{version} || 1) == 2) {
- eval { require PublicInbox::V2Writable };
- die "v2 requirements not met: $@\n" if $@;
- my $v2w = PublicInbox::V2Writable->new($repo);
- $v2w->reindex;
- $v2w->done;
- } else {
- my $s = PublicInbox::SearchIdx->new($repo, 1);
- $s->index_sync({ reindex => $reindex });
+PublicInbox::Admin::require_or_die(keys %$mods);
+PublicInbox::Admin::progress_prepare($opt);
+for my $ibx (@ibxs) {
+ $ibx = PublicInbox::InboxWritable->new($ibx);
+ if ($opt->{compact} >= 2) {
+ PublicInbox::Xapcmd::run($ibx, 'compact', $compact_opt);