#!/usr/bin/perl
#
# all_review, by Anthony R. Thompson on 2/28/96
# sends REVIEW requests for all mailing lists to LISTSERV
#
# A quick hack of a script, never meant for public consumption and
# probably poorly coded, but provided in case it might be useful.  We
# used to run this script hourly via Cron and save the results via
# procmail to one file for each list, for updated subscriber files.
#
# The responses that LISTSERV sends back might be sent into a script
# to save them to subscriber files such as the revlists script, using
# a procmail recipe like the following:
#
# :0 H
# * ^From:.*LISTSERV@
# * ^Subject:.*File: "ABC-.*LIST
# | cat - | $HOME/.procmail/revlists
#
# Contact: put @ between art and sigilservices.com
#
# Copyright (C) 1998-2010 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA. http://www.fsf.org/licensing/licenses/gpl.html
#

$listhost = 'lists.ourhost.org';        # INSTALL
$listowner = "abc-listmaster\@abc.org"; # INSTALL owns of all our lists
$listpass = 'LISTPASSWORDHERE';         # INSTALL all lists = same pass
$listdir = '/path/to/place/with/list/subscriber/files';       # INSTALL
$listpre = "abc-";                      # INSTALL all lists start w/ abc-
$sendmail = "/usr/sbin/sendmail -t";    # INSTALL path to sendmail
$emailpause = 3;                        # INSTALL for email throttling
$listserv = join('@', 'listserv', $listhost);

sub ListNames {
    opendir(DIR,$listdir) || die "Error: can't open $listdir";
    local(@files) = readdir(DIR);       # get list of all files in dir
    closedir(DIR);
    local(@lists);
    foreach (@files) {
        if ($_ =~ /^$listpre/) {
	    s/\.list$//;     # remove .list file extension, if present
            push(@lists, $_);
        }
    }
    return @lists;
}

sub Review {
    local($list) = @_;
    open (SMAIL, "| $sendmail");
    print SMAIL "To: $listserv\nFrom: $listowner\nSubject: REVIEW $list\n\n";
    print SMAIL "REVIEW $list PW=$listpass\n";
    print "Sent REVIEW request for $list\n";
    close (SMAIL);
}

foreach (&ListNames()) { &Review($_); sleep($emailpause); }
