rottlog-develop
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Rottlog-develop] Little patches for rot[t]log


From: Frederic Connes
Subject: [Rottlog-develop] Little patches for rot[t]log
Date: Wed, 04 Sep 2002 12:54:21 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1b) Gecko/20020731

Hi,

I use rot[t]log since 0.32alpha and I appreciate it.
I noticed some little problems, so here are some patches against 0.35alpha to correct them: - createdir.patch: createdir in rc did nothing, because $CREATE_DIR was used instead of $create_dir
- typos.patch: fixes some typos and removes useless blank spaces

I also noticed (but have no time to fix):
- nomail in rc does nothing, because $mail is only unset when parsing monthly/weekly/daily (so a workaround is to put nomail in the configuration section of each file to rotate)
- @1, @2... doesn't work with storedir (or did I miss something ?)
  it creates a "@1", "@2"... directory
- it would be great if storefile could be put in rc, so if one wants the rotated files to be called for instance @address@hidden one doesn't have to repeat it for each file.

Thanks,

Frederic Connes
--- /usr/src/rottlog-0.35alpha/rottlog  2002-09-04 09:41:44.000000000 +0200
+++ rottlog     2002-09-04 11:04:32.000000000 +0200
@@ -568,7 +568,7 @@
     expand_metavar "$log" "$pcdpc"
     pcdpc="$expanded_metavars"
     debecho "prepare_rotate: After expand_metavar pcdpc=$pcdpc"
-    if [ ! -d "$pcdpc" ] && [ ! -z "$CREATEDIR" ]; then
+    if [ ! -d "$pcdpc" ] && [ ! -z "$createdir" ]; then
       debecho "prepare_rotate: Trying to make $pcdpc..."
       mkdir -p "$pcdpc" 2>/dev/null
       chown $dir_own "$pcdpc"
@@ -1499,7 +1499,7 @@
                  shift
                fi
                check_perms "$dir_perm" "$dir_own" "$dir_grp" createdir
-               CREATEDIR=1
+               createdir=1
                ;;
           append-only)
                CHATTR=1
--- /usr/src/rottlog-0.35alpha/rottlog  2002-09-04 11:05:11.000000000 +0200
+++ rottlog     2002-09-04 12:39:10.000000000 +0200
@@ -4,12 +4,12 @@
 #
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation; either version 2 of the License, or   
+#    the Free Software Foundation; either version 2 of the License, or
 #    (at your option) any later version.
 #
 #    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of 
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 #    GNU General Public License for more details.
 #
 #    You should have received a copy of the GNU General Public License
@@ -19,7 +19,7 @@
 #
 # WARNING: This script is bash2.x compatible.
 #
-# This is rot[t]log 
+# This is rot[t]log
 # Utility to archive, rotates, compresses, and mails system logs.
 #
 #
@@ -50,11 +50,11 @@
      echo
      exit 1
   fi
-  
+
   mkdir $tmpd
   chmod 1700 $tmpd
   RETURN=$?
-  
+
   if [ $RETURN -gt 0 ]; then
      echo
      echo "**** Failed to create temp dir!"
@@ -64,11 +64,11 @@
      echo
      exit  $RETURN
   fi
-  
+
   # I think it's a good idea to let rottlog to ignore these signals, but
   # if you think it's not useful, you can comment it out.
   trap '' 1 2 5 6
-  
+
   if [ -z "$1" ]; then
     TEMPDIR="$tmpd"
     tmpfil=$TEMPDIR/rotttempfile.$$
@@ -104,13 +104,13 @@
 # Error codes
 E_NO_ERROR=0
 E_FILE_NOREAD=1
-E_SYNTAX_ERROR=2 
-E_BAD_LOGPART=3 
-E_BAD_ENDSCRIPT=4 
-E_BAD_CREATE=5 
-E_BAD_ROTATE=6 
-E_BAD_PARAM=7 
-E_NO_STOREDIR=8 
+E_SYNTAX_ERROR=2
+E_BAD_LOGPART=3
+E_BAD_ENDSCRIPT=4
+E_BAD_CREATE=5
+E_BAD_ROTATE=6
+E_BAD_PARAM=7
+E_NO_STOREDIR=8
 E_CANT_CREATE=9
 E_NO_PAGER=10
 E_CANT_UNCOMPRESS=11
