]> git.pld-linux.org Git - projects/buildlogs.git/blame - helpers/buildlogs-mover.sh
- default config
[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
44490041
MM
19if test -f ~/.buildlogs-mover ; then
20 . ~/.buildlogs-mover
21fi
22
51480b6d
MM
23handle_info () {
24 info="$1"
25 info_val="$(cat "$info" 2>/dev/null)"
26 if echo "$info_val" | grep -q '^END$' ; then
27 rm "$info" 2>/dev/null || return
28 status=$(echo "$info_val" | grep '^Status:' | sed -e 's/.*: *//')
29 case $status in
30 OK ) s=OK ;;
31 FAIL* ) s=FAIL ;;
32 * )
33 # this script is run from cron, so this should go through mail
34 # to admin
35 echo "bad buildlog status: $status in $info:" 1>&2
36 echo "#v+" 1>&2
37 echo "$info_val" 1>&2
38 echo "#v-" 1>&2
39 return
40 ;;
41 esac
42 archdir="$(dirname "$(dirname "$info")")"
43 file=$(basename "$info" .info)
44 if test -f "$archdir/OK/$file" ; then
45 mv -f "$archdir/OK/$file" "$archdir/prevOK/$file"
46 fi
47 rm -f "$archdir/"{OK,FAIL}"/$file"
48 mv -f "$archdir/.new/$file" "$archdir/$s/$file"
49 fi
50}
51
52for info in $root/*/*/.new/*.info ; do
53 if test -f "$info" ; then
54 handle_info "$info"
55 fi
56done
This page took 0.095901 seconds and 4 git commands to generate.