]> git.pld-linux.org Git - projects/buildlogs.git/blame - helpers/buildlogs-mover.sh
- you don't have to delete the buildlogs.db before starting
[projects/buildlogs.git] / helpers / buildlogs-mover.sh
CommitLineData
51480b6d
MM
1#!/bin/sh
2#
3# Script to be run from crontab on buildlogs host.
4# Moves buildlogs around.
5#
6# Expected directory structure:
7#
8# root/$(dist)/$(arch)/
9# .new/
10# OK/
11# FAIL/
12# prevOK/
13#
14# Note that we look for root/*/*/.new/*.info, so don't place any additional
15# directories there.
16
17root="/home/services/ftpd/buildlogs"
18
d9b75e39
PG
19if test -f /etc/buildlogs-mover.conf ; then
20 . /etc/buildlogs-mover.conf
44490041
MM
21fi
22
eaaed0dc 23for n in $root/*/*/.new ; do
b62277c0 24 if test ! -d $n ; then
eaaed0dc
MM
25 echo "$n doesn't exists or ain't directory"
26 exit 1
27 fi
28 break # don't check all
29done
30
51480b6d
MM
31handle_info () {
32 info="$1"
33 info_val="$(cat "$info" 2>/dev/null)"
34 if echo "$info_val" | grep -q '^END$' ; then
35 rm "$info" 2>/dev/null || return
36 status=$(echo "$info_val" | grep '^Status:' | sed -e 's/.*: *//')
37 case $status in
38 OK ) s=OK ;;
39 FAIL* ) s=FAIL ;;
40 * )
41 # this script is run from cron, so this should go through mail
42 # to admin
43 echo "bad buildlog status: $status in $info:" 1>&2
44 echo "#v+" 1>&2
45 echo "$info_val" 1>&2
46 echo "#v-" 1>&2
47 return
48 ;;
49 esac
50 archdir="$(dirname "$(dirname "$info")")"
51 file=$(basename "$info" .info)
52 if test -f "$archdir/OK/$file" ; then
53 mv -f "$archdir/OK/$file" "$archdir/prevOK/$file"
54 fi
55 rm -f "$archdir/"{OK,FAIL}"/$file"
56 mv -f "$archdir/.new/$file" "$archdir/$s/$file"
57 fi
58}
59
60for info in $root/*/*/.new/*.info ; do
61 if test -f "$info" ; then
62 handle_info "$info"
63 fi
64done
This page took 0.052412 seconds and 4 git commands to generate.