ingest.sh 697 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash

set -u
set -e

INCOMING=/home/eodn/eodn2realearth/incoming
PROCESSING=/home/eodn/eodn2realearth/processing
QUARANTINE=/home/eodn/eodn2realearth/quarantine

filepath=$(readlink -f $1)
filename=$(basename $filepath)

# set $SCRIPT based on input type
if [ ${filename:0:2} == "LC" ] && [ ${filename: -4} == ".zip" ]; then  # landsat zip files
  SCRIPT="bash -x /home/eodn/eodn2realearth/src/process-LCzip.sh"
else # not recognized
  mkdir -p ${QUARANTINE}
  mv $filepath ${QUARANTINE}/${filename}
  exit 0
fi

mkdir -p ${PROCESSING}/${filename}
cd ${PROCESSING}/${filename}
mv $filepath ${filename}
$SCRIPT ${filename} 
if [ $? -eq 0 ]; then
  rm -r ${PROCESSING}/${filename}
fi