#!/usr/bin/perl -wT #---------------------------------------------------------------------- # affa watchdog testmail # # This script is part of the smeserver-affa package # # Copyright (C) 2008 Michael Weinberger, neddix Stuttgart, Germany # # 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. # #---------------------------------------------------------------------- use strict; use Errno; use esmith::DB::db; use esmith::ConfigDB; use File::Path; use Mail::Send; use constant _JOBNAME=>'nx scheduled'; use constant _EMAIL=>'mweinber@neddix.de'; use constant _BACKUPHOST=>'backup.neddix.de (172.22.32.2)'; use constant _WDSCRIPT=>'affa-watchdog-nx-172.22.32.6'; BEGIN { # Clear PATH and related environment variables so that calls to # external programs do not cause results to be tainted. See # "perlsec" manual page for details. $ENV {'BASH_ENV'} = ''; $ENV {'PATH'} = ''; } sub sendEmail(); sendEmail(); unlink( "/tmp/".(_WDSCRIPT) ); exit 0; sub sendEmail() { my $config = esmith::ConfigDB->open_ro or die "Could not open config db."; my $LocalIP=$config->get("LocalIP")->value; my $SystemName=$config->get("SystemName")->value; my $DomainName=$config->get("DomainName")->value; my $msg = new Mail::Send; $msg->subject("Testmail for affa job '".(_JOBNAME)."' on ".(_BACKUPHOST).""); $msg->to(_EMAIL); $msg->set("From", "\"Affa watchdog on $SystemName.$DomainName ($LocalIP)\" "); my $fh = $msg->open; print $fh "It works!\n"; $fh->close; }