user/dev discussion of public-inbox itself
 help / color / Atom feed
1dccb8dd51c10793f06eca441eaf02156e15f427 blob 2089 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
 
#!/usr/bin/perl -w
# Copyright (C) 2015-2019 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
#
# Incremental (or one-shot) importer of a slrnpull news spool
=begin usage
	export ORIGINAL_RECIPIENT=address@example.com
	public-inbox-init $INBOX $GIT_DIR $HTTP_URL $ORIGINAL_RECIPIENT
	./import_slrnspool SLRNPULL_ROOT/news/foo/bar
=cut
use strict;
use warnings;
use PublicInbox::Config;
use PublicInbox::MIME;
use PublicInbox::Import;
use PublicInbox::Git;
sub usage { "Usage:\n".join('',grep(/\t/, `head -n 10 $0`)) }
my $exit = 0;
my $sighandler = sub { $exit = 1 };
$SIG{INT} = $sighandler;
$SIG{TERM} = $sighandler;
my $spool = shift @ARGV or die usage();
my $recipient = $ENV{ORIGINAL_RECIPIENT};
defined $recipient or die usage();
my $config = PublicInbox::Config->new;
my $ibx = $config->lookup($recipient);
my $git = $ibx->git;
my $im;
if (($ibx->{version} || 1) == 2) {
	require PublicInbox::V2Writable;
	$im = PublicInbox::V2Writable->new($ibx);
	$im->{parallel} = 0; # pointless to be parallel for a single message
} else {
	$im = PublicInbox::Import->new($git, $ibx->{name},
					$ibx->{-primary_address});
}

$ibx->{filter} ||= 'PublicInbox::Filter::Gmane';
my $filter = $ibx->filter;

sub key {
	"publicinbox.$ibx->{name}.importslrnspoolstate";
}

sub get_min {
	my $f = PublicInbox::Config->default_file;
	my $out = $git->qx('config', "--file=$f", key($ibx));
	$out ||= 0;
	chomp $out;
	$out =~ /\A[0-9]+\z/ and return $out;
	0;
}

sub set_min {
	my ($num) = @_;
	my $f = PublicInbox::Config->default_file;
	my @cmd = (qw/git config/, "--file=$f", key($ibx), $num);
	system(@cmd) == 0 or die join(' ', @cmd). " failed: $?\n";
}

my $n = get_min();
my $ok;
my $max_gap = 200000;
my $max = $n + $max_gap;
$spool =~ s!/+\z!!;

for (; $exit == 0 && $n < $max; $n++) {
	my $fn = "$spool/$n";
	open(my $fh, '<', $fn) or next;
	$max = $n + $max_gap;
	print STDERR $fn, "\n";

	my $mime = PublicInbox::MIME->new(eval { local $/; <$fh> });
	$filter->scrub($mime);
	$im->add($mime);

	$ok = $n + 1;
	set_min($ok);
}

$im->done;
debug log:

solving 1dccb8d ...
found 1dccb8d in https://80x24.org/public-inbox.git

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.org/gmane.mail.public-inbox.general

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git