forked from powsybl/powsybl-metrix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·66 lines (57 loc) · 1.38 KB
/
install.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
#!/bin/bash
CURDIR=$(cd `dirname $0` && pwd)
set -e
function clean_exit(){
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ] ; then
echo "Installation failed with exit code $EXIT_CODE."
fi
}
trap clean_exit EXIT
echo "Choose install directory ($HOME/.local/opt/powsybl-metrix) :"
read INSTALL_DIR
if [ -z "$INSTALL_DIR" ] ; then
INSTALL_DIR=$HOME/.local/opt/powsybl-metrix
fi
echo $INSTALL_DIR
echo "Choose install type (full / metrix) :"
read INSTALL_TYPE
if [ -z "$INSTALL_TYPE" ] ; then
INSTALL_TYPE="full"
fi
if [ $INSTALL_TYPE != "full" -a $INSTALL_TYPE != "metrix" ] ; then
echo "Allowed value for install type is metrix or full"
exit 1
fi
echo $INSTALL_TYPE
echo "Preparing install directory"
mkdir -p $INSTALL_DIR
echo "Installing metrix"
pushd $CURDIR/metrix-simulator
mkdir -p build
mkdir -p build/external
cd build/external
cmake ../../external
cmake --build .
cd ..
cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR ..
cmake --build . --target install
popd
if [ "$INSTALL_TYPE" == "full" ] ; then
echo "Installing powsybl-metrix"
pushd $CURDIR
mvn clean package
popd
fi
echo "Add to PATH ? (y/n)"
read ADD_TO_PATH
if [ "$ADD_TO_PATH" == "y" ] ; then
PATH_EXPORT="export PATH=$PATH:$INSTALL_DIR/bin"
cat $HOME/.bashrc | grep "$PATH_EXPORT"
if [ $? -ne 0 ] ; then
echo $PATH_EXPORT >> $HOME/.bashrc
else
echo "Already in PATH"
fi
fi
echo "Installation sucessful"