]> Sergey Matveev's repositories - public-inbox.git/commitdiff
wwwtext: show altid instructions in config
authorEric Wong <e@yhbt.net>
Thu, 26 Mar 2020 08:21:28 +0000 (08:21 +0000)
committerEric Wong <e@yhbt.net>
Thu, 26 Mar 2020 23:47:08 +0000 (23:47 +0000)
Exposing altid dumps will help and ensure total reproducibility
of existing instances.

AFAIK, sqlite3(1) can't execute arbitrary code, so it's not
quite as fashionable as the "curl | bash" stuff the cool people
are doing, these days :P

lib/PublicInbox/WwwText.pm

index cbe82b730f765a585e3fbf019a98f5183afa3405..2008ba0928decaba609dadbd8e67515cea2678fa 100644 (file)
@@ -138,15 +138,16 @@ sub inbox_config ($$$) {
        my $ibx = $ctx->{-inbox};
        push @$hdr, 'Content-Disposition', 'inline; filename=inbox.config';
        my $name = dq_escape($ibx->{name});
+       my $inboxdir = '/path/to/top-level-inbox';
        $$txt .= <<EOS;
 ; example public-inbox config snippet for "$name"
 ; see public-inbox-config(5) manpage for more details:
 ; https://public-inbox.org/public-inbox-config.html
 [publicinbox "$name"]
-       inboxdir = /path/to/top-level-inbox
+       inboxdir = $inboxdir
        ; note: public-inbox before v1.2.0 used "mainrepo"
        ; instead of "inboxdir", both remain supported after 1.2
-       mainrepo = /path/to/top-level-inbox
+       mainrepo = $inboxdir
        url = https://example.com/$name/
        url = http://example.onion/$name/
 EOS
@@ -154,6 +155,21 @@ EOS
                defined(my $v = $ibx->{$k}) or next;
                $$txt .= "\t$k = $_\n" for @$v;
        }
+       if (my $altid = $ibx->{altid}) {
+               my $base_url = $ibx->base_url($ctx->{env});
+               my $altid_map = $ibx->altid_map;
+               $$txt .= <<EOF;
+       ; altid DBs may be used to provide numeric article ID lookup from
+       ; old, pre-existing sources.  You can recreate them via curl(1),
+       ; gzip(1), and sqlite3(1) as documented:
+EOF
+               for (sort keys %$altid_map) {
+                       $$txt .= "\t;\tcurl -XPOST $base_url$_.sql.gz | \\\n" .
+                               "\t;\tgzip -dc | \\\n" .
+                               "\t;\tsqlite3 $inboxdir/$_.sqlite3\n";
+                       $$txt .= "\taltid = serial:$_:file=$_.sqlite3\n";
+               }
+       }
 
        for my $k (qw(filter newsgroup obfuscate replyto watchheader)) {
                defined(my $v = $ibx->{$k}) or next;