]>
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/ | |
51480b6d MM |
12 | # |
13 | # Note that we look for root/*/*/.new/*.info, so don't place any additional | |
14 | # directories there. | |
15 | ||
16 | root="/home/services/ftpd/buildlogs" | |
372c19c6 | 17 | ADDLOG="/home/services/httpd/html/pld-buildlogs/scripts/addlog.php" |
51480b6d | 18 | |
d9b75e39 PG |
19 | if test -f /etc/buildlogs-mover.conf ; then |
20 | . /etc/buildlogs-mover.conf | |
44490041 MM |
21 | fi |
22 | ||
eaaed0dc | 23 | for 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 | |
29 | done | |
30 | ||
51480b6d MM |
31 | handle_info () { |
32 | info="$1" | |
33 | info_val="$(cat "$info" 2>/dev/null)" | |
34 | if echo "$info_val" | grep -q '^END$' ; then | |
51480b6d MM |
35 | status=$(echo "$info_val" | grep '^Status:' | sed -e 's/.*: *//') |
36 | case $status in | |
37 | OK ) s=OK ;; | |
38 | FAIL* ) s=FAIL ;; | |
39 | * ) | |
40 | # this script is run from cron, so this should go through mail | |
41 | # to admin | |
42 | echo "bad buildlog status: $status in $info:" 1>&2 | |
43 | echo "#v+" 1>&2 | |
44 | echo "$info_val" 1>&2 | |
45 | echo "#v-" 1>&2 | |
372c19c6 | 46 | rm "$info" 2>/dev/null |
51480b6d MM |
47 | return |
48 | ;; | |
49 | esac | |
50 | archdir="$(dirname "$(dirname "$info")")" | |
51 | file=$(basename "$info" .info) | |
372c19c6 | 52 | if test -f "$archdir/.new/$file"; then |
372c19c6 PG |
53 | mv -f "$archdir/.new/$file" "$archdir/$s/$file" |
54 | $ADDLOG "$archdir/$s/$file" | |
55 | rm "$info" 2>/dev/null | |
15dc9a1b | 56 | fi |
51480b6d MM |
57 | fi |
58 | } | |
59 | ||
60 | for info in $root/*/*/.new/*.info ; do | |
61 | if test -f "$info" ; then | |
62 | handle_info "$info" | |
63 | fi | |
64 | done |