I added a few echos, guessed at what was happening and below you will see a nice little script which shows "useless" parameters in main.cf

On 12/24/2012 05:26 AM, mouss wrote:
Le 23/12/2012 15:28, Robert Moskowitz a écrit :
On 12/23/2012 09:20 AM, Noel Jones wrote:
On 12/23/2012 7:17 AM, Robert Moskowitz wrote:
You can chase these with something like:

#  postconf -n | while read parameter equal value; do
       default_value=`postconf -d $parameter 2>&1`;
        if [ "$value" = "$default_value" ]; then
               echo "NOTICE: Useless setting: $parameter = $value";
       fi;
done

I have been running this against the base Centos 6 install that has
a main.cf with lots of comments and a few parameter lines.

postconf -n shows about 20 parameters, and when I compare these
against postconf -d only 9 of them are different.
That sounds about right. A basic postfix install needs only a few
non-default settings.


parameters like mailq_path is now /usr/bin/mailq.postfix and the
default is /usr/bin/mailq
sounds reasonable.

I look at the script and I am not able to tell what is wrong; can
you help me get it right?  I think this is a real useful tool.
It's unclear what problem you are having.  Please explain.
When I run the script shown above, there is no output.  Yet I know
there are lines in the main.cf that differ from the defaults.
That is there are 9 lines shown in the -n option that are different
from shown in the -d option.  I would think that the above script
should have printed those lines.
No. the only output of the script is the one in the 'echo' line: it only
prints anything if the value is the same in main.cf and in `postconf
-d`.  To see local settings, use 'postconf -n'. that's its job.

If you really insist, here is a modified version of the script:

postconf -n | while read parameter equal value; do
       default_value=`postconf -d $parameter 2>&1`;
        if [ "$value" = "$default_value" ]; then
               echo "NOTICE: Useless setting: $parameter = $value";
       else
               echo "$parameter = $value"
       fi;
done

postconf -n | while read parameter equal value; do
      default_value=`postconf -d $parameter 2>&1`;
       if [ "$parameter = $value" = "$default_value" ]; then
              echo "NOTICE: Useless setting: $parameter = $value";
      fi;
done


But

postconf -n | while read parameter equal value; do
      default_value=`postconf -d $parameter`;
       if [ "$parameter = $value" = "$default_value" ]; then
              echo "NOTICE: Useless setting: $parameter = $value";
      fi;
done


also works. But this gets down to your comment that the "2>&1" avoids false postitives. I don't know how to include that in the if statement.


Reply via email to