Check in create-user changes from megacz
[hcoop/scripts.git] / apache-sync-logs
CommitLineData
d2462e94 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
b7036601 8kdestroy > /dev/null 2>&1
d2462e94 9unlog
10
b7036601 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
b7036601 30 if [ ! -d "$LOG_DEST" ]; then
31 echo "Error: $LOG_DEST does not exist, please make it"
f9be7472 32 exit 1
b7036601 33 else
34 k5start -qtU -f $KEYTAB_DIR/$USER \
c62c1339 35 -- su $USER -c "rsync -a $A/apache/log/ $LOG_DEST/ ;
36 chown -R $USER $LOG_DEST ;
37 chmod -R u+rw $LOG_DEST"
b7036601 38 [ "$VERBOSE" = "true" ] && echo " done."
f9be7472 39 exit 0
b7036601 40 fi
d2462e94 41done