ingest.sh 849 Bytes
Newer Older
1
2
3
4
5
#!/usr/bin/env bash

set -u
set -e

Nick Bearson's avatar
Nick Bearson committed
6
7
8
LOG=/home/eodn/eodn2realearth/log/ingest.log
exec >> $LOG 2>&1

9
10
11
12
13
14
15
16
17
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
Nick Bearson's avatar
Nick Bearson committed
18
  echo "SAW LANDSAT ZIP: ${filename}"
19
20
  SCRIPT="bash -x /home/eodn/eodn2realearth/src/process-LCzip.sh"
else # not recognized
Nick Bearson's avatar
Nick Bearson committed
21
  echo "QUARANTINE (NOT RECOGNIZED): ${filename}"
22
23
24
25
26
27
28
29
30
31
32
33
  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