Re: shtool rotate patch to pass file values to epilog/prolog
On Sun, Sep 21, 2008, Bill Campbell wrote: tatus: RO Content-Length: 2216 Lines: 52 On Sun, Sep 21, 2008, Ralf S. Engelschall wrote: On Fri, Sep 19, 2008, Bill Campbell wrote: The attached patch to the sh.rotate script sets an environment variable ROTATE_LOGFILE with the name of the current file being processed before invoking the epilog or prolog programs. This permits the epilog/prolog script to do things such as calling webalizer to process the file being rotated. The problem is that defining multiple log files in the rc.conf file with lines like the follow cause the epilog/prolog programs to be execute multiple times without knowledge of which file is being processed. apache_log_files=/opkg/var/apache/log/*access*log I first tried having the sh.rotate script add an argument to the eval of the epilog/prolog command, but this does not work when the command is compound as in the rc.apache daily processing: -E ${apache_log_epilog} rc apache reload Creating a new environment variable avoids this problem and cannot break any existing epilog/prolog programs as they will not be aware of the variable. Ok, taken over into my GNU shtool source tree for inclusion into GNU shtool 2.0.9 -- with just a small adjustment: ROTATE_LOGFILE - SHTOOL_ROTATE_LOGFILE to avoid any conflicts. Thanks for your contribution, Bill! I thought you might want to use a more descriptive environment variable, and that get it into the main shtool. Presumably this will make it into the shtool rotate man page? I've now also added two sentences into the manpage about the variables. Ralf S. Engelschall [EMAIL PROTECTED] www.engelschall.com __ OpenPKG http://openpkg.org Developer Communication List openpkg-dev@openpkg.org
Re: shtool rotate patch to pass file values to epilog/prolog
On Fri, Sep 19, 2008, Bill Campbell wrote: The attached patch to the sh.rotate script sets an environment variable ROTATE_LOGFILE with the name of the current file being processed before invoking the epilog or prolog programs. This permits the epilog/prolog script to do things such as calling webalizer to process the file being rotated. The problem is that defining multiple log files in the rc.conf file with lines like the follow cause the epilog/prolog programs to be execute multiple times without knowledge of which file is being processed. apache_log_files=/opkg/var/apache/log/*access*log I first tried having the sh.rotate script add an argument to the eval of the epilog/prolog command, but this does not work when the command is compound as in the rc.apache daily processing: -E ${apache_log_epilog} rc apache reload Creating a new environment variable avoids this problem and cannot break any existing epilog/prolog programs as they will not be aware of the variable. Ok, taken over into my GNU shtool source tree for inclusion into GNU shtool 2.0.9 -- with just a small adjustment: ROTATE_LOGFILE - SHTOOL_ROTATE_LOGFILE to avoid any conflicts. Thanks for your contribution, Bill! Ralf S. Engelschall [EMAIL PROTECTED] www.engelschall.com __ OpenPKG http://openpkg.org Developer Communication List openpkg-dev@openpkg.org
Re: shtool rotate patch to pass file values to epilog/prolog
On Sun, Sep 21, 2008, Ralf S. Engelschall wrote: On Fri, Sep 19, 2008, Bill Campbell wrote: The attached patch to the sh.rotate script sets an environment variable ROTATE_LOGFILE with the name of the current file being processed before invoking the epilog or prolog programs. This permits the epilog/prolog script to do things such as calling webalizer to process the file being rotated. The problem is that defining multiple log files in the rc.conf file with lines like the follow cause the epilog/prolog programs to be execute multiple times without knowledge of which file is being processed. apache_log_files=/opkg/var/apache/log/*access*log I first tried having the sh.rotate script add an argument to the eval of the epilog/prolog command, but this does not work when the command is compound as in the rc.apache daily processing: -E ${apache_log_epilog} rc apache reload Creating a new environment variable avoids this problem and cannot break any existing epilog/prolog programs as they will not be aware of the variable. Ok, taken over into my GNU shtool source tree for inclusion into GNU shtool 2.0.9 -- with just a small adjustment: ROTATE_LOGFILE - SHTOOL_ROTATE_LOGFILE to avoid any conflicts. Thanks for your contribution, Bill! Thanks Ralf. I thought you might want to use a more descriptive environment variable, and that get it into the main shtool. Presumably this will make it into the shtool rotate man page? Bill -- INTERNET: [EMAIL PROTECTED] Bill Campbell; Celestial Software LLC URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way Voice: (206) 236-1676 Mercer Island, WA 98040-0820 Fax:(206) 232-9186 There is far more danger in public than in private monopoly, for when Government goes into business it can always shift its losses to the taxpayers. Government never makes ends meet -- and that is the first requisite of business. -- Thomas Edison __ OpenPKG http://openpkg.org Developer Communication List openpkg-dev@openpkg.org
shtool rotate patch to pass file values to epilog/prolog
The attached patch to the sh.rotate script sets an environment variable ROTATE_LOGFILE with the name of the current file being processed before invoking the epilog or prolog programs. This permits the epilog/prolog script to do things such as calling webalizer to process the file being rotated. The problem is that defining multiple log files in the rc.conf file with lines like the follow cause the epilog/prolog programs to be execute multiple times without knowledge of which file is being processed. apache_log_files=/opkg/var/apache/log/*access*log I first tried having the sh.rotate script add an argument to the eval of the epilog/prolog command, but this does not work when the command is compound as in the rc.apache daily processing: -E ${apache_log_epilog} rc apache reload Creating a new environment variable avoids this problem and cannot break any existing epilog/prolog programs as they will not be aware of the variable. Bill -- INTERNET: [EMAIL PROTECTED] Bill Campbell; Celestial Software LLC URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way Voice: (206) 236-1676 Mercer Island, WA 98040-0820 Fax:(206) 232-9186 Breathe fire, slay dragons, and take chances. Failure is temporary, regret is eternal. --- sh.rotate.orig 2008-04-02 13:10:17.0 -0700 +++ sh.rotate 2008-09-19 11:48:40.504881762 -0700 @@ -205,6 +205,10 @@ if [ .$opt_t = .yes ]; then echo $opt_P fi +# pass current log file name to prolog +# prolog cannot be handed an argument as it may be +# called as prolog something +ROTATE_LOGFILE=$ldir/$file; export ROTATE_LOGFILE eval $opt_P [ $? -ne 0 ] shtool_exit $? fi @@ -394,6 +398,10 @@ if [ .$opt_t = .yes ]; then echo $opt_E fi +# pass archive file name to epilog command +# epilog cannot be handed an argument as it is often +# called as epilog something +ROTATE_LOGFILE=${adir}/${file}.${n}; export ROTATE_LOGFILE eval $opt_E [ $? -ne 0 ] shtool_exit $? fi