head 1.8; access; symbols OPENPKG_E1_MP_HEAD:1.5 OPENPKG_E1_MP:1.5 OPENPKG_E1_MP_2_STABLE:1.2.6.1 OPENPKG_E1_FP:1.2.6.1 OPENPKG_2_STABLE_MP:1.5 OPENPKG_2_STABLE_20061018:1.2.6.1 OPENPKG_2_STABLE_20060622:1.2 OPENPKG_2_STABLE:1.2.0.6 OPENPKG_2_STABLE_BP:1.2 OPENPKG_2_5_RELEASE:1.2 OPENPKG_2_5_SOLID:1.2.0.4 OPENPKG_2_5_SOLID_BP:1.2 OPENPKG_2_4_RELEASE:1.2 OPENPKG_2_4_SOLID:1.2.0.2 OPENPKG_2_4_SOLID_BP:1.2 OPENPKG_CW_FP:1.2; locks; strict; comment @# @; 1.8 date 2007.12.29.15.18.24; author tho; state Exp; branches; next 1.7; commitid ODLvlZLVHAJz3lLs; 1.7 date 2007.12.05.13.16.21; author tho; state Exp; branches; next 1.6; commitid kHIhkdpaQh5x9fIs; 1.6 date 2007.12.05.09.29.54; author tho; state Exp; branches; next 1.5; commitid ff6zbHrMevkRTdIs; 1.5 date 2006.11.24.16.34.10; author rse; state Exp; branches; next 1.4; commitid 8eoZqfkQhEmIkWVr; 1.4 date 2006.11.24.12.50.34; author tho; state Exp; branches; next 1.3; commitid 3rntZKg3vU326VVr; 1.3 date 2006.08.25.19.16.25; author rse; state Exp; branches; next 1.2; commitid Tvsj1UyQ8rQ89gKr; 1.2 date 2005.03.11.09.31.37; author tho; state Exp; branches 1.2.6.1; next 1.1; 1.1 date 2005.03.10.13.07.38; author tho; state Exp; branches; next ; 1.2.6.1 date 2006.10.16.14.49.55; author rse; state Exp; branches; next 1.2.6.2; commitid iZxwRSmmWscPXUQr; 1.2.6.2 date 2006.12.22.19.13.21; author thl; state Exp; branches; next ; commitid 2LefOfqsS8nsjyZr; desc @@ 1.8 log @unfortunately the PID file contains two lines and only the first contains the real PID and we don't want to kill some random process IDs since we are run as root here @ text @#!@@l_prefix@@/bin/openpkg rc ## ## rc.fetchmail -- Run-Commands ## %config fetchmail_enable="$openpkg_rc_def" fetchmail_daemon="no" fetchmail_log_prolog="true" fetchmail_log_epilog="true" fetchmail_log_numfiles="10" fetchmail_log_minsize="1M" fetchmail_log_complevel="9" %common fetchmail_rc="@@l_prefix@@/etc/fetchmail/fetchmailrc" 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" fetchmail_signal () { [ -f $fetchmail_pidfile ] && kill -$1 `head -1 $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' \ -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" fetchmail_active="no" rcService fetchmail enable yes && \ fetchmail_signal 0 && fetchmail_active="yes" echo "fetchmail_enable=\"$fetchmail_enable\"" echo "fetchmail_usable=\"$fetchmail_usable\"" echo "fetchmail_active=\"$fetchmail_active\"" %start -p 200 -u @@l_susr@@ rcService fetchmail enable yes || exit 0 rcService fetchmail active yes && exit 0 rcVarIsYes fetchmail_daemon || exit 0 fetchmail_reconfigure @@l_prefix@@/bin/fetchmail \ -f ${fetchmail_rc} \ -L ${fetchmail_logfile} \ --pidfile ${fetchmail_pidfile} %stop -p 800 -u @@l_susr@@ rcService fetchmail enable yes || exit 0 rcService fetchmail active no && exit 0 rcVarIsYes fetchmail_daemon || exit 0 fetchmail_signal 15 rm -f ${fetchmail_pidfile} 2>/dev/null || true %restart -p 200 -u @@l_susr@@ rcService fetchmail enable yes || exit 0 rcService fetchmail active no && exit 0 rcVarIsYes fetchmail_daemon || exit 0 rc fetchmail stop start %quarterly -p 800 -u @@l_susr@@ rcService fetchmail enable yes || exit 0 rcVarIsYes fetchmail_daemon || exit 0 fetchmail_reconfigure %daily -p 800 -u @@l_susr@@ rcService fetchmail enable yes || exit 0 rcVarIsYes fetchmail_daemon || exit 0 shtool rotate -f \ -n ${fetchmail_log_numfiles} -s ${fetchmail_log_minsize} -d \ -z ${fetchmail_log_complevel} -m 644 -o @@l_susr@@ -g @@l_mgrp@@ \ -P "${fetchmail_log_prolog}" \ -E "${fetchmail_log_epilog}; rc fetchmail restart" \ ${fetchmail_logfile} @ 1.7 log @ignore lines with only spaces as well @ text @d22 1 a22 1 [ -f $fetchmail_pidfile ] && kill -$1 `cat $fetchmail_pidfile` @ 1.6 log @in the fetchmail.users file blank lines should be skipped as well @ text @d36 1 a36 1 -e '/^$/d' <$fetchmail_users |\ @ 1.5 log @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 @ text @d35 2 a36 1 sed -e '/^[[:space:]]*#.*/d' <$fetchmail_users |\ @ 1.4 log @BugFix: we have to tell it where to put the PID file; --quit just starts a new daemon which first kills the old one, which is not the desired behavior, so use kill instead. Please port to stable. @ text @d14 2 a15 1 fetchmail_log_file="@@l_prefix@@/var/fetchmail/fetchmail.log" d17 1 a17 2 fetchmail_rc_master="@@l_prefix@@/etc/fetchmail/fetchmail.master" fetchmail_rc_numfiles="100" d19 1 a20 2 %common d24 44 d82 4 a85 2 rc fetchmail quarterly @@l_prefix@@/bin/fetchmail -f ${fetchmail_rc} -L ${fetchmail_log_file} \ a100 6 %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 d104 1 a104 44 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 d114 1 a114 2 ${fetchmail_log_file} exit 0 @ 1.3 log @replace '@@l_prefix@@/lib/openpkg/bash @@l_prefix@@/etc/rc' in shebang with '@@l_prefix@@/bin/openpkg rc' to allow people who run the rc.xxx scripts directly (as executables) to leverage from the Set-UID functionality @ text @d40 2 a41 1 @@l_prefix@@/bin/fetchmail -f ${fetchmail_rc} -L ${fetchmail_log_file} d47 1 a47 1 @@l_prefix@@/bin/fetchmail --quit @ 1.2 log @show all forbidden statements in final rc file @ text @d1 1 a1 1 #!@@l_prefix@@/lib/openpkg/bash @@l_prefix@@/etc/rc @ 1.2.6.1 log @Mass merge from CURRENT to 2-STABLE (all packages except those of JUNK class) @ text @d1 1 a1 1 #!@@l_prefix@@/bin/openpkg rc @ 1.2.6.2 log @MFC: make up leeway for 2_STABLE by virtue of build-time results @ text @d14 1 a14 2 %common d16 2 a17 1 fetchmail_master="@@l_prefix@@/etc/fetchmail/fetchmail.master" a18 1 fetchmail_logfile="@@l_prefix@@/var/fetchmail/fetchmail.log" d20 2 a24 44 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 } d39 2 a40 5 fetchmail_reconfigure @@l_prefix@@/bin/fetchmail \ -f ${fetchmail_rc} \ -L ${fetchmail_logfile} \ --pidfile ${fetchmail_pidfile} d46 1 a46 1 fetchmail_signal 15 d55 6 d64 44 a107 1 fetchmail_reconfigure d117 2 a118 1 ${fetchmail_logfile} @ 1.1 log @first version of poor man's global fetchmail @ text @d71 1 @