Browse Source

My today's "either break everything or make it even better" commit: - globally cleanup styles of configuration files and scripts - make the fetchmailrc generation process more robust, concise and portable - remove %reload as just running fetchmail without anything else doesn't seem to be a real "reload" operation to me - add a bunch of additional comments - move most variables from %config to %common as they are not really intended to be changed by the user

master
parent
commit
4ffe0cfd6e
  1. 24
      fetchmail/fetchmail.master
  2. 34
      fetchmail/fetchmail.spec
  3. 11
      fetchmail/fetchmail.users
  4. 113
      fetchmail/rc.fetchmail

24
fetchmail/fetchmail.master

@ -1,11 +1,9 @@
#
# Put your global fetchmail daemon options in
# the fetchmail.master file.
# Do not edit the fetchmailrc file directly
#
#
# Global Options
#
##
## fetchmail.master -- fetchmail(1) master option configuration file
##
## NOTICE: put your global fetchmail(1) daemon options here
## instead of editin the fetchmailrc file directly!
##
# set daemon mode and poll every XX seconds
set daemon 160
@ -13,18 +11,18 @@ set daemon 160
# where to send anything to
set postmaster postmaster@localhost
# Direct error mail to postmaster
# direct error mail to postmaster
set no bouncemail
# Send spam bounces top postmaster
# send spam bounces top postmaster
set no spambounce
# Name of a file to dump error and status messages to
# name of a file to dump error and status messages
set logfile @l_prefix@/var/fetchmail/fetchmail.log
# Name of the file to store UID lists in
# name of the file to store UID lists
set idfile @l_prefix@/var/fetchmail/fetchmail.uid
# Turn off error logging through syslog
# turn off syslog based error logging
set no syslog

34
fetchmail/fetchmail.spec

