LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   POSTCONF -E /or/ SED & CAT? (https://www.linuxquestions.org/questions/linux-server-73/postconf-e-or-sed-and-cat-633602/)

lovelord 04-07-2008 04:01 AM

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 :rolleyes:

blacky_5251 04-07-2008 04:30 AM

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?

lovelord 04-07-2008 04:48 AM

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.

blacky_5251 04-07-2008 04:54 AM

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


lovelord 04-07-2008 05:03 AM

Quote:

Originally Posted by blacky_5251 (Post 3113275)
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?

blacky_5251 04-07-2008 05:07 AM

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.

lovelord 04-07-2008 05:14 AM

Quote:

Originally Posted by blacky_5251 (Post 3113285)
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 :p


All times are GMT -5. The time now is 03:40 PM.