source:
vendors/fcm/1-5/examples/etc/regular-update.eg
@
1981
Last change on this file since 1981 was 1980, checked in by flavoni, 14 years ago | |
---|---|
File size: 1.2 KB |
Line | |
---|---|
1 | #!/bin/sh |
2 | # ------------------------------------------------------------------------------ |
3 | # (C) Crown copyright Met Office. All rights reserved. |
4 | # For further details please refer to the file COPYRIGHT.txt |
5 | # which you should have received as part of this distribution. |
6 | # ------------------------------------------------------------------------------ |
7 | |
8 | lockfile='lock' |
9 | |
10 | if [[ -f $lockfile ]]; then |
11 | exit |
12 | fi |
13 | |
14 | touch $lockfile |
15 | |
16 | headrevfile='latest' |
17 | lastrevfile='lastrev' |
18 | |
19 | # Current HEAD revision |
20 | if [[ ! -r $headrevfile ]]; then |
21 | echo "HEAD revision file $headrevfile cannot be read, abort" >&2 |
22 | rm -f $lockfile |
23 | exit 1 |
24 | fi |
25 | headrev=`cat $headrevfile` |
26 | headrev=`echo $headrev` |
27 | |
28 | # Revision at which this script is last run |
29 | if [[ -r $lastrevfile ]]; then |
30 | lastrev=`cat $lastrevfile` |
31 | lastrev=`echo $lastrev` |
32 | else |
33 | lastrev=0 |
34 | fi |
35 | |
36 | # Exit if HEAD revision is the same as the last run revision |
37 | if (($lastrev == $headrev)); then |
38 | rm -f $lockfile |
39 | exit 0 |
40 | fi |
41 | |
42 | # ------------------------------------------------------------------------------ |
43 | # Do something... |
44 | # ------------------------------------------------------------------------------ |
45 | |
46 | # Update last run revision file |
47 | echo $headrev >$lastrevfile |
48 | rm -f $lockfile |
49 | |
50 | # EOF |
Note: See TracBrowser
for help on using the repository browser.