]>
Commit | Line | Data |
---|---|---|
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 | ||
17 | root="/home/services/ftpd/buildlogs" | |
372c19c6 | 18 | ADDLOG="/home/services/httpd/html/pld-buildlogs/scripts/addlog.php" |
51480b6d | 19 | |
d9b75e39 PG |
20 | if test -f /etc/buildlogs-mover.conf ; then |
21 | . /etc/buildlogs-mover.conf | |
44490041 MM |
22 | fi |
23 | ||
eaaed0dc | 24 | for n in $root/*/*/.new ; do |
b62277c0 | 25 | if test ! -d $n ; then |
eaaed0dc MM |
26 | echo "$n doesn't exists or ain't directory" |
27 | exit 1 | |
28 | fi | |
29 | break # don't check all | |
30 | done | |
31 | ||
51480b6d MM |
32 | handle_info () { |
33 | info="$1" | |
34 | info_val="$(cat "$info" 2>/dev/null)" | |
35 | if echo "$info_val" | grep -q '^END$' ; then | |
51480b6d MM |
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 | |
372c19c6 | 47 | rm "$info" 2>/dev/null |
51480b6d MM |
48 | return |
49 | ;; | |
50 | esac | |
51 | archdir="$(dirname "$(dirname "$info")")" | |
52 | file=$(basename "$info" .info) | |
372c19c6 PG |
53 | if test -f "$archdir/.new/$file"; then |
54 | if test -f "$archdir/OK/$file" ; then | |
55 | mv -f "$archdir/OK/$file" "$archdir/prevOK/$file" | |
56 | fi | |
57 | rm -f "$archdir/"{OK,FAIL}"/$file" | |
58 | mv -f "$archdir/.new/$file" "$archdir/$s/$file" | |
59 | $ADDLOG "$archdir/$s/$file" | |
60 | rm "$info" 2>/dev/null | |
51480b6d MM |
61 | fi |
62 | } | |
63 | ||
64 | for info in $root/*/*/.new/*.info ; do | |
65 | if test -f "$info" ; then | |
66 | handle_info "$info" | |
67 | fi | |
68 | done |