1 # Copyright (C) 2014-2015 all contributors <meta@public-inbox.org>
2 # License: AGPLv3 or later (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");