-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync_laads.sh
executable file
·42 lines (35 loc) · 1.4 KB
/
sync_laads.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# Make sure that /var/lasrc_aux is a mountpoint
lasrc_directory="$LASRC_AUX_DIR"
echo "Checking mount status"
mount | grep -q "$lasrc_directory" || exit 1
echo "Aux directory is $LASRC_AUX_DIR"
#Switch to the LASRC_AUX_DIR to check if MSILUT seed data is available.
cd "$lasrc_directory"
if [ ! -d MSILUT ]; then
echo "MSILUT data not present... fetching from USGS."
wget --no-http-keep-alive http://edclpdsftp.cr.usgs.gov/downloads/auxiliaries/lasrc_auxiliary/MSILUT.tar.gz
tar -xvzf MSILUT.tar.gz
rm MSILUT.tar.gz
fi
if [ ! -d LDCMLUT ]; then
echo "LDCMLUT data not present... fetching from USGS."
wget --no-http-keep-alive https://edclpdsftp.cr.usgs.gov/downloads/validations/for_HLS/lasrc_aux/lasrc_aux.zip
unzip lasrc_aux.zip
rm lasrc_aux.zip
fi
if [ -n "$LAADS_BUCKET_BOOTSTRAP" ]; then
echo "Syncing existing laads data from aws s3 bucket s3://$LAADS_BUCKET_BOOTSTRAP/lasrc_aux/"
aws s3 sync "s3://$LAADS_BUCKET_BOOTSTRAP/lasrc_aux/" .
fi
echo "running updatelads.py $LAADS_FLAG"
if ! updatelads.py "$LAADS_FLAG"; then
echo "updatelads.py failed"
echo "sync current /tmp/lads to s3://hls-debug-output/laads_error to debug"
aws s3 sync /tmp/lads "s3://hls-debug-output/laads_error/${AWS_BATCH_JOB_ID}/"
exit 1
fi
if [ -n "$LAADS_BUCKET" ]; then
echo "Syncing data to s3 bucket s3://$LAADS_BUCKET/lasrc_aux/"
aws s3 sync "$LASRC_AUX_DIR" "s3://$LAADS_BUCKET/lasrc_aux/"
fi