@ -78,6 +78,7 @@ AutoReqProv: no
%patch -p0
%build
# configure program
CC="%{l_cc}" \
CFLAGS="%{l_cflags -O}" \
CPPFLAGS="%{l_cppflags}" \
@ -89,31 +90,42 @@ AutoReqProv: no
--without-kerberos5 \
--without-hesiod \
--disable-nls
# build program
%{l_make} %{l_mflags}
%install
# install program
rm -rf $RPM_BUILD_ROOT
%{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
# strip down installation
strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
%if "%{with_conf}" != "yes"
rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/fetchmailconf
rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/fetchmailconf.1
rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/python
%endif
# create global service run-time directory
%{l_shtool} mkdir -f -p -m 755 \
$RPM_BUILD_ROOT%{l_prefix}/var/fetchmail \
$RPM_BUILD_ROOT%{l_prefix}/etc/fetchmail \
$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
$RPM_BUILD_ROOT%{l_prefix}/var/fetchmail
# install global service configuration files
%{l_shtool} mkdir -f -p -m 755 \
$RPM_BUILD_ROOT%{l_prefix}/etc/fetchmail
%{l_shtool} install -c -m 644 %{l_value -s -a} \
%{SOURCE fetchmail.master} \
%{SOURCE fetchmail.users} \
%{SOURCE fetchmail.master} %{SOURCE fetchmail.users} \
$RPM_BUILD_ROOT%{l_prefix}/etc/fetchmail/
# install run-command script
%{l_shtool} mkdir -f -p -m 755 \
$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
%{l_shtool} install -c -m 644 %{l_value -s -a} \
%{SOURCE rc.fetchmail} \
$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
%if "%{with_conf}" != "yes"
rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/fetchmailconf
rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/fetchmailconf.1
rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/python
%endif
# determine installation files
%{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
%{l_files_std} \
'%config %{l_prefix}/etc/fetchmail/fetchmail.master' \

11
fetchmail/fetchmail.users

@ -1,4 +1,7 @@
#
# put here the login names of users who are allowed to use the global service
# one per line
#
##
## fetchmail.master -- fetchmail(1) username configuration file
##
## NOTICE: put here (one per line) the login names of users
## who are allowed to use the global fetchmail(1) service
##

113
fetchmail/rc.fetchmail

@ -11,17 +11,60 @@
fetchmail_log_numfiles="10"
fetchmail_log_minsize="1M"
fetchmail_log_complevel="9"
fetchmail_log_file="@l_prefix@/var/fetchmail/fetchmail.log"
%common
fetchmail_rc="@l_prefix@/etc/fetchmail/fetchmailrc"
fetchmail_rc_master="@l_prefix@/etc/fetchmail/fetchmail.master"
fetchmail_rc_numfiles="100"
fetchmail_master="@l_prefix@/etc/fetchmail/fetchmail.master"
fetchmail_users="@l_prefix@/etc/fetchmail/fetchmail.users"
fetchmail_logfile="@l_prefix@/var/fetchmail/fetchmail.log"
fetchmail_pidfile="@l_prefix@/var/fetchmail/fetchmail.pid"
%common
fetchmail_signal () {
[ -f $fetchmail_pidfile ] && kill -$1 `cat $fetchmail_pidfile`
}
fetchmail_reconfigure () {
umask 077
rcTmp -i
tmpfile1=`rcTmp -f -n tmp1`
tmpfile2=`rcTmp -f -n tmp2`
( echo "## **** AUTOMATICALLY GENERATED FILE -- DO NOT EDIT! ****"
echo ""
if [ -s $fetchmail_master ]; then
cat $fetchmail_master
fi
if [ -s $fetchmail_users ]; then
sed -e '/^[[:space:]]*#.*/d' <$fetchmail_users |\
while read user comment; do
fetchmailrc=`eval echo ~$user`/.fetchmailrc
if [ -s $fetchmailrc ]; then
sed <$fetchmailrc \
-e '/^[[:space:]]*set[[:space:]].*/s;^;X##FORBIDDEN##;' \
-e '/.*[[:space:]]preconnect[[:space:]].*/s;^;X##FORBIDDEN##;' \
-e '/.*[[:space:]]postconnect[[:space:]].*/s;^;X##FORBIDDEN##;' \
-e '/.*[[:space:]]idle[[:space:]].*/s;^;X##FORBIDDEN##;' \
-e '/.*[[:space:]]monitor[[:space:]].*/s;^;X##FORBIDDEN##;' \
-e '/.*[[:space:]]plugin[[:space:]].*/s;^;X##FORBIDDEN##;' \
-e '/.*[[:space:]]plugout[[:space:]].*/s;^;X##FORBIDDEN##;' \
-e '/^[[:space:]]*poll[[:space:]].*/s;\(.*\);X\1;' \
-e '/^[[:space:]]*server[[:space:]].*/s;\(.*\);X\1;' \
-e '/^[[:space:]]*#.*/s;\(.*\);X\1;' \
-e '/^X.*/!d' \
-e '/^X.*/s;^X;;' \
>$tmpfile1
if @l_prefix@/bin/fetchmail --configdump -f $tmpfile1 >/dev/null 2>&1; then
cat $tmpfile1
fi
fi
done
fi
) >$tmpfile2
if cmp $fetchmail_rc $tmpfile2 >/dev/null 2>&1; then
:
else
cp $tmpfile2 $fetchmail_rc
chmod 600 $fetchmail_rc
fi
rcTmp -k
}
%status -u @l_susr@ -o
fetchmail_usable="unknown"
@ -36,8 +79,10 @@
rcService fetchmail enable yes || exit 0
rcService fetchmail active yes && exit 0
rcVarIsYes fetchmail_daemon || exit 0
rc fetchmail quarterly
@l_prefix@/bin/fetchmail -f ${fetchmail_rc} -L ${fetchmail_log_file} \
fetchmail_reconfigure
@l_prefix@/bin/fetchmail \
-f ${fetchmail_rc} \
-L ${fetchmail_logfile} \
--pidfile ${fetchmail_pidfile}
%stop -p 800 -u @l_susr@
@ -53,59 +98,10 @@
rcVarIsYes fetchmail_daemon || exit 0
rc fetchmail stop start
%reload -p 200 -u @l_susr@
rcService fetchmail enable yes || exit 0
rcService fetchmail active no && exit 0
rcVarIsYes fetchmail_daemon || exit 0
@l_prefix@/bin/fetchmail
%quarterly -p 800 -u @l_susr@
rcService fetchmail enable yes || exit 0
rcVarIsYes fetchmail_daemon || exit 0
if [ -s ${fetchmail_users} ] ; then
cat ${fetchmail_users} | shtool subst \
-e '/^[[:space:]]*#.*/d' | while read user comment
do
urc=`eval echo ~$user`/.fetchmailrc
if [ -s $urc ] ; then
cat $urc | shtool subst \
-e '/^[[:space:]]*set[[:space:]].*/s;^;X##FORBIDDEN##;' \
-e '/.*[[:space:]]preconnect[[:space:]].*/s;^;X##FORBIDDEN##;' \
-e '/.*[[:space:]]postconnect[[:space:]].*/s;^;X##FORBIDDEN##;' \
-e '/.*[[:space:]]idle[[:space:]].*/s;^;X##FORBIDDEN##;' \
-e '/.*[[:space:]]monitor[[:space:]].*/s;^;X##FORBIDDEN##;' \
-e '/.*[[:space:]]plugin[[:space:]].*/s;^;X##FORBIDDEN##;' \
-e '/.*[[:space:]]plugout[[:space:]].*/s;^;X##FORBIDDEN##;' \
-e '/^[[:space:]]*poll[[:space:]].*/s;\(.*\);X\1;' \
-e '/^[[:space:]]*server[[:space:]].*/s;\(.*\);X\1;' \
-e '/^[[:space:]]*#.*/s;\(.*\);X\1;' \
-e '/^X.*/!d' \
-e '/^X.*/s;^X;;' \
>/tmp/$user.$$
chmod 0600 /tmp/$user.$$
if @l_prefix@/bin/fetchmail --configdump -f /tmp/$user.$$ >/dev/null 2>&1; then
cat /tmp/$user.$$
fi
rm /tmp/$user.$$
fi
done >${fetchmail_rc}.tmp
cat ${fetchmail_rc_master} ${fetchmail_rc}.tmp >${fetchmail_rc}.new
rm ${fetchmail_rc}.tmp
chmod 0600 ${fetchmail_rc}.new
if ! cmp -s ${fetchmail_rc} ${fetchmail_rc}.new ; then
shtool rotate -f \
-n ${fetchmail_rc_numfiles} -m 644 -o @l_susr@ -g @l_mgrp@ \
${fetchmail_rc}
mv ${fetchmail_rc}.new ${fetchmail_rc}
fi
rm -f ${fetchmail_rc}.new
else
if [ -s ${fetchmail_rc_master} ] ; then
cp ${fetchmail_rc_master} ${fetchmail_rc}
chmod 0600 ${fetchmail_rc}
fi
fi
exit 0
fetchmail_reconfigure
%daily -p 800 -u @l_susr@
rcService fetchmail enable yes || exit 0
@ -115,6 +111,5 @@
-z ${fetchmail_log_complevel} -m 644 -o @l_susr@ -g @l_mgrp@ \
-P "${fetchmail_log_prolog}" \
-E "${fetchmail_log_epilog}; rc fetchmail restart" \
${fetchmail_log_file}
exit 0
${fetchmail_logfile}

Loading…
Cancel
Save