@@ -150,9 +150,9 @@
 BREAK_CYCLE=255
 
 # ################################################################
-#       
+#
 #              END CONFIGURATION OF INTERNAL VARIABLES
-#        
+#
 # ################################################################
 
 trap 'rm -rf $TEMPDIR $LOCK; exit $USCITA' 0
@@ -204,7 +204,7 @@
     USCITA=$E_NO_RCFILE
     exit $USCITA
   fi
-  
+
   for i in $RC_VARS; do
     tmp_param=$(awk "/^$i/ { print }" < $MAINRC)
     if [ $(expr "$tmp_param" : ".*=.*") -ne ${#tmp_param} ]; then
@@ -275,7 +275,7 @@
     USCITA=$E_FILE_NOREAD
     exit $USCITA
   fi
-  
+
   if [ -z "$grp" ]; then
     echo "Can't extract group from filename!"
     USCITA=$E_FILE_NOREAD
@@ -362,12 +362,12 @@
   # "$1" sta in DELAYED_FILES, se è così viene compresso rimanendo sempre
   # con il nome preso da DELAYED_FILES, e si continua la procedura per il
   # prossimo file che sarà solo "tagliato" se necessario ma non compresso.
-  # Se il file "$1" non è presente in DELAYED_FILES si inserisce $2 in 
+  # Se il file "$1" non è presente in DELAYED_FILES si inserisce $2 in
   # questo file, lo si copia in $2 e si prosegue con eventuali "tagli"
 
   # Se non c'è DELAY allora prima si copia il log in un file temporaneo,
   # si comprime questo file temporaneo in $2, poi si applicano eventuali
-  # tagli a $1. 
+  # tagli a $1.
 
   # Gestisco la compressione a distanza di una rotazione...
 
@@ -378,7 +378,7 @@
     debecho "Archive/rotation not necessary"
     return
   fi
-  
+
   if [ ! -z "$DELAY" ]; then
     IS_OLD=$(grep "$1" $DELAYED_FILES 2>/dev/null)
     if [ ! -z "$IS_OLD" ]; then
@@ -388,7 +388,7 @@
       if [ ! -r "$old_rotated" ]; then
         if [ ! -z "$remove_missing" ]; then
           (
-          echo "Error in compress procedure. Old not compressed logfile 
does'nt"
+          echo "Error in compress procedure. Old not compressed logfile 
doesn't"
           echo "exists or is not readable. Erasing from control files."
           ) >>$TMPERRMSG
           remove_from_ctrlfile "$1"
@@ -576,7 +576,7 @@
       chmod $dir_perm "$pcdpc"
     fi
     if [ ! -d "$pcdpc" ]; then
-      echo "Directory to store compressed log does'nt exist!"
+      echo "Directory to store compressed log doesn't exist!"
       echo "Log=$log"
       echo "Dir=$pcdpc"
       USCITA=$E_NO_STOREDIR
@@ -584,7 +584,7 @@
     fi
 
     make_storefile "$log"
-    
+
     # ddd//bbb --> ddd/bbb
     storefile=${storefile//\/\//\/}
 
@@ -611,7 +611,7 @@
     if [ -z "$COLLATE" ]; then
       esegui_rotate "$log" "$storefile"
     else
-      collate_logfiles "$log" "$storefile" 
+      collate_logfiles "$log" "$storefile"
     fi
 
     # Eseguiamo lo script dopo la rotazione
@@ -636,11 +636,11 @@
         . $TEMPDIR/meta-postrotate.$$
       fi
     fi
-    
+
     if [ ! -z "$CHATTR" ]; then
       chattr +a "$log"
     fi
-    
+
     date_end=$(date)
     if [ ! -z "$mail" ]; then
       debecho "prepare_rotate: mailing to $touser action report"
@@ -665,7 +665,7 @@
     . $TMPROTTCOLLECT.$logname
     expand_metavar "$COLLECT_LOG" "$COLLECT_ARCDIR"
     pcdpc="$expanded_metavars"
- 
+
     # trick: faccio una espansione delle meta-variabili
     # "a capa mia"
     COLLECT_ARCFIL="${COLLECT_ARCFIL//address@hidden/*}"
@@ -702,7 +702,7 @@
       fi
     fi
     count=1
-    case $COLLATE in 
+    case $COLLATE in
       tar)
       #Shipped in 0.30alpha. It works
       #debecho "Performing TARCOLLATE"
@@ -723,7 +723,7 @@
           debecho "Copied $f in $MAKETREE"
           continue
         fi
-      
+
         #if [ ! -z "$COLLECT_DELAY" ] && \
         #   [ ! -z $(grep "^.*=$f" $DELAYED_FILES 2>/dev/null) ]; then
         if [ ! -z "$COLLECT_DELAY" ] && [ "$TOBEPACK" = "$f" ]; then
@@ -775,11 +775,11 @@
 collect_log_info () {
   local p=$2
   local find="$1"
-  
+
   for find in address@hidden; do
     debecho "Searching for matching logfile in address@hidden"
     if [ "$find" = "$1" ]; then
-      debecho "Found matching logfile $find"
address@hidden      debecho "Found matching logfile $find"
       if [ -z "$ROTATE" ] || [ $ROTATE -ne $p ]; then
         echo "Invalid rotate period for collate link"
         return $E_BAD_PERIOD
@@ -848,13 +848,13 @@
   filna=${filna//\\\\\\*}
 
   case "$filna" in
-    *\]*|*\[*|*\{*|*\}*|*\?*) 
+    *\]*|*\[*|*\{*|*\}*|*\?*)
         echo "Only * wildcard can be used!"
         USCITA=$E_BAD_WILDCARD
         exit $USCITA
         ;;
   esac
-  
+
   if [ $(expr index "$filna" "\*" ) -eq 0 ]; then
     debecho "No wildcard in this filename"
     return 0
@@ -928,11 +928,11 @@
   tmpstr=${tmpstr//address@hidden/$year}
   tmpstr=${tmpstr//address@hidden/$month}
   tmpstr=${tmpstr//address@hidden/$day}
-  #TODO: prima di espandere questa cerco in DELAYED_FILES 
+  #TODO: prima di espandere questa cerco in DELAYED_FILES
   tmpstr=${tmpstr//address@hidden/$comp_ext}
   tmpstr=${tmpstr//address@hidden/$meta_tmp_dir}
 
-  # Only if path and filename is already expanded these two metavariables 
+  # Only if path and filename is already expanded these two metavariables
   # can be sustituted.
   if [ $(expr index "$pcdpc" "\@") -eq 0 ]; then
     case "$tmpstr" in
@@ -985,7 +985,7 @@
   qdldl="$1"
   local poschar=$[ ${#qdldl} - 1 ]
   local lastchar=$(echo "${qdldl:$poschar:1}"|tr 'a-z' 'A-Z')
-  
+
   case "$lastchar" in
     L)
       # sono righe!
@@ -1035,9 +1035,9 @@
 check_perms () {
   local tmpown
   local tmpgrp
- 
+
   debecho "Checking permissions..."
- 
+
   if [ "$1" != "" ]; then
     debecho "Checking for mode $1..."
     if [ ${#1} -gt 4 ]; then
@@ -1058,7 +1058,7 @@
     tmpvar=$(grep "^$2:" /etc/passwd 2>/dev/null|cut -d':' -f1)
     if [ -z "$tmpvar" ]; then
       echo "Error analyzing $4 parameter"
-      echo "Invalid owner! It does'nt exists in /etc/passwd."
+      echo "Invalid owner! It doesn't exists in /etc/passwd."
       USCITA=$E_INVALID_OWN
       exit $USCITA
     fi
@@ -1069,7 +1069,7 @@
     tmpvar=$(grep "^$3:" /etc/group 2>/dev/null)
     if [ -z "$tmpvar" ]; then
       echo "Error analyzing $4 parameter"
-      echo "Invalid group! It does'nt exists in /etc/group."
+      echo "Invalid group! It doesn't exists in /etc/group."
       USCITA=$E_INVALID_GRP
       exit $USCITA
     fi
@@ -1154,7 +1154,7 @@
   debecho "End of filename expansion"
 }
 
-read_and_do() { 
+read_and_do() {
   if [ -z "$1" ]; then
     cmd_exec=( prepare_rotate )
   else
@@ -1213,7 +1213,7 @@
     while [ "$LINEA" != "}" ]; do
       # Dopo la prima riga (contenente { ) si analizzano le successive
       # la sintassi è: <parola-chiave> <valore>
-        
+
       set -- $LINEA
       debecho "Analyzing parameters of '$LINEA'"
       while [ $# -gt 0 ]; do
@@ -1551,7 +1551,7 @@
       debecho "Sanity check: exit from subshell due to FORCE_DAY=$FORCE_DAY"
       exit
     fi
-    
+
     # se c'è delaycompress si ignora nocompress
     debecho "Ignoring nocompress if using delaycompress"
     if [ ! -z "$NOCOMPRESS" ] && [ -z "$DELAY" ]; then
@@ -1608,7 +1608,7 @@
 
     expand_filenames $filenames
 
-    ( 
+    (
     if [ -z "$COLLATE" ]; then
       exit 0
     fi
@@ -1635,7 +1635,7 @@
       # se modfico anche collect_log_info
       debecho "Calling collect_log_info with log=${pcldr[0]} and 
period=$period"
       COLLATE=
-      read_and_do collect_log_info "${pcldr[0]}" $period 
+      read_and_do collect_log_info "${pcldr[0]}" $period
       debecho "Restoring original purged_file variable value..."
       PURGED_FILE="$orig_PURGED_FILE"
     )
@@ -1643,7 +1643,7 @@
     if [ $RET_VAL -ne 0 ]; then
       exit $RET_VAL
     fi
-    
+
     # call function specified in "$1" with all other parameters
     address@hidden
     EXIT_CODE=$?
@@ -1665,7 +1665,7 @@
     fi
     #unset pcldr
   done <$PURGED_FILE
-  
+
 }
 
 mail_to_admin() {
@@ -1696,7 +1696,7 @@
 
 $( cat $TMPERRMSG )
 
-Next rotation will be performed approximatively on $date_next. 
+Next rotation will be performed approximatively on $date_next.
 If you don't correct this problem before this date rottlog will send
 same error message next time it will try to manage this logfile.
 
@@ -1709,7 +1709,7 @@
 EOF
   else
     cat << EOF | $mail
-From: $fromuser 
+From: $fromuser
 To: $touser
 Subject: Rot[t]Log $quale maintenance
 
@@ -1741,7 +1741,7 @@
 
 EOF
   fi
-   
+
   debecho "Sent mail from $fromuser to $touser"
 
 }
@@ -1771,7 +1771,7 @@
     fi
   fi
   debecho "Rotation not needed: $DIFFDATA < $2"
-  return 0  
+  return 0
 }
 
 read_daily() {
@@ -1787,7 +1787,7 @@
     debecho "Rotating daily logfiles"
     read_and_do
   fi
-   
+
 }
 
 
@@ -1817,7 +1817,7 @@
     debecho "Rotating monthly logfiles"
     read_and_do
   fi
-   
+
 }
 
 read_weekly() {
@@ -1834,7 +1834,7 @@
     debecho "Rotating weekly logfiles"
     read_and_do
   fi
-      
+
 }
 
 banner() {
@@ -2042,7 +2042,7 @@
 summarize_loginfo () {
   # ciclo tra daily, weekly, monthly
   # quando trovo il file in uno di questi tre visualizzo le info ed esco
-  
+
   for quale in daily weekly monthly; do
     if [ -e $MAINPATH/$quale ]; then
       debecho "Searching in $quale conffile"
@@ -2054,7 +2054,7 @@
 checkrc () {
   while [ $# -ne 0 ]; do
     if [ ! -e $MAINPATH/$1 ]; then
-      echo "WARNING: $1 file does'nt exist!"
+      echo "WARNING: $1 file doesn't exist!"
     else
       echo 
"==========================================================================="
       echo "Checking $1 configuration file..."
@@ -2126,7 +2126,7 @@
                     rctocheck="$rctocheck daily"
                     ;;
                 all)
-                    rctocheck="weekly monthly daily" 
+                    rctocheck="weekly monthly daily"
                     ;;
                 *)
                   echo "Invalid option to checkrc: $1"
@@ -2135,9 +2135,9 @@
               esac
               shift
             done
-            checkrc $rctocheck 
+            checkrc $rctocheck
             ;;
-      #--without-scripts) 
+      #--without-scripts)
       #      GLOBAL_DISABLE_SCRIPT=1
       #      ;;
       --force)
@@ -2187,8 +2187,7 @@
   done
   [ -z "$DONTEXIT" ] && exit
 fi
-  
+
 read_daily
 read_weekly
 read_monthly
-

reply via email to

[Prev in Thread] Current Thread [Next in Thread]