@ -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}