-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinstall_fits.sh
executable file
·245 lines (213 loc) · 4.87 KB
/
install_fits.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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/bin/bash
#############################################################
# AlpacaPi setup
#############################################################
# Edit History
#############################################################
#++ Sep 14, 2023 <MLS> Created install_fits.sh
#++ Jul 18, 2024 <MLS> Updated to handle cfitsio-4.4.1
#++ Dec 31, 2024 <MLS> Updated to handle cfitsio-4.5.0
#############################################################
# This will get the default version
# sudo apt-get install libcfitsio-dev
# https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/
###########################################################
function CheckFile
{
MYPATH=$1
FILENAME=$2
ERRSTRING=$3
#echo $1
#echo $2
#echo $3
FULLPATH="$MYPATH/$FILENAME"
#echo $FULLPATH
if [ -d $FULLPATH ]
then
STATUS="Present"
ERRSTRING=""
else
if [ -f $FULLPATH ]
then
STATUS="Present"
ERRSTRING=""
else
STATUS="Missing"
let MISSING_COUNT=$MISSING_COUNT+1
fi
fi
# echo -e "\t$FILENAME\t\t$STATUS"
printf "\t%-24s\t%s\t%s\r\n" $FILENAME $STATUS "$ERRSTRING"
}
###########################################################
function CheckFITSversion
{
CFITSIO_PRESENT=false
# Version 3.47 - May 2019
if [ -d cfitsio-3.47 ]
then
CFITSIO_PRESENT=true
FITS_FOLDER="cfitsio-3.47"
fi
# Version 3.48 - Mar 2020
if [ -d cfitsio-3.48 ]
then
CFITSIO_PRESENT=true
FITS_FOLDER="cfitsio-3.48"
fi
# Version 3.49 - Aug 2020
if [ -d cfitsio-3.49 ]
then
CFITSIO_PRESENT=true
FITS_FOLDER="cfitsio-3.49"
fi
# not released yet, but just being prepared
if [ -d cfitsio-3.50 ]
then
CFITSIO_PRESENT=true
FITS_FOLDER="cfitsio-3.50"
fi
# Version 4.0.0 - Sep 2021
if [ -d cfitsio-4.0.0 ]
then
CFITSIO_PRESENT=true
FITS_FOLDER="cfitsio-4.0.0"
fi
# Version 4.1.0 - Sep 2021
if [ -d cfitsio-4.1.0 ]
then
CFITSIO_PRESENT=true
FITS_FOLDER="cfitsio-4.1.0"
fi
if [ -d cfitsio-4.4.1 ]
then
CFITSIO_PRESENT=true
FITS_FOLDER="cfitsio-4.4.1"
fi
if [ -d cfitsio-4.5.0 ]
then
CFITSIO_PRESENT=true
FITS_FOLDER="cfitsio-4.5.0"
fi
}
###########################################################
function UntarFitsFile
{
echo -n "Getting ready to untar $CFITSIO_TAR, do you want to proceed [y/n]?"
read YESNO
if [ $YESNO == "y" ]
then
tar -xvf $CFITSIO_TAR
fi
}
###########################################################
function CheckForFITSIO
{
FITS_INSTALLED=false
FITS_LOCATION="not-found"
if [ -f "/usr/local/include/fitsio.h" ]
then
FITS_INSTALLED=true
FITS_LOCATION="/usr/local/include"
fi
if [ -f "/usr/include/fitsio.h" ]
then
FITS_INSTALLED=true
FITS_LOCATION="/usr/include"
fi
}
###########################################################
function DownloadFITStarFile
{
if [ -f $CFITSIO_TAR ]
then
echo "FITS tar file already present $CFITSIO_TAR"
else
wget "http://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio_latest.tar.gz"
fi
}
###########################################################
function InstallFits
{
CFITSIO_TAR="cfitsio_latest.tar.gz"
DownloadFITStarFile
CheckForFITSIO
echo "FITS_INSTALLED = $FITS_INSTALLED"
if [ $FITS_INSTALLED == true ]
then
echo "Fits located at $FITS_LOCATION"
grep CFITSIO_VERSION $FITS_LOCATION/fitsio.h
exit
else
echo "We will now try to install fitsio"
fi
#if [ -f "/usr/local/include/fitsio.h" ]
if [ $FITS_INSTALLED == true ]
then
echo "cfitsio already installed"
else
CheckFITSversion
if [ $CFITSIO_PRESENT == true ]
then
echo "cfitsio already un-tared, leaving it alone, version = $FITS_FOLDER"
else
if [ -f $CFITSIO_TAR ]
then
echo "cfitsio tar file found, untaring....."
UntarFitsFile
else
echo "did not find $CFITSIO_TAR"
echo -n "Would you like to try downloading the FITS support library (cfitsio) [y/n]?"
read YESNO
if [ $YESNO == "y" ]
then
echo "Downloading $CFITSIO_TAR..........."
wget "http://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/$CFITSIO_TAR"
UntarFitsFile
fi
fi
fi
CheckFITSversion
echo "Fits version = $FITS_FOLDER"
if [ $CFITSIO_PRESENT == true ]
then
echo "We are now ready to build and install cfitsio"
echo -n "Some of this will use require super user (sudo). Would you like to proceed [y/n]?"
read YESNO
if [ $YESNO == "y" ]
then
if [ -d $FITS_FOLDER ]
then
cd $FITS_FOLDER
pwd
./configure --prefix=/usr/local
make
sudo make install
sudo /sbin/ldconfig -v
make testprog
if [ -f testprog ]
then
echo "testprog Make success"
sleep 5
./testprog > testprog.lis
DIFFCNT=`diff testprog.lis testprog.out | wc -l`
echo $DIFFCNT
if [ "$DIFFCNT" -eq "0" ]
then
echo "Install OK"
else
echo "Install Failed (testprog)"
diff testprog.lis testprog.out | wc
fi
cmp testprog.fit testprog.std | wc
else
echo "Failed to make testprog"
fi
else
echo "Could not find directory ($FITS_FOLDER)"
fi
fi
fi
fi
}
InstallFits