Browse Source

Greatly enhance Postfix package

Ralf S. Engelschall 24 years ago
parent
commit
f44301f167
2 changed files with 104 additions and 13 deletions
  1. 47 13
      postfix/postfix.spec
  2. 57 0
      postfix/rc.postfix

+ 47 - 13
postfix/postfix.spec

@@ -22,9 +22,10 @@
 ##  SUCH DAMAGE. 
 ##  
 
-%define       V_here    20010228pl05
-%define       V_real    20010228-pl05
-%define       V_tls     0.7.9-20010228-pl04-0.9.6b
+%define       V_here      20010228.5
+%define       V_real      20010228-pl05
+%define       V_tls       0.7.9-20010228-pl04-0.9.6b
+%define       V_pflogsumm 1.0.3
 
 #   package information
 Name:         postfix
@@ -42,13 +43,14 @@ Release:      6
 Source0:      ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix-%{V_real}.tar.gz
 Source1:      ftp://ftp.aet.tu-cottbus.de/pub/postfix_tls/pfixtls-%{V_tls}.tar.gz
 Source2:      ftp://ftp.openpkg.org/DST/postfix/fakesyslog.tar.gz
-Source3:      rc.postfix
+Source3:      http://jimsun.linxnet.com/downloads/pflogsumm-%{V_pflogsumm}.pl
+Source4:      rc.postfix
 
 #   build information
 Prefix:       %{l_prefix}
 BuildRoot:    %{l_buildroot}
-BuildPreReq:  OpenPKG, openpkg >= 0.9-30, db, openssl
-PreReq:       OpenPKG, openpkg >= 0.9-30, db, openssl
+BuildPreReq:  OpenPKG, openpkg >= 0.9-30, db, openssl, perl >= 5.6.1-10, pcre
+PreReq:       OpenPKG, openpkg >= 0.9-30, db, openssl, perl >= 5.6.1-10, pcre
 AutoReq:      no
 AutoReqProv:  no
 Provides:     MTA
@@ -63,6 +65,12 @@ Provides:     MTA
     %setup2 -q -T -D -a 2
     cd postfix-%{V_real}
     %{l_patch} -p1 < ../pfixtls-%{V_tls}/pfixtls.diff
+    %{l_rpmtool} subst \
+        's/var_config_dir, /var_command_dir, /' \
+        -- src/postfix/postfix.c
+    %{l_rpmtool} subst \
+        's;config_directory/postfix-script;command_directory/postfix-script;' \
+        -- conf/postfix-script*
 
 %build
 
@@ -72,7 +80,7 @@ Provides:     MTA
       CC="%{l_cc}" \
       CFLAGS="%{l_cflags -O}" \
       ./configure \
-          --with-logfile=%{l_prefix}/var/postfix/postfix.log
+          --with-logfile=%{l_prefix}/var/postfix/log/postfix.log
       %{l_make} %{l_mflags} 
     )
 
@@ -83,9 +91,9 @@ Provides:     MTA
     CCARGS="$CCARGS %{l_cflags -O}"
     CCARGS="$CCARGS -I%{l_prefix}/include"
     CCARGS="$CCARGS -DDEF_CONFIG_DIR=\\\\\\\"%{l_prefix}/etc/postfix\\\\\\\""
-    CCARGS="$CCARGS -DHAS_DB -DHAS_SSL"
+    CCARGS="$CCARGS -DHAS_PCRE -DHAS_DB -DHAS_SSL"
     AUXLIBS=""
-    AUXLIBS="$AUXLIBS -L%{l_prefix}/lib -ldb -lssl -lcrypto"
+    AUXLIBS="$AUXLIBS -L%{l_prefix}/lib -ldb -lssl -lcrypto -lpcre"
     AUXLIBS="$AUXLIBS -L$fakesyslogdir -lfakesyslog"
     %{l_make} %{l_mflags} makefiles \
         CC="%{l_cc}" CCARGS="$CCARGS" AUXLIBS="$AUXLIBS"
@@ -109,6 +117,7 @@ Provides:     MTA
       mailq_path=%{l_prefix}/sbin/mailq \
       mail_user=%{l_fsusr} \
       manpages=%{l_prefix}/man \
+      setgid=no \
       sh INSTALL.sh </dev/null
     )
     
