# .new/
# OK/
# FAIL/
-# prevOK/
#
# Note that we look for root/*/*/.new/*.info, so don't place any additional
# directories there.
root="/home/services/ftpd/buildlogs"
+ADDLOG="/home/services/httpd/html/pld-buildlogs/scripts/addlog.php"
-#if test -f /etc/buildlogs-mover.conf ; then
-# . /etc/buildlogs-mover.conf
-#fi
if test -f /etc/buildlogs-mover.conf ; then
. /etc/buildlogs-mover.conf
fi
+for n in $root/*/*/.new ; do
+ if test ! -d $n ; then
+ echo "$n doesn't exists or ain't directory"
+ exit 1
+ fi
+ break # don't check all
+done
+
handle_info () {
info="$1"
info_val="$(cat "$info" 2>/dev/null)"
if echo "$info_val" | grep -q '^END$' ; then
- rm "$info" 2>/dev/null || return
status=$(echo "$info_val" | grep '^Status:' | sed -e 's/.*: *//')
case $status in
OK ) s=OK ;;
echo "#v+" 1>&2
echo "$info_val" 1>&2
echo "#v-" 1>&2
+ rm "$info" 2>/dev/null
return
;;
esac
archdir="$(dirname "$(dirname "$info")")"
file=$(basename "$info" .info)
- if test -f "$archdir/OK/$file" ; then
- mv -f "$archdir/OK/$file" "$archdir/prevOK/$file"
+ if test -f "$archdir/.new/$file"; then
+ mv -f "$archdir/.new/$file" "$archdir/$s/$file"
+ $ADDLOG "$archdir/$s/$file"
+ rm "$info" 2>/dev/null
fi
- rm -f "$archdir/"{OK,FAIL}"/$file"
- mv -f "$archdir/.new/$file" "$archdir/$s/$file"
fi
}