forked from msproul/AlpacaPi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·385 lines (320 loc) · 8.29 KB
/
setup.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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
#!/bin/bash
#############################################################
# AlpacaPi setup
#############################################################
# Edit History
#############################################################
# Dec 13, 2020 <MLS> Starting on setup for github downloads
# Dec 14, 2020 <MLS> Working on FITS install
# Dec 16, 2020 <MLS> FITS install working
# Feb 9, 2021 <MLS> Added support for FLIR-SDK
# Sep 22, 2021 <MLS> Updated to support cfitsio Version 4.0.0
#############################################################
#
# sudo apt-get install libudev-dev
# sudo apt-get install libopencv-dev
# sudo apt-get install libi2c-dev
# sudo apt-get install libjpeg-dev
###########################################################
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 CheckOpenCV
{
OPENCV_INSTALLED=false
OPENCV_STRING="Missing"
if [ -f "/usr/include/opencv2/highgui/highgui_c.h" ]
then
OPENCV_INSTALLED=true
OPENCV_STRING="Installed in /usr/include"
fi
if [ -f "/usr/local/include/opencv2/highgui/highgui_c.h" ]
then
OPENCV_INSTALLED=true
OPENCV_STRING="Installed in /usr/local/include"
fi
printf "\t%-24s\t%s\r\n" "OpenCV" "$OPENCV_STRING"
echo "To install opencv on Raspberry Pi"
echo " >sudo apt-get update"
echo " >sudo apt-get install libopencv-dev"
}
###########################################################
function Checksystem
{
MISSING_COUNT=0
clear
pwd
echo "**********************************************"
echo "* AlpacaPi system check *"
echo "* *"
echo "* It is OK to run this script multiple times *"
echo "* *"
echo "* Not all of these libraries are required *"
echo "* For example, if you don't use QHY cameras *"
echo "* then the QHY library is not needed *"
echo "**********************************************"
echo "Build tools"
CheckFile "/usr/bin" "gcc" "compiler not installed"
CheckFile "/usr/bin" "g++" "compiler not installed"
CheckFile "/usr/bin" "make" "make not installed"
CheckFile "/usr/bin" "cmake" "cmake not installed"
echo
echo "Local files"
CheckFile "./" "Makefile" "please re-check download"
CheckFile "./" "src" "please re-check download"
CheckFile "./" "src_discovery" "please re-check download"
CheckFile "./" "src_mlsLib" "please re-check download"
CheckFile "./" "src_MoonRise" "please re-check download"
CheckFile "./" "Objectfiles"
CheckFile "./" "ASI_lib"
CheckFile "./" "AtikCamerasSDK"
CheckFile "./" "EFW_linux_mac_SDK" "Not required"
CheckFile "./" "QHY" "Not required"
CheckFile "./" "toupcamsdk" "Not required"
echo
echo "System libraries"
# CheckFile "/usr/local/include" "fitsio.h"
# CheckFile "/usr/include" "fitsio.h"
#echo $FITS_LOCATION
CheckFile $FITS_LOCATION "fitsio.h"
echo
echo "Checking for openCV (Required for images and clients)"
CheckOpenCV
echo "*********************************************"
}
###########################################################
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
}
###########################################################
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 InstallFits
{
# wget "http://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio_latest.tar.gz
CFITSIO_TAR="cfitsio_latest.tar.gz"
CheckForFITSIO
if [ $FITS_INSTALLED ]
then
echo "Fits located at $FITS_LOCATION"
fi
#exit
#if [ -f "/usr/local/include/fitsio.h" ]
if [ $FITS_INSTALLED ]
then
echo "cfitsio already installed"
else
CheckFITSversion
if $CFITSIO_PRESENT
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
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
}
##################################################################
function setupJPEGlib()
{
echo "*******************************************************"
echo "Getting ready to install libjpeg-dev"
sudo apt-get install libjpeg-dev
}
###########################################################
function CheckForFLIR()
{
if [ -d "FLIR-SDK" ]
then
echo "FLIR SDK present, checking for installation"
cd FLIR-SDK
if [ -f "install_spinnaker_mls.sh" ]
then
echo -n "Would you like to install FLIR support [y/n]?"
read YESNO
if [ $YESNO == "y" ]
then
echo "Running FLIR install script"
./install_spinnaker_mls.sh
fi
else
echo "FLIR install script not found"
fi
cd ..
fi
}
##############################################################
# Determine platform
ARMCNT=`grep ARMv7 /proc/cpuinfo | wc -l`
if [ $ARMCNT -gt 1 ]
then
echo "Running on ARMv7"
ISARM=true
else
ISARM=false
fi
#install udev
#sudo apt-get install libudev-dev
mkdir -p Objectfiles
CheckForFITSIO
Checksystem
if [ ! -f Makefile ]
then
echo "'Makefile' is missing, please re-check download"
fi
if [ ! -d ASI_lib ]
then
echo "ZWO ASI camera is missing (ASI_lib)"
fi
InstallFits
CheckForFLIR
Checksystem
echo "*************************************************************"
echo "Installing libusb-1.0-0-dev"
sudo apt-get install libusb-1.0-0-dev
echo "MISSING_COUNT = $MISSING_COUNT"
echo "*********************************************"
echo "NOTE: This install script is not finished"
echo "Please be patient"
echo "Last updated 3/23/2022"
echo "*********************************************"