File: rotate-httpd

package info (click to toggle)
http-analyze 1.9e-2
  • links: PTS
  • area: non-free
  • in suites: hamm
  • size: 376 kB
  • ctags: 327
  • sloc: ansic: 3,493; sh: 185; makefile: 106
file content (56 lines) | stat: -rwxr-xr-x 1,529 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/ksh
# $Id: rotate-httpd,v 1.1 1996/06/27 11:41:13 stefan Exp $
#
# Rotate server log files and archive the old logfiles.
# Does not affect users who may be connected to the server.
#
# Copyright 1996 by Stefan Stapelberg, <stefan@rent-a-guru.de>
#
# $Log: rotate-httpd,v $
# Revision 1.1  1996/06/27  11:41:13  stefan
# Initial revision
#
#

# SRVROOT is the name of the ServerRoot directory.
SRVROOT=/usr/ns-home

# CFGFILE defines the name of the config file for this server.
CFGFILE=analyze.conf

# ANALYZE contains the name of the executable program.
ANALYZE=/usr/local/bin/http-analyze

# SRVLIST contains the names of all SERVER_ROOT configuration directories
SRVLIST='httpd-80'

# Add here any additional logfiles you want rotated.
LOGS='access errors secure'

typeset -i MON YEAR
typeset -Z2 MON

eval $(date "+MABB='%B' MON='%m' YEAR='%Y'")

((MON=$MON-1)); [ $MON -eq 0 ] && { MON="12"; ((YEAR=$YEAR-1)); }
LOGDIR="log$YEAR"

cd $SRVROOT || { echo "panic: can't cd into $SRVROOT" 1>&2; exit 1; }

for server in $SRVLIST; do
	(cd $server/logs
	    [ ! -d "$LOGDIR" ] && { mkdir $LOGDIR; }
	    for file in $LOGS; do
		[ -f $file ] && { mv $file $LOGDIR/$file.$MON; }
		echo "$server/logs/$file saved in $LOGDIR/$file.$MON" 1>&2
	    done)
	$server/restart
done

# Now run http-analyze for each server. For each server,
# a configuration file must exist under the ServerRoot.
for server in $SRVLIST; do
	test -s $CFGFILE && \
	  { $ANALYZE -m -c $CFGFILE $LOGDIR/$file.$MON; \
	    $ANALYZE -m -c $CFGFILE; }
done