1 # Copyright (C) 2014-2018 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use PublicInbox::Config;
7 use File::Temp qw/tempdir/;
8 my $tmpdir = tempdir('pi-init-XXXXXX', TMPDIR => 1, CLEANUP => 1);
9 use constant pi_init => 'blib/script/public-inbox-init';
12 local $ENV{PI_DIR} = "$tmpdir/.public-inbox/";
13 my $cfgfile = "$ENV{PI_DIR}/config";
14 my @cmd = (pi_init, 'blist', "$tmpdir/blist",
15 qw(http://example.com/blist blist@example.com));
16 is(system(@cmd), 0, 'public-inbox-init OK');
18 ok(-e $cfgfile, "config exists, now");
19 is(system(@cmd), 0, 'public-inbox-init OK (idempotent)');
21 chmod 0666, $cfgfile or die "chmod failed: $!";
22 @cmd = (pi_init, 'clist', "$tmpdir/clist",
23 qw(http://example.com/clist clist@example.com));
24 is(system(@cmd), 0, 'public-inbox-init clist OK');
25 is((stat($cfgfile))[2] & 07777, 0666, "permissions preserved");
29 foreach my $mod (qw(DBD::SQLite Search::Xapian::WritableDatabase)) {
31 skip "$mod missing for v2", 2 if $@;
33 local $ENV{PI_DIR} = "$tmpdir/.public-inbox/";
34 my $cfgfile = "$ENV{PI_DIR}/config";
35 my @cmd = (pi_init, '-V2', 'v2list', "$tmpdir/v2list",
36 qw(http://example.com/v2list v2list@example.com));
37 is(system(@cmd), 0, 'public-inbox-init -V2 OK');
38 ok(-d "$tmpdir/v2list", 'v2list directory exists');
39 ok(-f "$tmpdir/v2list/msgmap.sqlite3", 'msgmap exists');
40 ok(-d "$tmpdir/v2list/all.git", 'catch-all.git directory exists');