3 # invoked by cron as root on each web node
7 # drop any tokens; use only users' cgi tokens
8 kdestroy
> /dev
/null
2>&1
14 LOCAL_LOG_DIR
=/var
/log
/apache
2/user
15 KEYTAB_DIR
=/etc
/keytabs
/user.daemon
16 AFS_USER_DIR
=/afs
/hcoop.net
/user
19 # Iterate through logs for each user
20 for A
in $
(find $LOCAL_LOG_DIR -mindepth 3 -maxdepth 3 -print); do
22 PATHBITS
=`echo $USER | head -c 1`/`echo $USER | head -c 2`/$USER
23 USER_HOME
=$AFS_USER_DIR/$PATHBITS
24 LOG_SRC
=$A/apache
/log
/$
(hostname
)
25 LOG_DEST
=$USER_HOME/.logs
/apache
/$
(hostname
)
27 # Skip deleted or empty log directories
28 # Possible inefficiency? (ls entire directory*400+ dirs)
29 if test ! -d "$LOG_SRC" ||
! ls "$LOG_SRC"/*/*.log
>/dev
/null
2>&1; then
30 if test "$VERBOSE" = "true"; then
31 echo "Skipping $USER (deleted or empty log dir $LOG_SRC)"
36 # Skip people who have unreadable log subdirectories
37 # This test is broken! --clinton
38 if test -d "$USER_HOME/.logs" && \
39 ! ls "$USER_HOME/.logs" >/dev
/null
2>&1; then
40 if test "$VERBOSE" = "true"; then
41 echo "Skipping $USER (unreadable log dir $USER_HOME/.logs)"
46 # Skip people who do not have keytabs
47 if test ! -f "$KEYTAB_DIR/$USER"; then
48 if test "$VERBOSE" = "true"; then
49 echo "Skipping $USER (missing keytab $KEYTAB_DIR/$USER)"
54 if test "$VERBOSE" = "true"; then
56 echo "=============================================================================="
57 echo "syncing logs for $USER from $LOG_SRC"
58 echo " to $LOG_DEST ..."
61 if test ! -d "$USER_HOME/.logs/apache"; then
62 echo "Error: $USER_HOME/.logs/apache does not exist, please make it"
64 # We will assume that people know what they are doing when they
65 # delete their ~/.logs/apache directory ....
66 # This is perhaps a bad assumption --clinton
67 if test "$VERBOSE" = "true"; then
68 echo "Skipping $USER (no $LOG_DEST directory)"
72 # LOG_SRC/* is important: don't remove log files just because a vhost is gone
73 k5start
-qtU -f $KEYTAB_DIR/$USER -- rsync
-a --no-owner --no-group --delete $LOG_SRC/* $LOG_DEST/
74 test "$VERBOSE" = "true" && echo " done."
78 if test "$ERROR" = "yes"; then