LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-07-2008, 04:01 AM   #1
lovelord
LQ Newbie
 
Registered: Apr 2008
Posts: 4

Rep: Reputation: 0
Exclamation POSTCONF -E /or/ SED & CAT?


Hi all linux gurus,

i'm a little newbie in linux yet, but i'm trying to configure a script that allow simply modifing a text file (we'll call it spam-server.txt) to change the /etc/postfix/mainf.cf

I know that some could be modified by "postconf -e" command, but, perhaps, not my case, 'couse i'm trying to modify "smtpd_recipient_restrictions" line to add a series of checks. Tryed this

Code:
postconf -e 'smtpd_recipient_restrictions= `cat spam-server.txt`'
wrong result ...

So i've a file containing all check to add (spam-server.txt) and what i was supposed to do is something like

Code:
sed 's/,permit/`cat spam-server.txt`&/g' /testing/main.cf > /testing/main.cf.new
so the sed command search for ",permit" line and add before the spam-server.txt text.... or maybe, this is what i supposed it could do... but when i go searching in /testing/main.cf.net can find only this line:

Code:
smtpd_recipient_restrictions = `cat spam-server.txt`,permit
surely something missundertanding... can someone help me?

PS: sorry newbie question

Last edited by lovelord; 04-07-2008 at 04:13 AM.
 
Old 04-07-2008, 04:30 AM   #2
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
I've simply put this in my main.cf file:-
Code:
smtpd_client_restrictions = permit_mynetworks, reject_rbl_client zen.spamhaus.org, reject_rbl_client cbl.abuseat.org, reject_rbl_client bl.spamcop.net, reject_rbl_client list.dsbl.org, reject_rbl_client dnsbl.njabl.org, reject_rbl_client dnsbl.sorbs.net, permit
Any reason why you want the list in a txt file?
 
Old 04-07-2008, 04:48 AM   #3
lovelord
LQ Newbie
 
Registered: Apr 2008
Posts: 4

Original Poster
Rep: Reputation: 0
hi,

i want a list in a text file becouse we are an isp provider, we have a lot of computers in housing and many customers have an "home mail server" so the idea is:

- create a text file contains rules
- do a script that download this file in each client once a day, read it and modify main.cf if any changes are done to the original one, restart postfix program
- add script to any client crontab

so , becouse it happens that sometimes we change this parameters, changing simple one file in our server any client will download the new one and upgrade itself.
 
Old 04-07-2008, 04:54 AM   #4
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
Then I would build a new main.cf file on the fly each time you want to restart postfix. Something like:-
Code:
cp main.cf.template main.cf
echo "smtpd_client_restrictions = " $(cat yourfile.txt) ",permit >> main.cf
service postfix restart
 
Old 04-07-2008, 05:03 AM   #5
lovelord
LQ Newbie
 
Registered: Apr 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by blacky_5251 View Post
Then I would build a new main.cf file on the fly each time you want to restart postfix. Something like:-
Code:
cp main.cf.template main.cf
echo "smtpd_client_restrictions = " $(cat yourfile.txt) ",permit >> main.cf
service postfix restart
This could be an idea, but doin' this my main.cf should be contains two smtpd_client_restrictions entryes, don't it?

what i could do is:

Code:
export DATA=`date +%Y%m%d%H$M%S`
cp /etc/postfix/main.cf /etc/postfix/main.cf.$DATA

# FIND AND CUT SMTPD_CLIENT_RESTRINCTIONS LINE

echo "smtpd_client_restrictions = " $(cat yourfile.txt) ",permit >> main.cf
service postfix restart
This could be interesting, but how to search and cut the line in main.cf file?
 
Old 04-07-2008, 05:07 AM   #6
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
I wasn't clear enough. The main.cf.template file that I suggest you copy to main.cf and then append to, would NOT contain the smtpd_client_restrictions entry - it would contain everything except that.
 
Old 04-07-2008, 05:14 AM   #7
lovelord
LQ Newbie
 
Registered: Apr 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by blacky_5251 View Post
I wasn't clear enough. The main.cf.template file that I suggest you copy to main.cf and then append to, would NOT contain the smtpd_client_restrictions entry - it would contain everything except that.
LoL,

this correct, it's Monday Morning
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
filesize limit on 'cat $file | sed > $file' drkstr Linux - Software 2 07-10-2006 02:47 AM
Cat and Sed Command Help. vidyashankara Linux - General 22 06-23-2006 01:32 PM
sed and escaping & in something like: echo $y | sed 's/&/_/g' prx Programming 7 02-03-2005 11:00 PM
less, cat, sed or what ebasi Linux - Software 8 07-28-2004 03:26 AM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration