-
Notifications
You must be signed in to change notification settings - Fork 7
/
update.sh
executable file
·55 lines (47 loc) · 2.34 KB
/
update.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
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash -ex
cd "$(dirname "$0")"
function sync_dir
{
if [ -z $1 ]; then
echo "ERROR: target directory value is not set"
exit 1
fi
TARGET_DIR="$1"
if [ -z $2 ]; then
echo "ERROR: source directory array is not set"
exit 1
fi
SOURCE_DIRS=($2) # convert space separated string to array
if [ -z $3 ]; then
echo "ERROR: include glob array is not set"
exit 1
fi
INCLUDE_GLOBS=($3) # convert space separated string to array
SERVER_HOSTNAME="gdc.cddis.eosdis.nasa.gov"
LFTP_MIRROR_OPTS="--no-empty-dirs --no-perms --no-umask --ignore-time --parallel=10"
lftp -d -u anonymous,[email protected] -e "set ftp:ssl-force true" -e "mirror ${LFTP_MIRROR_OPTS} $(echo ${SOURCE_DIRS[@]/#/--directory=}) $(echo ${INCLUDE_GLOBS[@]/#/--include-glob=}) --target-directory=${TARGET_DIR};exit" ${SERVER_HOSTNAME}
}
HH="[0-2][0-9]"
YY="[0-9][0-9]"
YYYY="[0-9][0-9][0-9][0-9]"
DOY="[0-9][0-9][0-9]"
DOW="[0-9]"
V="[0-9]"
GPS_WEEK="[0-9][0-9][0-9][0-9]"
END_YEAR=$(date -u +%Y)
START_YEAR=$(( ${END_YEAR} - 1 ))
for CURR_YEAR in $(seq ${START_YEAR} ${END_YEAR}); do
echo "STARTING YEAR: ${CURR_YEAR}"
# target dir source dirs (space separated array) include globs (space separated array)
sync_dir "./gnss/data/daily/" "/gnss/data/daily/${CURR_YEAR}/" "${DOY}/${YY}[ng]/brdc${DOY}0.${YY}[ng].Z ${DOY}/${YY}[ng]/brdc${DOY}0.${YY}[ng].gz"
sync_dir "./gnss/products/ionex/" "/gnss/products/ionex/${CURR_YEAR}/" "${DOY}/COD0OPSFIN_${YYYY}${DOY}0000_01D_01H_GIM.INX.gz ${DOY}/COD0OPSRAP_${YYYY}${DOY}0000_01D_01H_GIM.INX.gz"
sync_dir "./gnss/products/bias/" "/gnss/products/bias/${CURR_YEAR}/" "*_DCB.BSX.gz *_DCB.BIA.gz"
done
END_GPS_WEEK=$(( ( $(date -u +%s) - $(date -u -d'1980-01-06 00:00:00' +%s) ) / 60 / 60 / 24 / 7 ))
START_GPS_WEEK=$(( ${END_GPS_WEEK} - 52 ))
for CURR_GPS_WEEK in $(seq ${START_GPS_WEEK} ${END_GPS_WEEK}); do
echo "STARTING GPS WEEK: ${CURR_GPS_WEEK}"
# target dir source dirs (space separated array) include globs (space separated array)
sync_dir "./gnss/products/" "/gnss/products/${CURR_GPS_WEEK}/" "IGS${V}OPSFIN_${YYYY}${DOY}0000_01D_15M_ORB.SP3.gz IGS${V}OPSRAP_${YYYY}${DOY}0000_01D_15M_ORB.SP3.gz IGS${V}OPSULT_${YYYY}${DOY}${HH}00_02D_15M_ORB.SP3.gz"
sync_dir "./glonass/products/" "/glonass/products/${CURR_GPS_WEEK}/" "ig[l]${GPS_WEEK}${DOW}.sp3.Z"
done