Current time: 11-23-2024, 05:39 PM Hello There, Guest! (LoginRegister)


Post Reply 
script help please
Author Message
ChrisJones Offline
Newbie
*

Posts: 9
Joined: Nov 2009
Reputation: 0
Post: #1
script help please
this is what i want to do...
generate a greylist logfile for each domain , this is what the current manual command looks like.
Code:
cat /var/log/syslog | grep domain.co.uk |postgreyreport --nosingle_line --check_sender=mx,a --show_tries --separate_by_subnet=.:===========================================================​====================================\n. >/var/www/virtual/domain.co.uk/htdocs/postgrey.log

i think a command something like this could work
Code:
cat /var/log/syslog | grep $domain |postgreyreport --nosingle_line --check_sender=mx,a --show_tries --separate_by_subnet=.:===========================================================​====================================\n. >/var/www/virtual/$domain/htdocs/postgrey.log

the output really shouldnt be in a public folder unless protected. but im not very good at scripting tbh

at the moment i currenly have a command that lists all domains.
any help would be appreciated
11-14-2009 04:35 AM
Find all posts by this user Quote this message in a reply
Knut Offline
Member
***

Posts: 736
Joined: Nov 2006
Reputation: 10
Post: #2
RE: script help please
short and untested:

Code:
#!/bin/bash

FOLDER="/var/mail/virtual/"

for domain in $(ls $FOLDER); do
  if test -d /var/www/virtual/$domain/htdocs; then
    echo "Report for Domain $domain"
    cat /var/log/syslog | grep $domain |postgreyreport --nosingle_line -check_sender=mx,a --show_tries > /var/www/virtual/$domain/htdocs/postgrey.log
  fi

done

Knut
(This post was last modified: 11-14-2009 03:53 PM by Knut.)
11-14-2009 03:53 PM
Find all posts by this user Quote this message in a reply
ChrisJones Offline
Newbie
*

Posts: 9
Joined: Nov 2009
Reputation: 0
Post: #3
RE: script help please
Thanks knut

below is the final script which i called postgreylog , added a cron job to run before syslog has been cleared. Not all systems have mail logging in syslog so customise as required.

Changed where the file is saved a little , might be interesting to get something like this into the users control panel so they can check to see if real mail is being blocked (my wife had 5 email addresses today).

had to change it just a little but overall it does it's job. Thanks for helping

to run script past into your most used editor
and save , then chmod +x it.
run to test.

sample output here
Code:
#!/bin/bash
#postgreylog v1
#This script outputs the blocked mail into a readable logfile for each domain
#Idea Chris Jones 2009
#script written by Knut on isp-control.net forums 2009
#script re-edited by Chris Jones 2009

# Folder gathers the list of domains
FOLDER="/var/mail/virtual/"

#log should be the file you want read by postgrey report
log="/var/log/syslog"

#output edit the output so non-readable on net or post into a protected folder
output="/var/www/virtual/"

#Main script
#I require the .:====== part to make it readable by me it also looks better
for domain in $(ls $FOLDER); do
  if test -d /var/www/virtual/$domain/htdocs; then
    echo "Report for Domain $domain"
    cat $log | grep $domain |postgreyreport --nosingle_line --check_sender=mx,a --show_tries --separate_by_subnet=.:===================================From====================​===============TO=======================:.MailServer-Sending-Mail\ > $output$domain/postgrey.log
  fi

done

Thanks
Chris Jones
(This post was last modified: 11-15-2009 02:57 PM by ChrisJones.)
11-15-2009 02:51 PM
Find all posts by this user Quote this message in a reply
Knut Offline
Member
***

Posts: 736
Joined: Nov 2006
Reputation: 10
Post: #4
RE: script help please
Hi,

you can change the line
Code:
if test -d /var/www/virtual/$domain/htdocs; then
to
Code:
if test -d $output$domain/htdocs; then

Knut
11-15-2009 03:27 PM
Find all posts by this user Quote this message in a reply
ChrisJones Offline
Newbie
*

Posts: 9
Joined: Nov 2009
Reputation: 0
Post: #5
RE: script help please
yeah saw that not too long after , but it was early in the morning for me Smile
11-16-2009 09:59 PM
Find all posts by this user Quote this message in a reply
Knut Offline
Member
***

Posts: 736
Joined: Nov 2006
Reputation: 10
Post: #6
RE: script help please
You know the usermap ? http://www.isp-control.net/forum/usermap.php :-)

Knut
11-16-2009 10:02 PM
Find all posts by this user Quote this message in a reply
ChrisJones Offline
Newbie
*

Posts: 9
Joined: Nov 2009
Reputation: 0
Post: #7
RE: script help please
lol look at the top bubble for uk ,slightly out of place but only a little
11-16-2009 10:37 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)