home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume19 / rotate_log / patch01 next >
Internet Message Format  |  1991-05-02  |  9KB

  1. From: scs@lokkur.dexter.mi.us (Steve Simmons)
  2. Newsgroups: comp.sources.misc
  3. Subject: v19i015:  rotate_log - logfile management utility, Patch01
  4. Message-ID: <1991May2.173743.14451@sparky.IMD.Sterling.COM>
  5. Date: 2 May 91 17:37:43 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: 19624e33 2728ce99 eb5459a0 8e3e95b0
  8.  
  9. Submitted-by: Steve Simmons <scs@lokkur.dexter.mi.us>
  10. Posting-number: Volume 19, Issue 15
  11. Archive-name: rotate_log/patch01
  12. Patch-To: rotate_log: Volume 17, Issue 77
  13.  
  14. This is patch01 to rotate_log.  This patch fixes several bugs and adds 
  15. a new feature to rotate_log.  Owner/group/mode setting is now done right.  
  16. Several errors in the man page have been corrected.  A new '-s' feature 
  17. has been added so that empty logs will not be rotated.  Many thanks to 
  18. Robert McGraw (mcgraw@sunspot.sunspot.noao.edu), David J. Fiander 
  19. (david@scocan.sco.COM), Heiko Schlichting (heiko@methan.chemie.fu-berlin.de)
  20. and Rene' Seindal (seindal@skinfaxe.diku.dk) for fixes, comments and 
  21. suggestions.
  22.  
  23. To use -- go to wherever you archived the original and feed this
  24. file to patch.  The original ReadMe file is below.
  25.                      ---------------------
  26. Tired of writing yet another log trimming sequence in yet another shell
  27. script?  Then this little ditty is for you.  It rotates logs, compresses
  28. them, cleans out the old logs, kills the oldest logs, lets you invoke
  29. custom commands along the way, complains politely if anything is wrong,
  30. and has a hot cup of coffee waiting for you in the morning.
  31.  
  32. OK, it won't do the coffee.  But it does everything else, and has managed
  33. to worm it's way into crontabs all over the joint.  Today I was putting
  34. it in to clean Yet Another Log, and saw that our operators are using it,
  35. our other system programmer is using it, etc, etc.  They're even
  36. reading the man page.  Since it's such a success at work, it must
  37. be time to throw it to the wolves, er, world.  Enjoy!
  38.  
  39. Steve Simmons
  40. scs@lokkur.dexter.mi.us
  41. April 3, 1991
  42. -----
  43. *** ReadMe.old    Tue Apr 30 22:16:26 1991
  44. --- ReadMe    Tue Apr 30 22:17:04 1991
  45. ***************
  46. *** 14,16 ****
  47. --- 14,34 ----
  48.   Steve Simmons
  49.   scs@lokkur.dexter.mi.us
  50.   April 3, 1991
  51. + Notes on the patch release:
  52. + This patch bring rotate_log to 0.7 and the man page to 1.4.  This fix
  53. + patches several bugs in the initial (0.5) release.  The parameterizing
  54. + of chmod/chown/chgrp introduced an interesting set of bugs reported by
  55. + many folks.  Robert McGraw (mcgraw@sunspot.sunspot.noao.edu) and David
  56. + J. Fiander (david@scocan.sco.COM) sent detailed information and fixes.
  57. + Heiko Schlichting (heiko@methan.chemie.fu-berlin.de) sents some comments
  58. + and fixes for the man page.  Fiander also suggested the "skip if
  59. + empty" (-s) switch to not rotate empty logs.  That is implemented
  60. + here.
  61. + Rene' Seindal (seindal@skinfaxe.diku.dk) sent some detailed commentary
  62. + on old sh versions and bsd.  Those changes will be in a later release.
  63. + Steve
  64. + April 27, 1991
  65. *** rotate_log.old    Tue Apr 30 22:16:27 1991
  66. --- rotate_log    Tue Apr 30 22:17:04 1991
  67. ***************
  68. *** 10,15 ****
  69. --- 10,16 ----
  70.   #
  71.   #  -L    Name of the directory 'log' is found in.
  72.   #  -n    Number of backup copies to keep.
  73. + #  -s    Skip empty logs.
  74.   #  -c   Compress the backup copy.
  75.   #  -B   Dir to keep the backup copies in.
  76.   #  -b   Name of backup copy. 
  77. ***************
  78. *** 29,61 ****
  79.   # redistributed provided this notice remains intact and any changes you
  80.   # make are clearly marked as such.
  81.   #
  82. ! # $Source: /home/lokkur/scs/src/rotate_log/RCS/rotate_log,v $
  83.   #
  84. ! # $Revision: 0.5 $
  85.   #
  86. ! # $Author: scs $    $Date: 91/04/03 19:49:00 $
  87.   #
  88.   # $State: Exp $    $Locker:  $
  89.   #
  90.   # $Log:    rotate_log,v $
  91.   # Revision 0.5  91/04/03  19:49:00  scs
  92.   # Parameterized locations of chmod, chgrp, chown.
  93.   # 
  94. - # Revision 0.4  89/12/12  09:35:59  scs
  95. - # Bug fixes to pick up more defaults.
  96. - # 
  97. - # Revision 0.3  89/12/11  21:34:25  scs
  98. - # Broke out commands separately to avoid ksh wierdness.  Ported
  99. - # to system V.2 sh, ksh.  Removed some BSDisms that makes it more
  100. - # portable.
  101. - # 
  102. - # Revision 0.2  89/12/11  20:53:51  scs
  103. - # Improved error checking on source directory.  Corrected erroneous
  104. - # error message.
  105. - # 
  106. - # Revision 0.1  89/12/11  19:39:31  scs
  107. - # Initial revision.
  108. - # 
  109.   SCRIPT=`basename $0`
  110.   #
  111.   #  Commonly used commands
  112. --- 30,54 ----
  113.   # redistributed provided this notice remains intact and any changes you
  114.   # make are clearly marked as such.
  115.   #
  116. ! # $Source: /home/lokkur/scs/src/rotate_log/rotate_log/RCS/rotate_log,v $
  117.   #
  118. ! # $Revision: 0.7 $
  119.   #
  120. ! # $Author: scs $    $Date: 91/04/30 22:10:10 $
  121.   #
  122.   # $State: Exp $    $Locker:  $
  123.   #
  124.   # $Log:    rotate_log,v $
  125. + # Revision 0.7  91/04/30  22:10:10  scs
  126. + # Aded -s switch.
  127. + # 
  128. + # Revision 0.6  91/04/27  16:16:59  scs
  129. + # Fixed bug with -b/-n combo losing arguements.  Patch supplied by
  130. + # Michael Bredeweg (...clif!comnet!mike).
  131. + # 
  132.   # Revision 0.5  91/04/03  19:49:00  scs
  133.   # Parameterized locations of chmod, chgrp, chown.
  134.   # 
  135.   SCRIPT=`basename $0`
  136.   #
  137.   #  Commonly used commands
  138. ***************
  139. *** 80,85 ****
  140. --- 73,79 ----
  141.   BACKUP_MODE=""
  142.   BACKUP_OWNER=""
  143.   BACKUP_GROUP=""
  144. + SKIP_FLAG="false"
  145.   #
  146.   #  Basic switch parsing.  Right now, this forces us to use whitespace
  147.   #  between switch char and actual execution.  Whenever we get data
  148. ***************
  149. *** 135,140 ****
  150. --- 129,136 ----
  151.           BACKUP_COUNT="$2"
  152.           shift
  153.           ;;
  154. +     -s )    SKIP_FLAG="true"
  155. +         ;;
  156.       -c )    COMPRESS="compress"
  157.           ;;
  158.       -m )    if [ "$2" = "" ] ; then
  159. ***************
  160. *** 283,288 ****
  161. --- 279,293 ----
  162.       exit 0
  163.   fi
  164.   #
  165. + #  If the log is empty and the skip flag (-s) is set, do nothing.
  166. + #
  167. + if [ "${SKIP_FLAG}" = "true" ] ; then
  168. +     set `wc -c ${SOURCE_PATH}`
  169. +     if [ 0 = $1 ] ; then
  170. +         exit 0
  171. +     fi
  172. + fi
  173. + #
  174.   #  Make sure root operations are only run by root
  175.   #
  176.   if [ "${BACKUP_OWNER}" != "" -o "${SOURCE_OWNER}" != "" -o "${BACKUP_GROUP}" != "" -o "${SOURCE_GROUP}" != "" ]
  177. ***************
  178. *** 314,319 ****
  179. --- 319,325 ----
  180.       exit 0
  181.   fi
  182.   OLDEST="${1}"
  183. + NEXT="${1}"
  184.   shift
  185.   while [ "$1" != "" ] ; do
  186.       NEXT="${1}"
  187. *** rotate_log.8.old    Tue Apr 30 22:16:27 1991
  188. --- rotate_log.8    Tue Apr 30 22:17:04 1991
  189. ***************
  190. *** 1,23 ****
  191.   .\" Manual page for rotate_log
  192.   .\"
  193. ! .\" $Source: /home/lokkur/scs/src/rotate_log/RCS/rotate_log.8,v $
  194.   .\"
  195. ! .\" $Revision: 1.3 $
  196.   .\"
  197. ! .\" $Author: scs $    $Date: 89/12/11 17:54:30 $
  198.   .\"
  199. ! .\" $State: Exp $    $Locker: scs $
  200.   .\"
  201.   .\" $Log:    rotate_log.8,v $
  202.   ."\ Revision 1.3  89/12/11  17:54:30  scs
  203.   ."\ Added prolog and postlog commands.
  204.   ."\ 
  205. - ."\ Revision 1.2  89/12/11  17:34:46  scs
  206. - ."\ Corrected minor format errors.
  207. - ."\ 
  208. - ."\ Revision 1.1  89/12/11  17:29:36  scs
  209. - ."\ Initial revision
  210. - ."\ 
  211.   .TH ROTATE_LOG 8 89/12/11
  212.   .SH NAME
  213.   rotate_log \- rotate logfiles, removing the oldest
  214. --- 1,22 ----
  215.   .\" Manual page for rotate_log
  216.   .\"
  217. ! .\" $Source: /home/lokkur/scs/src/rotate_log/rotate_log/RCS/rotate_log.8,v $
  218.   .\"
  219. ! .\" $Revision: 1.4 $
  220.   .\"
  221. ! .\" $Author: scs $    $Date: 91/04/27 16:26:23 $
  222.   .\"
  223. ! .\" $State: Exp $    $Locker:  $
  224.   .\"
  225.   .\" $Log:    rotate_log.8,v $
  226. + .\" Revision 1.4  91/04/27  16:26:23  scs
  227. + .\" Corrected references to prolog/postlog in the man page.  Many thanks
  228. + .\" to Heiko Schlichting (heiko@methan.chemie.fu-berlin.de) for pointing
  229. + .\" out the problems.
  230. + .\" 
  231.   ."\ Revision 1.3  89/12/11  17:54:30  scs
  232.   ."\ Added prolog and postlog commands.
  233.   ."\ 
  234.   .TH ROTATE_LOG 8 89/12/11
  235.   .SH NAME
  236.   rotate_log \- rotate logfiles, removing the oldest
  237. ***************
  238. *** 111,117 ****
  239.   (this option is only available to 
  240.   .I root ).
  241.   .TP
  242. ! .B "\-O group"
  243.   Set the group membership of
  244.   .I logfile.0
  245.   to
  246. --- 110,116 ----
  247.   (this option is only available to 
  248.   .I root ).
  249.   .TP
  250. ! .B "\-G group"
  251.   Set the group membership of
  252.   .I logfile.0
  253.   to
  254. ***************
  255. *** 130,136 ****
  256.   has spaces, blanks, or metacharacters they must be quoted.
  257.   .TP
  258.   .B "\-E postlog_command"
  259. ! .I prolog_command
  260.   is a command to be executed immediately after emptying
  261.   .I logfile
  262.   Note it is only executed if
  263. --- 129,135 ----
  264.   has spaces, blanks, or metacharacters they must be quoted.
  265.   .TP
  266.   .B "\-E postlog_command"
  267. ! .I postlog_command
  268.   is a command to be executed immediately after emptying
  269.   .I logfile
  270.   Note it is only executed if
  271. ***************
  272. *** 137,143 ****
  273.   .I logfile
  274.   is successfully emptied.
  275.   Note also that if 
  276. ! .I prolog_command
  277.   has spaces, blanks, or metacharacters they must be quoted.
  278.   .PP
  279.   Note that the mode and ownership settings apply only the the newly
  280. --- 136,142 ----
  281.   .I logfile
  282.   is successfully emptied.
  283.   Note also that if 
  284. ! .I postlog_command
  285.   has spaces, blanks, or metacharacters they must be quoted.
  286.   .PP
  287.   Note that the mode and ownership settings apply only the the newly
  288.  
  289. exit 0 # Just in case...
  290. -- 
  291. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  292. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  293. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  294. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  295.