@@ -128,17 +137,35 @@ Provides:     MTA
         -- $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/main.cf
     rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/*.orig
     rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/LICENSE
+    rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/install.cf
+    mv $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script \
+       $RPM_BUILD_ROOT%{l_prefix}/sbin/postfix-script
+    rm -f $RPM_BUILD_ROOT%{l_prefix}/etc/postfix/postfix-script*
+    ( cd $RPM_BUILD_ROOT%{l_prefix}/etc/postfix
+      %{l_shtool} mkdir -f -p -m 755 sample
+      for cfg in access aliases canonical pcre_table regexp_table \
+                 relocated sample-* transport virtual main.cf.default; do
+          mv $cfg sample/
+      done 
+    )
 
     #   pre-create variable stuff
     ( cd $RPM_BUILD_ROOT%{l_prefix}/var/postfix
       %{l_shtool} mkdir -f -p -m 700 \
           active bounce corrupt defer deferred flush incoming private saved
       %{l_shtool} mkdir -f -p -m 755 \
-          pid public queue
+          log pid public queue
       %{l_shtool} install -c -m 755 \
-          /dev/null postfix.log
+          /dev/null log/postfix.log
+      %{l_shtool} install -c -m 755 \
+          /dev/null log/postfix.sum
     ) 
 
+    #   install addons
+    %{l_shtool} install -c -m 755 \
+        -e 's;/usr/bin/perl;%{l_prefix}/bin/perl;g' \
+        %{SOURCE3} $RPM_BUILD_ROOT%{l_prefix}/sbin/pflogsumm
+
     #   install run-command script
     %{l_shtool} mkdir -f -p -m 755 \
         $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
@@ -149,8 +176,8 @@ Provides:     MTA
     #   generate file list
     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
         %{l_files_std} \
-        '%config %attr(-,root,%{l_fsgrp}) %{l_prefix}/etc/postfix/*' \
-        '%dir %attr(-,root,%{l_fsgrp}) %{l_prefix}/etc/postfix' \
+        '%config %attr(-,root,%{l_fsgrp}) %{l_prefix}/etc/postfix/*.cf' \
+        '%attr(-,root,%{l_fsgrp}) %{l_prefix}/etc/postfix' \
         '%attr(-,root,%{l_fsgrp}) %{l_prefix}/libexec/postfix/*' \
         '%dir %attr(-,root,%{l_fsgrp}) %{l_prefix}/libexec/postfix' \
         '%dir %attr(-,root,%{l_fsgrp}) %{l_prefix}/var/postfix'
@@ -160,3 +187,10 @@ Provides:     MTA
 %clean
     # rm -rf $RPM_BUILD_ROOT
 
+%preun
+    $RPM_INSTALL_PREFIX/sbin/postfix stop
+    rm -rf $RPM_INSTALL_PREFIX/etc/postfix/prng_exch
+    rm -rf $RPM_INSTALL_PREFIX/var/postfix/pid/*
+    rm -rf $RPM_INSTALL_PREFIX/var/postfix/private/*
+    rm -rf $RPM_INSTALL_PREFIX/var/postfix/public/*
+

+ 57 - 0
postfix/rc.postfix

@@ -0,0 +1,57 @@
+#!@l_prefix@/lib/rpm/bash @l_prefix@/etc/rc
+##
+##  rc.postfix -- Run-Commands for Postfix Daemon
+##
+
+%config
+    postfix_enable="yes"
+    postfix_log_prolog="true"
+    postfix_log_epilog="true"
+    postfix_log_numfiles="10"
+    postfix_log_minsize="1M"
+    postfix_log_complevel="9"
+    postfix_sum_flags=""
+
+%start -p 200 -u root
+    opServiceEnabled postfix || exit 0
+    @l_prefix@/sbin/postfix start
+
+%stop -p 200 -u root
+    opServiceEnabled postfix || exit 0
+    @l_prefix@/sbin/postfix stop
+
+%restart -u root
+    opServiceEnabled postfix || exit 0
+    @l_prefix@/sbin/postfix stop
+    sleep 2
+    @l_prefix@/sbin/postfix start
+
+%reload -u root
+    opServiceEnabled postfix || exit 0
+    @l_prefix@/sbin/postfix reload
+
+%daily -u root
+    opServiceEnabled postfix || exit 0
+
+    #   generate logfile summary
+    shtool rotate -f \
+        -n${postfix_log_numfiles} -s0
+        -z${postfix_log_complevel} -o@l_fsusr@ -o@l_fsgrp@ -m644 \
+        @l_prefix@/var/postfix/log/postfix.sum
+    logfiles="@l_prefix@/var/postfix/log/postfix.log"
+    if [ -f "@l_prefix@/var/postfix/log/postfix.log.0" ]; then
+        logfiles="$logfiles @l_prefix@/var/postfix/log/postfix.log.0"
+    fi
+    @l_prefix@/sbin/pflogsumm -d yesterday -h 10 -u 10 -i \
+        --iso_date_time --problems_first --smtpd_stats \
+        ${postfix_sum_flags} \
+        ${logfiles} >@l_prefix@/var/postfix/log/postfix.sum
+
+    #   rotate logfile
+    shtool rotate -f \
+        -n${postfix_log_numfiles} -s${postfix_log_minsize} -d
+        -z${postfix_log_complevel} -o@l_fsusr@ -o@l_fsgrp@ -m644 \
+        -P "$postfix_log_prolog" \
+        -E "$postfix_log_epilog" \
+        @l_prefix@/var/postfix/log/postfix.log
+