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