apache-sync-logs: fix bug where only one user gets logs updated
[hcoop/scripts.git] / apache-sync-logs
index 32bef4c..2e88efd 100755 (executable)
@@ -14,6 +14,7 @@ VERBOSE=false
 LOCAL_LOG_DIR=/var/log/apache2
 KEYTAB_DIR=/etc/keytabs/user.daemon
 AFS_USER_DIR=/afs/hcoop.net/user
+ERROR=no
 
 for A in $(find $LOCAL_LOG_DIR/user -mindepth 3 -maxdepth 3 -print); do
     USER=`basename $A`
@@ -31,7 +32,7 @@ for A in $(find $LOCAL_LOG_DIR/user -mindepth 3 -maxdepth 3 -print); do
 
     if [ ! -d "$LOG_DEST" ]; then
         echo "Error: $LOG_DEST does not exist, please make it"
-        exit 1
+        ERROR=yes
     else
         rm -fr $TMP_DEST
         cp -a $LOG_SRC $TMP_DEST
@@ -41,6 +42,12 @@ for A in $(find $LOCAL_LOG_DIR/user -mindepth 3 -maxdepth 3 -print); do
             -- su $USER -c "rsync -a $TMP_DEST/ $LOG_DEST/"
         rm -fr $TMP_DEST
         [ "$VERBOSE" = "true" ] && echo "  done."
-        exit 0
     fi
 done
+
+if [ "$ERROR" = "yes" ]; then
+    exit 1
+else
+    exit 0
+fi
+