-
Notifications
You must be signed in to change notification settings - Fork 0
/
cspp_viirs_edr_update2latest.sh
213 lines (178 loc) · 5.99 KB
/
cspp_viirs_edr_update2latest.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#!/bin/bash
# $Id$
#
# Script to download the latest version of the CSPP VIIRS EDR software
# and LUTS. Checks if the installed version is the latest version.
#
#
# Environment settings:
# CSPP_EDR_HOME : the location of the CSPP EDR installation
#
# Written by Geoff Cureton UW/SSEC, January 2014
#
# Copyright 2011-2014, University of Wisconsin Regents.
# Licensed under the GNU GPLv3.
if [ -z "${CSPP_EDR_HOME}" ] ; then
echo "Please set CSPP_EDR_HOME "
exit 1
fi
currentDir=$(pwd)
echo "The current directory is ${currentDir}"
CSPP_ROOT=$(dirname ${CSPP_EDR_HOME})
echo "The CSPP root directory is ${CSPP_ROOT}"
CSPP_EDR_LUTS=${CSPP_EDR_HOME}/anc/cache/luts/viirs
echo "The CSPP VIIRS LUTS are in ${CSPP_EDR_LUTS}"
echo ""
#export CSPP_EDR_REMOTE_DIR=http:https://www.ssec.wisc.edu/~geoffc/CSPP_VIIRS_EDR_packages
export CSPP_EDR_REMOTE_DIR=ftp:https://ftp.ssec.wisc.edu:/pub/geoffc/CSPP_VIIRS_EDR_packages
################################
# Updating the cache package #
################################
checksum_file="CSPP_EDR_CACHE_LATEST_Checklist.md5"
echo "Downloading latest CSPP EDR VIIRS cache checksum ${CSPP_EDR_REMOTE_DIR}/${checksum_file} ..."
lftpget -c "${CSPP_EDR_REMOTE_DIR}/${checksum_file}"
if [ $? -ne 0 ] ; then
echo ""
echo "Download of latest CSPP VIIRS CACHE package was not successful."
exit 1
else
echo "Download of ${checksum_file} successful"
fi
# Check that the checksum file is actually a file that exists
if [[ ! -e ${checksum_file} && ! -f ${checksum_file} ]]; then
echo "the file ${checksum_file} does not exist, aborting..."
exit 1
fi
if [[ ! -f ${checksum_file} ]]; then
echo "the file ${checksum_file} is not a file, aborting..."
exit 1
fi
#
# Check that the installed cache package matches the checksum...
#
cache_tarfile="CSPP_EDR_CACHE_LATEST.tar.gz"
cd ${CSPP_ROOT}
md5sum -c ${currentDir}/${checksum_file} --status
md5_success=$?
cd ${currentDir}
if [ ${md5_success} -ne 0 ] ; then
echo ""
echo "Current CSPP EDR VIIRS cache installation does not match latest package, reinstalling."
echo "Downloading latest CSPP EDR VIIRS cache tarball..."
lftpget -c "${CSPP_EDR_REMOTE_DIR}/${cache_tarfile}"
if [ $? -ne 0 ] ; then
echo ""
echo "Download of latest CSPP EDR VIIRS cache package was not successful."
exit 1
else
echo ""
echo "Download successful"
fi
echo "Removing old CSPP EDR VIIRS cache installation..."
rm -rvf ${CSPP_EDR_HOME}/anc/cache/luts/viirs
rm -rvf ${CSPP_EDR_HOME}/anc/cache/NAAPS-ANC-Int
echo "Installing latest CSPP EDR VIIRS cache package..."
tar xzvf ${cache_tarfile} -C ${CSPP_ROOT}
if [ $? -ne 0 ] ; then
echo ""
echo "Installation of latest CSPP EDR VIIRS cache package was not successful."
exit 1
else
echo ""
echo "Installation of latest CSPP EDR VIIRS cache package was successful."
fi
# Check that the newly installed cache matches the checksum
cd ${CSPP_ROOT}
md5sum -c ${currentDir}/${checksum_file} --status
md5_success=$?
cd ${currentDir}
if [ ${md5_success} -ne 0 ] ; then
echo ""
echo "Latest CSPP EDR VIIRS cache installation does not match associated checksum, aborting..."
exit 1
else
echo ""
echo "Latest CSPP EDR VIIRS cache installation matches associated checksum."
echo ""
fi
else
echo ""
echo "Current CSPP EDR VIIRS cache installation matches latest package."
echo ""
fi
###############################
# Updating the code package #
###############################
checksum_file="CSPP_EDR_LATEST_Checklist.md5"
echo "Downloading latest CSPP EDR VIIRS code checksum ${CSPP_EDR_REMOTE_DIR}/${checksum_file} ..."
lftpget -c "${CSPP_EDR_REMOTE_DIR}/${checksum_file}"
if [ $? -ne 0 ] ; then
echo ""
echo "Download of latest CSPP VIIRS code package was not successful."
exit 1
else
echo "Download of ${checksum_file} successful"
fi
# Check that the checksum file is actually a file that exists
if [[ ! -e ${checksum_file} && ! -f ${checksum_file} ]]; then
echo "the file ${checksum_file} does not exist, aborting..."
exit 1
fi
if [[ ! -f ${checksum_file} ]]; then
echo "the file ${checksum_file} is not a file, aborting..."
exit 1
fi
#
# Check that the installed code package matches the checksum...
#
code_tarfile="CSPP_EDR_LATEST.tar.gz"
cd ${CSPP_ROOT}
md5sum -c ${currentDir}/${checksum_file} --status
md5_success=$?
cd ${currentDir}
if [ ${md5_success} -ne 0 ] ; then
echo ""
echo "Current CSPP EDR VIIRS code installation does not match latest package, reinstalling."
echo "Downloading latest CSPP EDR VIIRS code tarball..."
lftpget -c "${CSPP_EDR_REMOTE_DIR}/${code_tarfile}"
if [ $? -ne 0 ] ; then
echo ""
echo "Download of latest CSPP EDR VIIRS code package was not successful."
exit 1
else
echo ""
echo "Download successful"
fi
echo "Removing old CSPP EDR VIIRS code installation..."
rm -rvf $CSPP_EDR_HOME/common
rm -rvf $CSPP_EDR_HOME/viirs
rm -rvf $CSPP_EDR_HOME/cspp_edr_*.sh
echo "Installing latest CSPP EDR VIIRS code package..."
tar xzvf ${code_tarfile} -C ${CSPP_ROOT}
if [ $? -ne 0 ] ; then
echo ""
echo "Installation of latest CSPP EDR VIIRS code package was not successful."
exit 1
else
echo ""
echo "Installation of latest CSPP EDR VIIRS code package was successful."
fi
# Check that the newly installed code matches the checksum
cd ${CSPP_ROOT}
md5sum -c ${currentDir}/${checksum_file} --status
md5_success=$?
cd ${currentDir}
if [ ${md5_success} -ne 0 ] ; then
echo ""
echo "Latest CSPP EDR VIIRS code installation does not match associated checksum, aborting..."
else
echo ""
echo "Latest CSPP EDR VIIRS code installation matches associated checksum."
exit 1
fi
else
echo ""
echo "Current CSPP EDR VIIRS code installation matches latest package."
echo ""
fi
exit 0