summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Wrobel <wrobel@gentoo.org>2005-09-03 08:53:56 +0000
committerGunnar Wrobel <wrobel@gentoo.org>2005-09-03 08:53:56 +0000
commit4021c4cc9bd38bbff9e308545b6c278e68f0c8b0 (patch)
treeff98ea5b1c371213d719fd1518e469473b4ccc91
parentThese are the rearrangements (diff)
downloadmisc-4021c4cc9bd38bbff9e308545b6c278e68f0c8b0.tar.gz
misc-4021c4cc9bd38bbff9e308545b6c278e68f0c8b0.tar.bz2
misc-4021c4cc9bd38bbff9e308545b6c278e68f0c8b0.zip
Preparing new scripts-gw release
svn path=/local/; revision=331
-rw-r--r--z-distfiles/scripts-gw/Makefile12
-rwxr-xr-xz-distfiles/scripts-gw/SVN-daily19
-rwxr-xr-xz-distfiles/scripts-gw/SVN-dump79
-rwxr-xr-xz-distfiles/scripts-gw/SVN-monthly19
-rwxr-xr-xz-distfiles/scripts-gw/birthDay83
-rwxr-xr-xz-distfiles/scripts-gw/check-ALLWRITE12
-rwxr-xr-xz-distfiles/scripts-gw/check-SUID12
-rwxr-xr-xz-distfiles/scripts-gw/dailyRoutine104
-rwxr-xr-xz-distfiles/scripts-gw/emerge-single9
-rwxr-xr-xz-distfiles/scripts-gw/gpg-update144
-rwxr-xr-xz-distfiles/scripts-gw/mysql-dump-all15
-rwxr-xr-xz-distfiles/scripts-gw/spam-report19
-rwxr-xr-xz-distfiles/scripts-gw/spamcop179
-rwxr-xr-xz-distfiles/scripts-gw/svn-add20
-rwxr-xr-xz-distfiles/scripts-gw/svn-del20
-rwxr-xr-xz-distfiles/scripts-gw/tonline.pl204
-rwxr-xr-xz-distfiles/scripts-gw/tripUpdate5
17 files changed, 955 insertions, 0 deletions
diff --git a/z-distfiles/scripts-gw/Makefile b/z-distfiles/scripts-gw/Makefile
new file mode 100644
index 0000000..f0abd2d
--- /dev/null
+++ b/z-distfiles/scripts-gw/Makefile
@@ -0,0 +1,12 @@
+DESTDIR=
+
+SBINSCRIPTS = SVN-dump SVN-html SVN-monthly birthDay check-SUID tripUpdate SVN-daily SVN-etc SVN-ldap SVN-mysql check-ALLWRITE dailyRoutine mysql-dump-all
+BINSCRIPTS = emerge-single
+
+all:
+ echo "No compilation necessary!"
+
+install: $(SBINSCRIPTS) $(BINSCRIPTS)
+ install -g root -o root -m 755 -d $(DESTDIR)/usr/bin $(DESTDIR)/usr/sbin
+ install -g root -o root -m 755 $(SBINSCRIPTS) $(DESTDIR)/usr/sbin/
+ install -g root -o root -m 755 $(BINSCRIPTS) $(DESTDIR)/usr/bin/
diff --git a/z-distfiles/scripts-gw/SVN-daily b/z-distfiles/scripts-gw/SVN-daily
new file mode 100755
index 0000000..2ab0df1
--- /dev/null
+++ b/z-distfiles/scripts-gw/SVN-daily
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+BIN_DUMP="/usr/sbin/SVN-dump"
+
+for REPOSITORY in /var/svn/repos/*
+ do
+ $BIN_DUMP $REPOSITORY /var/svn/dump/`basename $REPOSITORY`.dump incremental
+done
+
+for FILE in /var/svn/dump/*.bz2
+ do
+ [ -f $FILE.gpg ] && rm $FILE.gpg
+ [ -f $FILE ] && /usr/bin/gpg --batch --no-tty --default-recipient post@gunnarwrobel.de --encrypt-files $FILE && rm $FILE
+done
+
+chown -R apache:apache /var/svn/dump
+chmod 750 /var/svn/dump
+chmod 660 /var/svn/dump/*
+
diff --git a/z-distfiles/scripts-gw/SVN-dump b/z-distfiles/scripts-gw/SVN-dump
new file mode 100755
index 0000000..a812774
--- /dev/null
+++ b/z-distfiles/scripts-gw/SVN-dump
@@ -0,0 +1,79 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+my $repos_path = $ARGV[0];
+my $dumpfile = $ARGV[1];
+my $type = $ARGV[2];
+
+my $bin_svnadmin = `which svnadmin`;
+my $bin_svnlook = `which svnlook`;
+my $bin_bz2 = `which bzip2`;
+
+$bin_svnlook =~ s/\n//;
+$bin_svnadmin =~ s/\n//;
+$bin_bz2 =~ s/\n//;
+
+if ($bin_svnadmin eq "") {$bin_svnadmin = "/usr/bin/svnadmin"};
+if ($bin_svnlook eq "") {$bin_svnlook = "/usr/bin/svnlook"};
+if ($bin_bz2 eq "") {$bin_bz2 = "/bin/bzip2"};
+
+# Figure out the starting revision. Use 0 if we cannot read the
+# last-dumped file, else use the revision in that file incremented
+# by 1.
+my $new_start = 0;
+if (open LASTDUMPED, "$dumpfile.last")
+{
+ my $line = <LASTDUMPED>;
+ if (defined $line and $line =~ /^(\d+)/)
+ {
+ $new_start = $1 + 1;
+ }
+ close LASTDUMPED;
+}
+
+# Query the youngest revision in the repos.
+my $youngest = `$bin_svnlook youngest $repos_path`;
+defined $youngest && $youngest =~ /^\d+$/
+ or die "$0: 'svnlook youngest $repos_path' cannot get youngest revision.\n";
+chomp $youngest;
+
+if ($type eq "incremental")
+{
+ if ($new_start > $youngest)
+ {
+ print "Nothing to do!\n";
+ } else {
+ ## Do the backup.
+ system("$bin_svnadmin dump $repos_path --revision $new_start:$youngest --incremental >> $dumpfile.tmp") == 0
+ or die "$0: svnadmin dump to '$dumpfile.tmp' failed.\n";
+
+ # Store a new last-dumped revision.
+ open LASTDUMPED, "> $dumpfile.last.tmp"
+ or die "$0: cannot open '$dumpfile.last.tmp' for writing: $!\n";
+ print LASTDUMPED "$youngest\n";
+ close LASTDUMPED
+ or die "$0: error in closing '$dumpfile.last.tmp' for writing: $!\n";
+
+ # Rename to final locations.
+ rename("$dumpfile.tmp", "$dumpfile.$new_start.$youngest")
+ or die "$0: cannot rename '$dumpfile.tmp' to '$dumpfile': $!\n";
+
+ rename("$dumpfile.last.tmp", "$dumpfile.last")
+ or die "$0: cannot rename '$dumpfile.last.tmp' to '$dumpfile.last': $!\n";
+
+ system("$bin_bz2 $dumpfile.$new_start.$youngest") == 0
+ or die "$0: compressing dump file $dumpfile.$new_start.$youngest failed.\n";
+ }
+} else {
+
+ system("$bin_svnadmin dump $repos_path >> $dumpfile.full.tmp") == 0
+ or die "$0: svnadmin dump to '$dumpfile.tmp' failed.\n";
+
+ rename("$dumpfile.full.tmp", "$dumpfile.full")
+ or die "$0: cannot rename '$dumpfile.full.tmp' to '$dumpfile.full': $!\n";
+
+ system("$bin_bz2 -f $dumpfile.full") == 0
+ or die "$0: compressing dump file $dumpfile.full failed.\n";
+}
+# All done!
diff --git a/z-distfiles/scripts-gw/SVN-monthly b/z-distfiles/scripts-gw/SVN-monthly
new file mode 100755
index 0000000..3f26b15
--- /dev/null
+++ b/z-distfiles/scripts-gw/SVN-monthly
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+BIN_DUMP="/usr/sbin/SVN-dump"
+
+for REPOSITORY in /var/svn/repos/*
+ do
+ $BIN_DUMP $REPOSITORY /var/svn/dump/`basename $REPOSITORY`.dump full
+done
+
+for FILE in /var/svn/dump/*.bz2
+ do
+ [ -f $FILE.gpg ] && rm $FILE.gpg
+ [ -f $FILE ] && /usr/bin/gpg --batch --no-tty --default-recipient post@gunnarwrobel.de --encrypt-files $FILE && rm $FILE
+done
+
+chown -R apache:apache /var/svn/dump
+chmod 750 /var/svn/dump
+chmod 660 /var/svn/dump/*
+
diff --git a/z-distfiles/scripts-gw/birthDay b/z-distfiles/scripts-gw/birthDay
new file mode 100755
index 0000000..b0acb56
--- /dev/null
+++ b/z-distfiles/scripts-gw/birthDay
@@ -0,0 +1,83 @@
+#!/usr/bin/perl
+
+use Date::Calc qw(:all);
+use Net::SMTP;
+
+($year,$month,$day) = Today();
+($hour,$min,$sec) = Now();
+
+my $server = $ARGV[0];
+my $ldapdc = $ARGV[1];
+my $ldpass = $ARGV[2];
+
+system("ldapsearch -x -LL -H $server -b $ldapdc -s sub -D cn=admin,$ldapdc -w $ldpass \"(birthDate=*)\" cn mail birthDate > /tmp/birthday.tmp");
+
+open BDAY, "</tmp/birthday.tmp";
+
+while ($line = <BDAY>)
+{
+ if($line =~ /^dn:/)
+ {
+ $user = $line;
+ }
+ if($line =~ /^cn:/)
+ {
+ ($bday{$user}{"NAME"}) = ($line =~ /cn: (.*)/);
+ }
+ if($line =~ /^mail:/)
+ {
+ ($bday{$user}{"MAIL"}) = ($line =~ /mail: (.*)/);
+ }
+ if($line =~ /^birthDate:/)
+ {
+ ($bday{$user}{"BDAY"}{"YEAR"}, $bday{$user}{"BDAY"}{"MONTH"}, $bday{$user}{"BDAY"}{"DAY"}) = ($line =~ /birthDate: (\d\d\d\d)-(\d\d)-(\d\d).*/);
+ $bday{$user}{"AGE"} = ($year - $bday{$user}{"BDAY"}{"YEAR"});
+ $bday{$user}{"TLEFT"} = Delta_Days($year, $month, $day, $year, $bday{$user}{"BDAY"}{"MONTH"}, $bday{$user}{"BDAY"}{"DAY"});
+ }
+}
+
+foreach $user (keys %bday)
+{
+ if ($bday{$user}{"TLEFT"}==7 || $bday{$user}{"TLEFT"}==-358)
+ {
+ &bdayMail($bday{$user}{"NAME"},$bday{$user}{"MAIL"},$bday{$user}{"AGE"},"Der Geburtstag von " . $bday{$user}{"NAME"} . " naht!", $bday{$user}{"BDAY"}{"DAY"} . "." . $bday{$user}{"BDAY"}{"MONTH"});
+ }
+ if ($bday{$user}{"TLEFT"}==0)
+ {
+ &bdayMail($bday{$user}{"NAME"},$bday{$user}{"MAIL"},$bday{$user}{"AGE"},"Heute hat " . $bday{$user}{"NAME"} . " Geburtstag!", $bday{$user}{"BDAY"}{"DAY"} . "." . $bday{$user}{"BDAY"}{"MONTH"});
+ }
+}
+
+system("rm /tmp/birthday.tmp");
+
+sub bdayMail {
+ $smtp = Net::SMTP->new('localhost')
+ or die "Can't connect SMTP localhost!\n";
+
+ $recp{'post@gunnarwrobel.de'}{"NAME"} = "Gunnar";
+
+ $date = sprintf("%.3s, %02d %.3s %d %d:%d:%d +0200",
+ Day_of_Week_to_Text(Day_of_Week($year,$month,$day)),
+ $day,
+ Month_to_Text($month),
+ $year,$hour,$min,$sec);
+
+ foreach $localname (keys %recp)
+ {
+ $mail = 'From: Birthday Skript <system@gunnarwrobel.de>' . "\n";
+ $mail .= "To: " . $recp{$localname}{"NAME"} . " <" . $localname .">\n";
+ $mail .= "Date: " . $date . "\n";
+ $mail .= "Subject: " . $_[3] . "\n\n";
+ $mail .= "Am " . $_[4] . " wird " . $_[0] . " " . $_[2] . " Jahre alt.\n\n";
+ if (!$_[1] eq "")
+ {
+ $mail .= "Falls Du eine Mail schreiben moechtest: " . $_[1] . "\n";
+ }
+ $smtp->mail('system@gunnarwrobel.de');
+ $smtp->to($localname);
+ $smtp->data();
+ $smtp->datasend($mail);
+ $smtp->dataend();
+ $smtp->quit;
+ }
+}
diff --git a/z-distfiles/scripts-gw/check-ALLWRITE b/z-distfiles/scripts-gw/check-ALLWRITE
new file mode 100755
index 0000000..ac2691b
--- /dev/null
+++ b/z-distfiles/scripts-gw/check-ALLWRITE
@@ -0,0 +1,12 @@
+#!/bin/bash
+LOG=/root/.log/read.log
+LOG_OLD=/root/.log/read.log.old
+mv $LOG $LOG_OLD
+find / -xdev -perm +o=w ! \( -type d -perm +o=t \) ! -type l -print > $LOG
+
+diff -Nau $LOG_OLD $LOG
+echo "##################################################"
+cat $LOG_OLD
+echo "##################################################"
+cat $LOG
+rm $LOG_OLD
diff --git a/z-distfiles/scripts-gw/check-SUID b/z-distfiles/scripts-gw/check-SUID
new file mode 100755
index 0000000..5740da4
--- /dev/null
+++ b/z-distfiles/scripts-gw/check-SUID
@@ -0,0 +1,12 @@
+#!/bin/bash
+LOG=/root/.log/suid.log
+LOG_OLD=/root/.log/suid.log.old
+mv $LOG $LOG_OLD
+find / -xdev -type f -perm +ug=s -print > $LOG
+
+diff -Nau $LOG_OLD $LOG
+echo "##################################################"
+cat $LOG_OLD
+echo "##################################################"
+cat $LOG
+rm $LOG_OLD
diff --git a/z-distfiles/scripts-gw/dailyRoutine b/z-distfiles/scripts-gw/dailyRoutine
new file mode 100755
index 0000000..cc163e2
--- /dev/null
+++ b/z-distfiles/scripts-gw/dailyRoutine
@@ -0,0 +1,104 @@
+#!/bin/bash
+
+MYSQLPASS="$1"
+GPGUSER="$2"
+BACKUP="/root/opt/backup"
+
+echo "---------------------"
+echo "-- TIME CORRECTION "
+echo "---------------------"
+echo
+
+ntpd -q
+
+echo "---------------------"
+echo "-- END"
+echo "---------------------"
+echo
+
+echo "---------------------"
+echo "NOW:"
+echo
+date
+echo "---------------------"
+echo
+
+echo "---------------------"
+echo "-- BACKUP "
+echo "---------------------"
+echo
+
+SVN-etc ${BACKUP} "AutomaticUpdate"
+SVN-html ${BACKUP} "AutomaticUpdate"
+SVN-mysql ${BACKUP} ${MYSQLPASS} "AutomaticUpdate"
+SVN-ldap ${BACKUP} "AutomaticUpdate"
+
+echo "---------------------"
+echo "-- END"
+echo "---------------------"
+echo
+
+echo "---------------------"
+echo "-- SVN BACKUP "
+echo "---------------------"
+echo
+
+SVN-daily ${GPGUSER} | grep -v "skipping"
+
+echo "---------------------"
+echo "-- END"
+echo "---------------------"
+echo
+
+echo "---------------------"
+echo "-- APACHE STATS"
+echo "---------------------"
+echo
+
+/etc/analog/analog.daily
+
+echo "---------------------"
+echo "-- END"
+echo "---------------------"
+echo
+
+echo "---------------------"
+echo "-- MAIL"
+echo "---------------------"
+echo
+
+rsync -rtpvz --delete-after /var/spool/mail/ /home/wrobel/mail/backup/
+chown -R wrobel:users /home/wrobel/mail/backup
+
+echo "---------------------"
+echo "-- END"
+echo "---------------------"
+echo
+
+echo "---------------------"
+echo "-- GENERAL"
+echo "---------------------"
+echo
+
+slocate -u
+texpire
+check-SUID
+check-ALLWRITE
+horde.fetchmail
+emerge --nospinner sync >> /var/log/portage.log
+emerge --nospinner --pretend world
+birthDay
+logwatch.pl --detail 10
+logrotate /etc/logrotate.conf
+
+echo "---------------------"
+echo "-- END"
+echo "---------------------"
+echo
+
+echo "---------------------"
+echo "NOW:"
+echo
+date
+echo "---------------------"
+echo
diff --git a/z-distfiles/scripts-gw/emerge-single b/z-distfiles/scripts-gw/emerge-single
new file mode 100755
index 0000000..aa41c12
--- /dev/null
+++ b/z-distfiles/scripts-gw/emerge-single
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+X=`/usr/bin/emerge -p $1 | /bin/grep '^\[' | /bin/wc | /bin/awk '{print $1}'`
+
+/usr/bin/test $X -eq 1 && emerge $1 && exit 0
+
+echo $'\e[31;01m'"This would emerge more than one ebuild!"
+
+exit 1
diff --git a/z-distfiles/scripts-gw/gpg-update b/z-distfiles/scripts-gw/gpg-update
new file mode 100755
index 0000000..23e73af
--- /dev/null
+++ b/z-distfiles/scripts-gw/gpg-update
@@ -0,0 +1,144 @@
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+
+use Crypt::GPG;
+use Date::Manip;
+
+sub promptUser {
+
+ my ($promptString) = @_;
+
+ print $promptString, ": ";
+
+ $| = 1; # force a flush after our print
+ $_ = <>; # get the input from STDIN (presumably the keyboard)
+
+ chomp;
+
+ return $_;
+}
+
+
+sub printKey($)
+{
+
+ my $key = shift;
+
+ print "ID: " . $key->{ID} . "\n";
+ print "Owner: " . $key->{UIDs}->[0]->{UID} . "\n";
+
+}
+
+my $date1;
+my $date2;
+my $flag;
+my $info;
+my $name;
+my $mail;
+my @earray;
+my $pass;
+my $spass;
+my $status;
+my $delete;
+my $finger;
+
+my $gpg = new Crypt::GPG;
+
+my @keys = $gpg->keydb();
+
+my %expired;
+
+$ENV{'LC_ALL'}="en_US";
+
+foreach my $key (@keys)
+{
+ if (not $key->{Expires} eq "")
+ {
+ $date1 = ParseDate($key->{Expires});
+ $date2 = ParseDate("now");
+ $flag = Date_Cmp($date1,$date2);
+ if ($flag < 0)
+ {
+ # key expired
+ print "=> Found expired key.\n\n";
+ printKey($key);
+ print "\nAction required!\n";
+ print "--------------------------------------------------------\n";
+ push @{$expired{$key->{ID}}}, $key;
+ }
+ else
+ {
+ print "=> Found key that has not yet expired.\n\n";
+ printKey($key);
+ print "\nNo action required!\n";
+ print "--------------------------------------------------------\n";
+ }
+ }
+ else
+ {
+ print "=> Found non-expiring key.\n\n";
+ printKey($key);
+ print "\nNo action required!\n";
+ print "--------------------------------------------------------\n";
+ }
+}
+
+print "\n########################################################\n\n";
+
+foreach my $keypair (keys %expired)
+{
+ if (scalar (@{$expired{$keypair}}) == 2)
+ {
+ print "Expired keypair (" . $keypair . ") will be regenerated!\n";
+ print "--------------------------------------------------------\n";
+ $info = $expired{$keypair}->[0]->{UIDs}->[0]->{UID};
+ ($name = $info) =~ s/\s*\(.*//;
+ ($mail = $info) =~ s/.*<(.+@.+)>/$1/;
+ print "User: " . $name . "\n";
+ print "Mail: <" . $mail . ">\n";
+ $pass = promptUser("New passphrase for this key");
+ $status = $gpg->keygen($name, $mail, 'ELG-E', 1024, '90', $pass);
+ while (<$status>)
+ {
+ $pass = $_;
+ chomp $pass;
+ print $pass;
+ }
+ close $status;
+ $delete = promptUser("\nReally delete the old key?");
+ if ($delete eq "yes")
+ {
+ foreach my $key (@{$expired{$keypair}})
+ {
+ $gpg->delkey($key);
+ }
+ }
+ print "--------------------------------------------------------\n";
+ }
+ else
+ {
+ print "Expired key (" . $keypair . ") has no matching partner!\n";
+ print "--------------------------------------------------------\n";
+ }
+}
+
+@keys = $gpg->keydb();
+
+print "\n########################################################\n\n";
+
+foreach my $key (@keys)
+{
+ if (scalar (@{$key->{UIDs}->[0]->{Signatures}}) == 1)
+ {
+ print "Found key without signature.\n";
+ printKey($key);
+ print "\nExpires: " . $key->{Expires} . "\n";
+ print "\nYou might want to consider signing this key with:\n";
+ print "\ngpg --default-key post\@gunnarwrobel.de --sign-key " . $key->{ID} . "\n";
+ print "\nYou can then send the key to a server with:\n";
+ print "\ngpg --send-key " . $key->{ID} . "\n";
+ print "--------------------------------------------------------\n";
+ }
+}
diff --git a/z-distfiles/scripts-gw/mysql-dump-all b/z-distfiles/scripts-gw/mysql-dump-all
new file mode 100755
index 0000000..6cbf58c
--- /dev/null
+++ b/z-distfiles/scripts-gw/mysql-dump-all
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+if [ "x$1" == "x--help" ]; then
+ echo "Usage: mysql-dump-all mysql-root-pass /backup/dir"
+ echo
+ echo "Dumps all mysql databases into the given /backup/dir/"
+ exit 0
+fi
+
+DBS=`mysql -u root -p${1} -s -e 'show databases;' | grep -v 'Database'`
+
+for db in $DBS
+do
+ mysqldump -u root -p${1} ${db} > ${2}/${db}.sql
+done
diff --git a/z-distfiles/scripts-gw/spam-report b/z-distfiles/scripts-gw/spam-report
new file mode 100755
index 0000000..68a3f0e
--- /dev/null
+++ b/z-distfiles/scripts-gw/spam-report
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+if [ -d "${1}" ]; then
+ MAILS="`ls ${1}`"
+ if [ ! -z "${MAILS}" ]; then
+ for MAIL in ${MAILS}
+ do
+ echo "Report ${1}/${MAIL}"
+ spamassassin -r < "${1}/${MAIL}"
+ echo "Delete ${1}/${MAIL}"
+ rm "${1}/${MAIL}"
+ done
+ fi
+ if [ -z "${MAILS}" ]; then
+ echo "Nothing in ${1} to report!"
+ fi
+fi
+
+
diff --git a/z-distfiles/scripts-gw/spamcop b/z-distfiles/scripts-gw/spamcop
new file mode 100755
index 0000000..28a1e60
--- /dev/null
+++ b/z-distfiles/scripts-gw/spamcop
@@ -0,0 +1,179 @@
+#!/usr/bin/perl -w
+
+use HTML::Form;
+use LWP;
+use HTTP::Cookies;
+
+sub get_all_links( $ );
+sub get_login_cookie( $$$$ );
+sub report_all_spam( $$ );
+
+if ($ARGV[0] eq "--help" ) {
+ print 'usage: spamcop {EMAIL-FOLDER}'."\n";
+ print 'usage: spamcop /home/heinz/mail/Inbox/.SpamCop'."\n";
+ exit;
+}
+
+# Configuration settings
+
+my $spam_cop_user = 'gunnarwrobel@yahoo.de';
+my $spam_cop_pass = 'k8FHdADl';
+
+# Main routine
+my $folder = $ARGV[0]; # the folder with spam cop answers
+
+my $ua = LWP::UserAgent->new();
+$ua->cookie_jar(HTTP::Cookies->new(file => "$ENV{HOME}/.cookies.txt"));
+
+
+my @link_batch = get_all_links( $folder );
+
+if (scalar( @link_batch ) > 0)
+{
+
+ get_login_cookie( $ua,
+ $link_batch[0],
+ $spam_cop_user,
+ $spam_cop_pass
+ );
+
+ report_all_spam( $ua,
+ \@link_batch
+ );
+}
+else
+{
+ die "Unable to extract any links from folder $folder!";
+}
+
+## Function get_all_links
+##
+## Retrieves all the SpamCop report links from the
+## mails in one folder
+##
+## Parameters:
+##
+## folder: the path to the folder to check for links
+
+sub get_all_links ( $ )
+{
+ my $folder = shift;
+
+ opendir (DIR, $folder . "/cur");
+ my @files = grep { $_ ne '.' and $_ ne '..'} readdir( DIR );
+
+ my @links = ();
+ my $link;
+
+ if (scalar @files > 0)
+ {
+ foreach my $file (@files)
+ {
+ open(FILE, $folder . "/cur/" . $file);
+ while (<FILE>)
+ {
+ if (($link) = ($_ =~ /(.*www.spamcop.net.sc.id=.*)/))
+ {
+ push @links, {'LINK' => $link, 'FILE' => $folder . "/cur/" . $file};
+ }
+ }
+ close(FILE);
+ }
+ }
+
+ return @links;
+}
+
+## Function get_login_cookie
+##
+## Logs the user into spamcop
+## and returns the session cookie
+##
+## Parameters:
+##
+## ua: LWP user agent
+## link: one of the extracted report links
+## user: SpamCop user
+## pass: SpamCop password
+
+sub get_login_cookie ( $$$$ )
+{
+
+ my $ua = shift;
+ my $link = shift;
+ my $user = shift;
+ my $pass = shift;
+
+ my $form = $ua->get($link->{'LINK'})
+ or
+ die "Couldn't fetch $link";
+
+ if ( $form->is_error() )
+ {
+ die $form->message();
+ }
+
+ my $formurl = "http://www.spamcop.net/mcgi";
+
+ my $resp = $ua->post
+ (
+ $formurl,
+ [
+ 'username' => $user,
+ 'password' => $pass,
+ 'duration' => '+12h',
+ 'action' => 'cookielogin',
+ 'returnurl' => '/mcgi?action=verifylogin',
+ 'submit' => 'Login'
+ ]
+ );
+
+ if ( $resp->is_error() )
+ {
+ die $resp->message();
+ }
+}
+
+## Function report_all_spam
+##
+## Reports every spam link
+##
+## Parameters:
+##
+## ua: LWP user agent
+## linklist: The list of report pages
+
+sub report_all_spam ( $$ )
+{
+ my $ua = shift;
+ my $link_list = shift;
+ my $form;
+ my @forms;
+ my $response;
+
+ foreach my $link (@{$link_list})
+ {
+ $form = $ua->get($link->{'LINK'})
+ or
+ die "Couldn't fetch $link";
+
+ @forms = HTML::Form->parse( $form );
+
+ foreach my $sendform (@forms)
+ {
+ if (defined $sendform->attr( 'name' )
+ and $sendform->attr( 'name' ) eq 'sendreport')
+ {
+ $response = $ua->request($sendform->click());
+ if ( $response->is_error() )
+ {
+ die "Failed to report spam:\n\n" . $response->message();
+ }
+ else
+ {
+ unlink $link->{'FILE'}
+ }
+ }
+ }
+ }
+}
diff --git a/z-distfiles/scripts-gw/svn-add b/z-distfiles/scripts-gw/svn-add
new file mode 100755
index 0000000..79aaea7
--- /dev/null
+++ b/z-distfiles/scripts-gw/svn-add
@@ -0,0 +1,20 @@
+#/bin/bash
+
+FILES=`svn status | sed -e '/^[^?]/d
+ s/^?//
+ s/^ *//
+ s/ /\\ /'`
+
+for FL in ${FILES}
+ do
+ echo ${FL}
+done
+
+if [ "${1}" = "do" ]; then
+ if [ "x${FILES}" != "x" ]; then
+ for FL in ${FILES}
+ do
+ svn add "${FL}"
+ done
+ fi
+fi
diff --git a/z-distfiles/scripts-gw/svn-del b/z-distfiles/scripts-gw/svn-del
new file mode 100755
index 0000000..8871cd6
--- /dev/null
+++ b/z-distfiles/scripts-gw/svn-del
@@ -0,0 +1,20 @@
+#/bin/bash
+
+FILES=`svn status | sed -e '/^[^!]/d
+ s/^!//
+ s/^ *//
+ s/ /\\ /'`
+
+for FL in ${FILES}
+ do
+ echo ${FL}
+done
+
+if [ "${1}" = "do" ]; then
+ if [ "x${FILES}" != "x" ]; then
+ for FL in ${FILES}
+ do
+ svn del "${FL}"
+ done
+ fi
+fi
diff --git a/z-distfiles/scripts-gw/tonline.pl b/z-distfiles/scripts-gw/tonline.pl
new file mode 100755
index 0000000..03875f1
--- /dev/null
+++ b/z-distfiles/scripts-gw/tonline.pl
@@ -0,0 +1,204 @@
+#!/usr/bin/perl -w
+
+# $Id: tonline.pl,v 1.5 2003/12/10 08:55:40 endresct Exp $
+
+use strict;
+use HTML::Entities;
+use MIME::Base64;
+use Net::SMTP;
+use LWP;
+use LWP::Debug qw(+);
+
+if ($ARGV[0] eq "--help" ) {
+ print 'usage: tonline.pl {USER} {PASS} {LOCALUSER}'."\n";
+ print 'usage: tonline.pl hmuster secret heinz@localserver'."\n";
+ exit;
+}
+
+# Configuration
+my $uname = $ARGV[0]; # change to your t-online name
+my $pword = $ARGV[1]; # change to your password
+my $localname = $ARGV[2]; # change to your local name
+my $deliver = 'smtp'; # change to 'smtp', if Hamster or
+ # <yourfavoriteunixsmtpserver>
+ # is running on the same machine
+
+my $url = 'https://modem.webmail.t-online.de';
+my $ua = LWP::UserAgent->new();
+my $spool = '/var/spool/mail/';
+
+my $location = createLogin( $ua, $url, $uname, $pword );
+
+# Comment out the first line an uncomment the second to fetch the "Ablage" folder
+my $inbox = $ua->get($location);
+
+if ($location) {
+
+ $location =~ s/main.cgp.*//;
+
+ my @ids = grepIDs($inbox);
+
+ for ( my $i = 0 ; $i < @ids ; $i++ ) {
+ my $mail = fetchFile( $location, $ids[$i] );
+ open(LOGFILE, "+>>", "/root/heide.mail.log");
+ print LOGFILE $mail;
+ close(LOGFILE);
+ my $issave = fileMail( $mail, $spool, $localname );
+
+ if ($issave) {
+ deleteMail($location, $ids[$i], $i);
+ # it's commented out, but: BE CAREFUL - please, save FIRST.
+ }
+
+ sleep(2); # don't kill webservers with too fast polls
+ } ## end for ( my $i =...
+}
+
+$ua->get( $url . "/logout.cgp" );
+
+sub createLogin {
+ my ( $ua, $url, $uname, $pword ) = @_;
+
+ my $location;
+ my $form_login;
+ my $form_pass;
+ my $form;
+ my $id;
+ my $resp;
+
+ push @{ $ua->requests_redirectable() }, 'POST';
+
+ $form = $ua->get($url . "/index.cgp") or die "Couldn't fetch $url";
+ die $form->message() if $form->is_error();
+
+ ($id) = $form->content() =~ m{/([^/]+)/login_in_frame\.cgp}s;
+
+ ($form_login) = $form->content() =~ m{/.*type="text" name='([^']+)}s;
+ ($form_pass) = $form->content() =~ m{/.*type="password" name='([^']+)}s;
+ $resp = $ua->post(
+ $url . "/main.cgp",
+ [
+ $form_login => $uname,
+ $form_pass => $pword,
+ 'js' => '0',
+ 'sessionid' => $id
+ ]
+ );
+
+ if ($resp->header('Refresh')) {
+ ($location) = ( $resp->header('Refresh') =~ m/URL=(.*)/ );
+ return $url . $location;
+ } else {
+ return
+ }
+
+} ## end sub createLogin
+
+sub grepIDs {
+ my $mbox = shift;
+ my %ids;
+
+ foreach my $key ( $mbox->content() =~ m/MAIL=(\d+?)\"/sg ) {
+ $ids{$key} = 1;
+ }
+
+ return keys(%ids);
+} ## end sub grepIDs
+
+sub deleteMail {
+ my ( $url, $id, $count ) = @_;
+ my $resp =
+ $ua->get( $url . "main.cgp?MAIL[$count]=" . $id . "&Loeschen.x=1" );
+
+ return 0 unless ( $resp->status_line() =~ /OK/ );
+} ## end sub deleteMail
+
+sub fileMail {
+ my ( $mail, $spool, $localname ) = @_;
+
+ if ( $deliver eq 'smtp' ) {
+ my ($from) = ( $mail =~ m/From: .+?<([^<]+)>/ );
+ my $smtp = Net::SMTP->new('localhost')
+ or die "Can't connect SMTP localhost!\n";
+
+ $mail =~ s/^From\s([^@]+@[^@ ]+)\s.*/From: $1/;
+ ## Hopefully fixes mailing problems
+ $mail =~ s/^-- /\#\#-- /;
+ $mail =~ s/^----------/\#\#---------/;
+
+ $smtp->mail($from);
+ $smtp->to($localname);
+ $smtp->data();
+ $smtp->datasend($mail);
+ $smtp->dataend();
+ $smtp->quit;
+
+ ## AutoResponder
+ $smtp = Net::SMTP->new('localhost')
+ or die "Can't connect SMTP localhost!\n";
+
+ $mail = "From: Heide u.Bernd Wrobel <hbwrobel\@torp4.de>\n";
+ $mail .= "Subject: Adressaenderung\n";
+ $mail .= "Content-Type: text/plain; charset=UTF-8\n";
+ $mail .= "Date: " . scalar(localtime()) . "\n";
+ $mail .= '
+Automatische Mitteilung
+#---------------------#
+
+Lieber Absender,
+
+Sie haben eine E-Mail an die Adresse hbwrobel@t-online.de versendet.
+Da wir diese Adresse innerhalb des nächsten halben Jahres löschen
+möchten, bitten wir Sie unseren Eintrag in Ihrem Adressbuch auf
+hbwrobel@torp4.de zu aktualisieren.
+
+Vielen Dank!
+
+Mit freundlichen Grüßen
+
+Heide und Bernd Wrobel
+';
+
+ $smtp->mail('hbwrobel@torp4.de');
+ $smtp->to($from);
+ $smtp->data();
+ $smtp->datasend($mail);
+ $smtp->dataend();
+ $smtp->quit;
+ return 1;
+ } ## end if ( $deliver...
+ elsif ( $deliver eq 'mbox' ) {
+ open( MBOX, ">>$spool$localname" )
+ or die "Can't open Mailbox of $localname!\n";
+ print MBOX $mail;
+ close MBOX;
+ return 1;
+ } ## end elsif ( $deliver...
+ else {
+ return 0;
+ }
+} ## end sub fileMail
+
+sub fetchFile{
+# fetches via t-online the complete mail with headers and attachments as file. The file
+# isn't compatible to mbox. Please, adjust by yourself.
+# Create a unique ID at the main for-loop - just the content is
+# returned by this function, the filename has to be done by yourself.
+
+ my ( $url, $mail_id ) = @_;
+ my $resp =
+ $ua->get( $url
+ . "main.cgp?MAIL[0]="
+ . $mail_id
+ . "&Speichern.x=1&Speichern.y=1" );
+ my $mail;
+
+ if ( $resp->is_redirect() ) {
+ my $mail = $ua->get( $resp->headers()->{'location'} );
+ return $mail->content();
+ } else {
+ return $resp->content();
+ }
+} ## end sub fetchFile
+
+
diff --git a/z-distfiles/scripts-gw/tripUpdate b/z-distfiles/scripts-gw/tripUpdate
new file mode 100755
index 0000000..3eb69e8
--- /dev/null
+++ b/z-distfiles/scripts-gw/tripUpdate
@@ -0,0 +1,5 @@
+#!/bin/bash
+DIR=/var/lib/tripwire/report
+HOST=`hostname -s`
+LAST_REPORT=`ls -1t $DIR/$HOST-*.twr | head -n 1`
+tripwire --update --twrfile "$LAST_REPORT"