1#!/bin/sh
2#####################################################################################
3#
4# Test data setup script for all OSSIM repositories. The following env vars must be
5# set in the GoCD environment:
6#
7#   OSSIM_DATA_REPOSITORY -- local NFS mount point for data repository
8#   OSSIM_DATA -- Local directory to contain elevation, imagery, and expected results
9#
10# The test data directory, specified by the env var OSSIM_DATA is
11# syncronized against a master repository. The master data repository is
12# assumed to be NFS-mounted at the mount point specified in the environment
13# variable "OSSIM_DATA_REPOSITORY". The data will be rsynced to the local
14# directory specified by "OSSIM_DATA" env var.
15#
16#####################################################################################
17
18echo; echo "Running setup.sh script from <$PWD>...";
19
20echo "STATUS: Checking presence of env var OSSIM_DATA = <$OSSIM_DATA>...";
21if [ -z $OSSIM_DATA ] || [ ! -d $OSSIM_DATA ] ; then
22  echo "ERROR: Env var OSSIM_DATA must be defined and exist in order to syncronize against data repository.";
23  exit 1;
24fi
25
26echo "STATUS: Checking access to data repository at <$OSSIM_DATA_REPOSITORY>...";
27if [ -z $OSSIM_DATA_REPOSITORY ] || [ ! -d $OSSIM_DATA_REPOSITORY ] ; then
28  echo "ERROR: Env var OSSIM_DATA_REPOSITORY must be defined and exist in order to syncronize against data repository.";
29  exit 1;
30fi
31
32# rsync elevation data:
33echo "STATUS: Syncing elevation data...";
34rsync -rmv --delete $OSSIM_DATA_REPOSITORY/elevation/dted/level0 $OSSIM_DATA/elevation/dted;
35if [ $? != 0 ] ; then
36  echo "ERROR: Failed data repository rsync of elevation.";
37  exit 1;
38fi
39
40# rsync nadcon data:
41echo "STATUS: Syncing nadcon data...";
42rsync -rm --delete $OSSIM_DATA_REPOSITORY/elevation/nadcon $OSSIM_DATA/elevation;
43if [ $? != 0 ] ; then
44  echo "ERROR: Failed data repository rsync of nadcon grids.";
45  exit 1;
46fi
47
48if [ ! -d $OSSIM_DATA/elevation/geoids ] ; then
49  echo "STATUS: Creating missing geoids subdirectory";
50  mkdir $OSSIM_DATA/elevation/geoids;
51  if [ $? != 0 ] ; then
52    echo "ERROR: Failed creatiion of geoids directory at <$OSSIM_DATA/elevation/geoids>.";
53    exit 1;
54  fi
55fi
56
57# rsync geoid 96 data:
58echo "STATUS: Syncing geoid96 data...";
59rsync -rm --delete $OSSIM_DATA_REPOSITORY/elevation/geoid96_little_endian/ $OSSIM_DATA/elevation/geoids/geoid96;
60if [ $? != 0 ] ; then
61  echo "ERROR: Failed data repository rsync of geoid96 grids.";
62  exit 1;
63fi
64
65# rsync geoid 99 data:
66echo "STATUS: Syncing geoid99 data...";
67rsync -rm --delete $OSSIM_DATA_REPOSITORY/elevation/geoid99_little_endian/ $OSSIM_DATA/elevation/geoids/geoid99;
68if [ $? != 0 ] ; then
69  echo "ERROR: Failed data repository rsync of geoid99 grids.";
70  exit 1;
71fi
72
73#rsync imagery
74echo "STATUS: Syncing image data...";
75rsync -rm --delete $OSSIM_DATA_REPOSITORY/test/data/public $OSSIM_DATA/ossim_data;
76if [ $? != 0 ] ; then
77  echo "ERROR: Failed data repository rsync of imagery.";
78  exit 1;
79fi
80
81exit 0;
82
83
84