source: LMDZ5/branches/LF-private/tools/fcm/templates/hook/post-commit-background @ 5028

Last change on this file since 5028 was 1578, checked in by jghattas, 13 years ago
  • Add fcm in LMDZ5/tools directory

It is no longer needed to have fcm in your environement PATH variable.
Now makelmdz_fcm takes by default this fcm. It is still possible to use
another fcm, using -fcm_path argument in makelmdz_fcm.

  • Property svn:executable set to *
File size: 2.8 KB
Line 
1#!/bin/ksh
2# ------------------------------------------------------------------------------
3# NAME
4#   post-commit-background
5#
6# SYNOPSIS
7#   post-commit-background REPOS REV
8#
9# DESCRIPTION
10#   This script performs the Subversion post-commit tasks in the background. The
11#   first argument must be the path to the current Subversion repository, and
12#   the second argument must be the revision of the current commit. Errors in
13#   the script are automatically e-mailed to the FCM user account.
14#
15#   The script does the following:
16#    1. updates the "latest" file in the log directory with the latest revision
17#       number of the repository.
18#    2. creates an incremental revision dump of the current revision.
19#    3. runs "background_updates.pl" if it exists in the hook script directory.
20#
21# COPYRIGHT
22#   (C) Crown copyright Met Office. All rights reserved.
23#   For further details please refer to the file COPYRIGHT.txt
24#   which you should have received as part of this distribution.
25# ------------------------------------------------------------------------------
26
27REPOS=$1
28REV=$2
29
30REPOS_NAME=${REPOS##*/}
31LOG_DIR=~fcm/svn/post-commit
32LOG_FILE=$LOG_DIR/${REPOS_NAME}.log
33DUMP_DIR=~fcm/svn/dumps/$REPOS_NAME
34DUMP_FILE=$DUMP_DIR/$REV
35ERR=''
36
37{
38  # Update the "latest" file with the latest revision number
39  # ----------------------------------------------------------------------------
40  echo "$(date): Updating ${REPOS_NAME}.latest ..."
41  echo $REV > $LOG_DIR/${REPOS_NAME}.latest
42
43  if (($? != 0)); then
44    ERR="${ERR}Update of ${REPOS_NAME}.latest: failed. "
45  fi
46
47  # Dump the current revision
48  # ----------------------------------------------------------------------------
49  if [[ ! -d $DUMP_DIR ]]; then
50    mkdir -p $DUMP_DIR
51  fi
52
53  svnadmin dump -r $REV --incremental --deltas $REPOS 1>$DUMP_FILE
54
55  if (($? != 0)); then
56    ERR="${ERR}$REPOS_NAME@$REV: svnadmin dump: failed. "
57  fi
58
59  # Warn us of large changesets (>1Mb)
60  dump_size=$(stat -c %s $DUMP_FILE)
61
62  if (($dump_size > 1048576)); then
63    ERR="${ERR}Dump size exceeds 1Mb. "
64    echo "WARNING: large changeset dump, size = ${dump_size}byte">&2 
65  fi
66
67  # Perform background update, if necessary
68  # ----------------------------------------------------------------------------
69  if [[ -e ${REPOS}/hooks/background_updates.pl ]]; then
70    echo "$(date): Running background tasks and exiting ..."
71    ${REPOS}/hooks/background_updates.pl $REPOS_NAME $LOG_DIR
72
73    if (($? != 0)); then
74      ERR="${ERR}background_updates.pl: failed. "
75    fi
76
77  else
78    echo "$(date): No background tasks required - exiting"
79  fi
80
81} 1>$LOG_FILE 2>&1
82
83# If there are errors, e-mail the log message to FCM
84# ------------------------------------------------------------------------------
85if [[ -n $ERR ]]; then
86  ERR=${ERR% *}
87  /bin/mail -s "$REPOS@$REV: $ERR" my.name@somewhere.org <<EOF
88$(<$LOG_FILE)
89EOF
90fi
Note: See TracBrowser for help on using the repository browser.