-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsource-heasoft.sh
More file actions
executable file
·96 lines (76 loc) · 2.03 KB
/
Copy pathsource-heasoft.sh
File metadata and controls
executable file
·96 lines (76 loc) · 2.03 KB
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
#!/bin/bash
# This bash script is part of the MEGAlib & COSItools setup procedure.
# As such it is dual licenced under Apache 2.0 for COSItools and LGPL 3.0 for MEGAlib
#
# Development lead: Andreas Zoglauer
#
# Description:
# Source all HEASoft-related environment variables
# Make this script work with zsh
if [ -n "$ZSH_VERSION" ]; then emulate -L ksh; fi
# Print some help
confhelp() {
echo ""
echo "This script sources all HEASoft-related environment variables"
echo " "
echo "Usage: ./source-heasoft.sh --path=[full path to the HEASoft installation]";
echo " "
}
# Parse the command line
CMD=( "$@" )
__TMP_PATH=""
__TMP_HERE=$(pwd)
for C in "${CMD[@]}"; do
if [[ ${C} == *-p*=* ]]; then
__TMP_PATH=`echo ${C} | awk -F"=" '{ print $2 }'`
elif [[ ${C} == *-h ]] || [[ ${C} == *-hel* ]]; then
echo ""
confhelp
exit 0
fi
done
# Perform sanity checks
# We require an absolute path
if [[ ${__TMP_PATH} != /* ]]; then
echo ""
echo "ERROR: The HEASoft path must be an absolute path: ${__TMP_PATH}"
echo ""
return
fi
# The directory must exist
if [[ ! -d ${__TMP_PATH} ]]; then
echo ""
echo "ERROR: HEASoft directory not found: ${__TMP_PATH}"
echo ""
return
fi
# Source the HEASoft environment
__TMP_HEADASFOUND=false
__TMP_CFITSIOFOUND=false
if [[ -f ${__TMP_PATH}/headas-init.sh ]]; then
export HEADAS=${__TMP_PATH}
alias heainit=". ${HEADAS}/headas-init.sh"
source ${HEADAS}/headas-init.sh
__TMP_HEADASFOUND=true
fi
if [[ `uname -a` == *Linux* ]]; then
if [[ -f ${__TMP_PATH}/lib/libcfitsio.so ]]; then
__TMP_CFITSIOFOUND=true
fi
else
# Too many installation options here - don't do the check...
__TMP_CFITSIOFOUND=true
fi
if [[ ${__TMP_HEADASFOUND} == false ]]; then
echo ""
echo "ERROR: HEADAS software not found in HEADAS directory"
echo ""
return
fi
if [[ ${__TMP_CFITSIOFOUND} == false ]]; then
echo ""
echo "ERROR: libcfitsio not found in the HEADAS library directory"
echo " You should make a link such as libcfitsio_3.XY.so -> libcfitsio.so"
return
fi
return