-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-heasoft.sh
181 lines (156 loc) · 5.68 KB
/
install-heasoft.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
#!/bin/bash
echo "Do you want to create a log file where all output will be dumped (Default is no)? [yes/no]"
read log_status
if [ -z "$log_status" ]
then
log_status="no"
fi
if [ "$log_status" == "no" ] || [ "$log_status" == "yes" ]
then
:
else
echo "Invalid input!"
fi
echo "Updating packages..."
sudo apt update && sudo apt -y upgrade >> install.log
echo "Packages updated successfully"
ubuntu_version=$(lsb_release -rs 2>/dev/null)
echo "Ubuntu version: ${ubuntu_version}"
ubuntu_version=$(echo "${ubuntu_version}" | bc -l)
flag_version=23.10
if [ -f "/proc/sys/fs/binfmt_misc/WSLInterop" ]
then
echo "Operating system: Windows Subsystem for Linux detected"
available_space=$(df -h /mnt/c | awk 'NR==2 {print $4}' | tr -d 'G')
echo "Space available in C: ${available_space}"
if [ ${available_space} -lt 10 ]
then
echo "Available space must be greater than 10 GB. Please clean up your storage and run the script again"
exit 1 2>/dev/null
else
echo "Proceeding with installation..."
fi
else
echo "Operating system: Linux detected"
fi
if (( $(echo "${ubuntu_version} > ${flag_version}" | bc -l) ))
then
sudo apt-get install libncurses-dev
if dpkg -l | grep -q "libncurses-dev"
then
echo "libncurses-dev installed successfully"
else
echo "libncurses-dev installation unsucessful. Exiting..."
exit 1 2>/dev/null
fi
else
sudo apt-get install libncurses5-dev
if dpkg -l | grep -q "libncurses5-dev"
then
echo "libncurses5-dev installed successfully"
else
echo "libncurses5-dev installation unsucessful. Exiting..."
exit 1 2>/dev/null
fi
fi
packages=(libreadline-dev ncurses-dev curl libcurl4 libcurl4-gnutls-dev xorg-dev make gcc g++ gfortran perl-modules python3-dev python3-pip python3-setuptools python3-astropy python3-numpy python3-scipy python3-matplotlib)
echo "Installing required dependencies..."
for package in "${packages[@]}"
do
echo "Installing ${package}..."
sudo apt-get install -y "${package}"
if dpkg -l | grep -q "${package}"
then
echo "${package} installed successfully"
else
echo "${package} installation unsucessful. Exiting..."
exit 1 2>/dev/null
fi
done
echo "Defining environment variables..."
export CC=/usr/bin/gcc
export CXX=/usr/bin/g++
export FC=/usr/bin/gfortran
export PERL=/usr/bin/perl
export PYTHON=/usr/bin/python3
echo "Environment variables defined"
mkdir ~/heasoft
if [ -d "${HOME}/heasoft" ]
then
cd ~/heasoft
else
echo "Fatal error! Unable to create heasoft directory"
exit 1 2>/dev/null
fi
location=$(pwd)
while true
do
wget "https://heasarc.gsfc.nasa.gov/cgi-bin/Tools/tarit/tarit.pl?mode=download&arch=src&src_pc_linux_ubuntu=Y&src_other_specify=&checkeverything=on&checkallmission=on&mission=asca&mission=einstein&mission=exosat&mission=gro&mission=heao1&mission=hitomi&mission=integral&mission=ixpe&mission=maxi&mission=nicer&mission=nustar&mission=oso8&mission=rosat&mission=suzaku&mission=swift&mission=vela5b&mission=xte&checkallgeneral=on&general=attitude&general=caltools&general=futils&general=fimage&general=heasarc&general=heasim&general=heasptools&general=heatools&general=heagen&general=fv&general=timepkg&checkallxanadu=on&xanadu=ximage&xanadu=xronos&xanadu=xspec&xstar=xstar" -O heasoft.tar.gz && touch download.ok || touch download.bad
if [[ $(ls | grep '\.ok$') ]]
then
break
fi
done
echo "Unsetting required flags..."
unset CFLAGS CXXFLAGS FFLAGS LDFLAGS
echo "Flags unset"
if [[ $(ls | grep 'heasoft.tar.gz$') ]]
then
echo "Extracting..."
if tar -xvzf heasoft.tar.gz
then
hea_dir=$(tar -tzf "heasoft.tar.gz" | head -n 1 | cut -f1 -d'/')
echo "Extraction successful"
else
echo "Fatal error! Unable to extract content"
exit 1 2>/dev/null
fi
fi
echo "Configuring heasoft..."
cd $hea_dir/BUILD_DIR/
if [ "$log_status" == "yes" ]
then
./configure >> $location/install.log 2>&1
configure_check=$(tail -n 1 $location/install.log)
if [ "$configure_check" = "Finished" ]; then
echo "Configuration successful"
else
echo "Configuration unsuccessful. Terminating..."
exit 1 2>/dev/null
fi
echo "Compiling files. This can take upto an hour depending on the system and much longer if you are using WSL..."
make >> $location/install.log 2>&1
compile_check=$(tail -n 1 $location/install.log)
echo $compile_check
if [ "$compile_check" = "Finished make all" ]; then
echo "Compilation successful"
else
echo "Compilation unsuccessful. Terminating..."
exit 1 2>/dev/null
fi
echo "Installing. This can take up to 30 minutes or more depending on the system and even more if you are using WSL..."
make install >> $location/install.log 2>&1
install_check=$(tail -n 1 $location/install.log)
if [ "$install_check" = "Finished make install" ]; then
echo "Installation successful"
else
echo "Installation unsuccessful. Terminating..."
exit 1 2>/dev/null
fi
else
./configure
echo "Compiling files. This can take upto an hour depending on the system and much longer if you are using WSL..."
make
echo "Installing. This can take up to 30 minutes or more depending on the system and even more if you are using WSL..."
make install
fi
cd ../x86_64*
echo "Making init shell script executable..."
chmod u+x headas-init.sh
headas_path=$(pwd)
echo "Modifying .bashrc..."
echo -e "\n#heasoft\n\nexport HEADAS=\"${headas_path}\"\nsource \"\$HEADAS/headas-init.sh\"" >> $HOME/.bashrc
source $HOME/.bashrc
hea_version=$(fversion)
echo "Heasoft version: ${hea_version} installed successfully"
rm $HOME/heasoft/heasoft.tar.gz