-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup
executable file
·187 lines (155 loc) · 5.38 KB
/
setup
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
#!/bin/sh
###########################################################################
# Copyright (C) 2021 HENJAB AB
#
# This file is part of vol2birdinstall.
#
# vol2birdinstall is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# vol2birdinstall is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with vol2birdinstall. If not, see <http://www.gnu.org/licenses/>.
###########################################################################
#
# Performs the installation steps for setting up the vol2bird software including dependencies
#
# @author Anders Henja (HENJAB AB)
# @date 2021-09-26
###########################################################################
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
DEFAULT_PREFIX=/opt/vol2bird
ROOTDIR="$SCRIPTPATH"
BUILDDIR="$ROOTDIR/.build"
DOWNLOADDIR="$ROOTDIR/.downloads"
PATCHDIR="$SCRIPTPATH/patches"
CURRENTDIR=`pwd`
. "$SCRIPTPATH/scripts/utilities.sh"
. "$SCRIPTPATH/scripts/defaults.sh"
. "$SCRIPTPATH/scripts/software_dependency_functions.sh"
OS_NAME=`get_os_name`
print_usage()
{
echo "Usage: setup [options] (clean) (distclean) (install)"
echo "Actions:"
echo "clean - Cleans the .build catalogue and all software will be rebuilt"
echo "distclean - Cleans the .downloads and .build catalogues and all software will be fetched and rebuilt"
echo "install - Installs the software"
echo ""
echo "Options:"
echo "--prefix=<prefix> Will install the software in the specified folder."
echo "--remove=<modules> A comma separated list of modules that should be removed from build history"
echo "--disable-mistnet If mistnet support should be disabled. Default is enabled."
echo "--download-mistnet-nexrad If installing and this is set. Then the mistnet_nexrad.pt will be downloaded and installed into <prefix>/etc."
echo "--history Prints the currently built modules"
echo "--help This help text"
}
do_install()
{
prefix=$1
enable_mistnet=$2
echo "OS_NAME=$OS_NAME"
if [ "$OS_NAME" = "Ubuntu" -o "$OS_NAME" = "Debian GNU/Linux" ]; then
sh "$SCRIPTPATH/scripts/install_debian_dependencies.sh" $* || exit_with_error 127 "Could not install dependencies"
elif [ "$OS_NAME" = "CentOS" -o "$OS_NAME" = "RedHat" -o "$OS_NAME" = "Rocky Linux" ]; then
sh "$SCRIPTPATH/scripts/install_redhat_dependencies.sh" $* || exit_with_error 127 "Could not install dependencies"
elif [ "$OS_NAME" = "Darwin" ]; then
#echo "Skipping dependencies"
sh "$SCRIPTPATH/scripts/install_macos_dependencies.sh" $* || exit_with_error 127 "Could not install dependencies"
fi
mkdir -p "$BUILDDIR" || exit_with_error 127 "Could not create build directory $BUILDDIR"
mkdir -p "$DOWNLOADDIR" || exit_with_error 127 "Could not create download directory $DOWNLOADDIR"
mkdir -p "$prefix" || exit_with_error 127 "Could not create prefix directory $prefix"
chown $USER "$prefix"
if [ "$OS_NAME" != "Darwin" ]; then
install_proj4 "$DOWNLOADDIR" "$BUILDDIR" "$prefix" "$PATCHDIR" || exit_with_error 127 "Could not build proj4"
fi
install_hlhdf "$DOWNLOADDIR" "$BUILDDIR" "$prefix" "$PATCHDIR"
install_rave "$DOWNLOADDIR" "$BUILDDIR" "$prefix" "$PATCHDIR"
install_iris2odim "$DOWNLOADDIR" "$BUILDDIR" "$prefix" "$PATCHDIR"
install_rsl "$DOWNLOADDIR" "$BUILDDIR" "$prefix" "$PATCHDIR"
if [ "$enable_mistnet" = "yes" ]; then
if [ "$OS_NAME" != "Darwin" ]; then
install_libtorch "$DOWNLOADDIR" "$BUILDDIR" "$prefix" "$PATCHDIR"
fi
fi
install_vol2bird "$DOWNLOADDIR" "$BUILDDIR" "$prefix" "$PATCHDIR" "$enable_mistnet"
}
do_clean()
{
\rm -fr "$BUILDDIR"
}
do_distclean()
{
\rm -fr "$BUILDDIR"
\rm -fr "$DOWNLOADDIR"
}
DO_INSTALL=no
DO_CLEAN=no
DO_DISTCLEAN=no
REMOVE_MODULE=
ENABLE_MISTNET=yes
DOWNLOAD_MISTNET_NEXRAD=no
PREFIX="$DEFAULT_PREFIX"
for arg in $*; do
case $arg in
--prefix=*)
PREFIX=`echo $arg | sed 's/[-a-zA-Z0-9]*=//'`
;;
--remove=*)
REMOVE_MODULE=`echo $arg | sed 's/[-a-zA-Z0-9]*=//'`
;;
--disable-mistnet)
ENABLE_MISTNET=no
;;
--download-mistnet-nexrad)
DOWNLOAD_MISTNET_NEXRAD=yes
;;
--history)
print_module_status "$BUILDDIR"
exit 0
;;
--help)
print_usage $0
exit 0
;;
install)
DO_INSTALL=yes
;;
clean)
DO_CLEAN=yes
;;
distclean)
DO_DISTCLEAN=yes
;;
*)
;;
esac
done
if [ "$REMOVE_MODULE" != "" ]; then
MODULES=`echo $REMOVE_MODULE | tr ',' ' '`
for m in $MODULES; do
remove_built_module "$BUILDDIR" $m
done
fi
if [ "$DO_DISTCLEAN" = "yes" ]; then
do_distclean
fi
if [ "$DO_CLEAN" = "yes" ]; then
do_clean
fi
if [ "$DO_INSTALL" = "yes" ]; then
do_install "$PREFIX" "$ENABLE_MISTNET"
if [ "$DOWNLOAD_MISTNET_NEXRAD" = "yes" ]; then
mkdir -p "$PREFIX/etc"
if [ ! -f "$PREFIX/etc/mistnet_nexrad.pt" ]; then
wget http://mistnet.s3.amazonaws.com/mistnet_nexrad.pt -O "$PREFIX/etc/mistnet_nexrad.pt"
fi
fi
fi