64dae8a47034d4e253263390530b4ef81719a1d1
[clinton/scripts.git] / apache-sync-logs
1 #!/bin/bash
2
3 # invoke this as root on mire
4
5 exec 2>&1
6
7 # drop any tokens; use only users' cgi tokens
8 kdestroy > /dev/null 2>&1
9 unlog
10
11 #VERBOSE=true
12 VERBOSE=false
13
14 LOCAL_LOG_DIR=/var/log/apache2
15 KEYTAB_DIR=/etc/keytabs/user.daemon
16 AFS_USER_DIR=/afs/hcoop.net/user
17
18 for 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 if [ ! -d "$LOG_DEST" ]; then
31 echo "Error: $LOG_DEST does not exist, please make it"
32 exit 1
33 else
34 k5start -qtU -f $KEYTAB_DIR/$USER \
35 -- su $USER -c "rsync -a $A/apache/log/ $LOG_DEST/ ;
36 chown -R $USER $LOG_DEST ;
37 chmod -R u+rw $LOG_DEST"
38 [ "$VERBOSE" = "true" ] && echo " done."
39 exit 0
40 fi
41 done