Set exit status in apache-sync-logs
[clinton/scripts.git] / apache-sync-logs
... / ...
CommitLineData
1#!/bin/bash
2
3# invoke this as root on mire
4
5exec 2>&1
6
7# drop any tokens; use only users' cgi tokens
8kdestroy > /dev/null 2>&1
9unlog
10
11#VERBOSE=true
12VERBOSE=false
13
14LOCAL_LOG_DIR=/var/log/apache2
15KEYTAB_DIR=/etc/keytabs/user.daemon
16AFS_USER_DIR=/afs/hcoop.net/user
17
18for A in $(find $LOCAL_LOG_DIR/user -mindepth 3 -maxdepth 3 -print); do
19 USER=`basename $A`
20 PATHBITS=`echo $USER | head -c 1`/`echo $USER | head -c 2`/$USER
21 LOG_DEST=$AFS_USER_DIR/$PATHBITS/logs/apache/
22
23 if [ "$VERBOSE" = "true" ]; then
24 echo
25 echo "=============================================================================="
26 echo "syncing logs for $USER from $A"
27 echo " to $LOG_DEST ..."
28 fi
29
30 chown -R $USER:www-data $A
31 chmod -R ug+rw $A
32
33 if [ ! -d "$LOG_DEST" ]; then
34 echo "Error: $LOG_DEST does not exist, please make it"
35 exit 1
36 else
37 k5start -qtU -f $KEYTAB_DIR/$USER \
38 -- su $USER -c "rsync -a $A/apache/log/ $LOG_DEST/"
39 [ "$VERBOSE" = "true" ] && echo " done."
40 exit 0
41 fi
42done