Commit fde5ee01 authored by Joan Vallvé Navarro's avatar Joan Vallvé Navarro
Browse files

script with options to allow single command call

parent f641de3f
Pipeline #8477 canceled with stages
#!/bin/bash
## FUNCTIONS
## FUNCTIONS #####################################################
func_make_install () {
if [ "$UID" -eq 0 -o "$EUID" -eq 0 ]; then
make install
......@@ -10,24 +10,118 @@ func_make_install () {
}
func_echo () {
if [ $VERBOSE == "true" ]; then
echo "$1"
fi
if [ $VERBOSE == "true" ]; then
echo "$1"
fi
}
usage() {
echo "Usage: $0 [-v] [-a] [-d <string>] [-w <string>] [-p <string>] [-f <y/n>] [-c <y/n>]"
echo " v: disables echo"
echo " a: installs all plugins (incompatible with -p)"
echo " d: dependencies destination path (either /global/path or relative/path). If not set, will be asked later."
echo " w: wolf folder destination path (either /global/path or relative/path). If not set, will be asked later."
echo " p: plugins to be installed (incompatible with -a) being a string of 6 chars y/n corresponding to plugins imu, gnss, laser, vision, apriltag, bodydynamics (for example 'ynynnn'). Plugins apriltag and bodydynamics won't be installed if vision and imu plugins are installed, respectively."
echo " f: y/n install Falko optional dependency. If not set, will be asked later."
echo " c: y/n install CSM optional dependency. If not set, will be asked later."
}
func_check_yn () {
if [ "$1" != "y" ] && [ "$1" != "n" ]; then
echo "options -p, -f, -c should containing only 'y' or 'n'"
usage
exit 0
fi
}
# verbose
## OPTIONS #####################################################
VERBOSE="true"
while getopts "he" option; do
case $option in
e) # disable verbose
INSTALL_PLUGINS=""
INSTALL_IMU="undefined"
INSTALL_GNSS="undefined"
INSTALL_LASER="undefined"
INSTALL_VISION="undefined"
INSTALL_APRILTAG="undefined"
INSTALL_BODYDYNAMICS="undefined"
INSTALL_FALKO="undefined"
INSTALL_CSM="undefined"
DEPS_PATH="undefined"
WOLF_PATH="undefined"
while getopts "vap:d:w:hf:c:" opt; do
case ${opt} in
v) # disable verbose
VERBOSE="false"
;;
a) # install all plugins
if [ "$INSTALL_PLUGINS" != "" ]; then
echo "options -p and -a are incompatible!"
usage
exit 0
fi
INSTALL_PLUGINS="a"
INSTALL_IMU="y"
INSTALL_GNSS="y"
INSTALL_LASER="y"
INSTALL_VISION="y"
INSTALL_APRILTAG="y"
INSTALL_BODYDYNAMICS="y"
;;
p) # install all plugins
if [ "$INSTALL_PLUGINS" != "" ]; then
echo "options -p and -a are incompatible!"
usage
exit 0
fi
if [ ${#OPTARG} != 6 ]; then
echo "option -p should contain 6 characters"
usage
exit 0
fi
INSTALL_PLUGINS=$OPTARG
INSTALL_IMU=${INSTALL_PLUGINS:0:1}
INSTALL_GNSS=${INSTALL_PLUGINS:1:1}
INSTALL_LASER=${INSTALL_PLUGINS:2:1}
INSTALL_VISION=${INSTALL_PLUGINS:3:1}
INSTALL_APRILTAG=${INSTALL_PLUGINS:4:1}
INSTALL_BODYDYNAMICS=${INSTALL_PLUGINS:5:1}
func_check_yn $INSTALL_IMU
func_check_yn $INSTALL_GNSS
func_check_yn $INSTALL_LASER
func_check_yn $INSTALL_VISION
func_check_yn $INSTALL_APRILTAG
func_check_yn $INSTALL_BODYDYNAMICS
;;
f) # install falko
INSTALL_FALKO=$OPTARG
func_check_yn $INSTALL_FALKO
c) # install csm
INSTALL_CSM=$OPTARG
func_check_yn $INSTALL_CSM
d) # deps path
DEPS_PATH=$OPTARG
w) # wolf path
WOLF_PATH=$OPTARG
;;
h )
usage
exit 0
;;
:)
echo "Error: -${OPTARG} requires an argument."
usage
exit 1
;;
*)
usage
exit 1
;;
esac
done
# START #####################################################
CORES=$(nproc)
func_echo "The number of available cores on this machine is $CORES"
RUN_PATH=$PWD
# UBUNTU
......@@ -51,8 +145,10 @@ fi
# WOLF DEPENDENCIES #####################################################
func_echo "You are in folder $PWD"
echo "Enter path for dependencies (either /global/path or relative/path):"
read DEPS_PATH
if [ $DEPS_PATH == "undefined" ]; then
echo "Enter path for dependencies (either /global/path or relative/path):"
read DEPS_PATH
fi
cd $DEPS_PATH
DEPS_PATH=$PWD
func_echo "path dependencies: $DEPS_PATH"
......@@ -112,13 +208,15 @@ func_make_install
# WOLF #####################################################
cd $RUN_PATH
func_echo "You are in folder $PWD"
echo "Enter path for wolf folder (either /global/path or relative/path):"
read WOLF_PATH
if [ $WOLF_PATH == "undefined" ]; then
echo "Enter path for wolf folder (either /global/path or relative/path):"
read WOLF_PATH
fi
cd $WOLF_PATH
mkdir wolf
cd wolf
WOLF_PATH=$PWD
func_echo "wolf folder path: $PWD/wolf"
func_echo "wolf folder path: $WOLF_PATH"
# CORE -----------------------------------------------------
......@@ -141,8 +239,10 @@ ctest -j$CORES
# IMU --------------------------------------------------
echo "Do you want to download and install plugin imu? (y/n)"
read INSTALL_IMU
if [ $INSTALL_IMU == "undefined" ]; then
echo "Do you want to download and install plugin imu? (y/n)"
read INSTALL_IMU
fi
if [ $INSTALL_IMU == "y" ]; then
func_echo "Cloning plugin imu..."
......@@ -166,8 +266,10 @@ else
fi
# GNSS --------------------------------------------------
echo "Do you want to download and install plugin gnss? (y/n)"
read INSTALL_GNSS
if [ $INSTALL_GNSS == "undefined" ]; then
echo "Do you want to download and install plugin gnss? (y/n)"
read INSTALL_GNSS
fi
if [ $INSTALL_GNSS == "y" ]; then
func_echo "Installing plugin gnss dependencies..."
......@@ -203,15 +305,19 @@ fi
# LASER --------------------------------------------------
echo "Do you want to download and install plugin laser? (y/n)"
read INSTALL_LASER
if [ $INSTALL_LASER == "undefined" ]; then
echo "Do you want to download and install plugin laser? (y/n)"
read INSTALL_LASER
fi
if [ $INSTALL_LASER == "y" ]; then
func_echo "Installing plugin laser dependencies..."
# CSM
echo "Do you want to install CSM to enable ICP processors? (y/n)"
read INSTALL_CSM
if [ $INSTALL_CSM == "undefined" ]; then
echo "Do you want to install CSM to enable ICP processors? (y/n)"
read INSTALL_CSM
fi
if [ $INSTALL_CSM == "y" ]; then
cd $DEPS_PATH
git clone https://gitlab.iri.upc.edu/labrobotica/algorithms/csm.git
......@@ -225,8 +331,10 @@ if [ $INSTALL_LASER == "y" ]; then
fi
# FALKO
echo "Do you want to install FALKO to enable Falko loop closure processors? (y/n)"
read INSTALL_FALKO
if [ $INSTALL_FALKO == "undefined" ]; then
echo "Do you want to install FALKO to enable Falko loop closure processors? (y/n)"
read INSTALL_FALKO
fi
if [ $INSTALL_FALKO == "y" ]; then
cd $DEPS_PATH
git clone https://gitlab.iri.upc.edu/labrobotica/algorithms/falkolib.git
......@@ -275,8 +383,10 @@ else
fi
# VISION --------------------------------------------------
echo "Do you want to download and install plugin vision (requires to install opencv 3.3.0)? (y/n)"
read INSTALL_VISION
if [ $INSTALL_VISION == "undefined" ]; then
echo "Do you want to download and install plugin vision (requires to install opencv 3.3.0)? (y/n)"
read INSTALL_VISION
fi
if [ $INSTALL_VISION == "y" ]; then
func_echo "Installing plugin vision dependencies..."
......@@ -319,8 +429,10 @@ fi
# APRILTAG --------------------------------------------------
if [ $INSTALL_VISION == "y" ]; then
echo "Do you want to download and install plugin apriltag? (y/n)"
read INSTALL_APRILTAG
if [ $INSTALL_APRILTAG == "undefined" ]; then
echo "Do you want to download and install plugin apriltag? (y/n)"
read INSTALL_APRILTAG
fi
if [ $INSTALL_APRILTAG == "y" ]; then
func_echo "Installing plugin apriltag dependencies..."
......@@ -358,9 +470,11 @@ fi
# BODYDYNAMICS --------------------------------------------------
if [ $INSTALL_IMU == "y" ]; then
echo "Do you want to download and install plugin bodydynamics? (y/n)"
read INSTALL_BD
if [ $INSTALL_BD == "y" ]; then
if [ $INSTALL_BODYDYNAMICS == "undefined" ]; then
echo "Do you want to download and install plugin bodydynamics? (y/n)"
read INSTALL_BODYDYNAMICS
fi
if [ $INSTALL_BODYDYNAMICS == "y" ]; then
func_echo "Cloning plugin bodydynamics..."
cd $WOLF_PATH
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment