memgraph/tests/qa/init

64 lines
1.5 KiB
Plaintext
Raw Normal View History

2017-06-20 21:01:11 +08:00
#!/bin/bash
function print_usage_and_exit {
echo "./init [-s]"
2017-06-20 21:01:11 +08:00
echo -e "Prepare the environment for Memgraph QA.\n"
echo "Optional arguments:"
echo -e " -s\tuse sudo apt-get for installing required packages"
exit 1
}
# read arguments
use_sudo=false
while [[ $# -gt 0 ]]; do
case $1 in
-s)
use_sudo=true
shift
;;
*)
# unknown option
print_usage_and_exit
;;
esac
done
# exit if any subcommand returns a non-zero status
set -e
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd ${script_dir}
required_pkgs=(python-virtualenv python3-pip) # required by 'run' script
2017-06-20 21:01:11 +08:00
# install all dependencies on debian based operating systems
required_missing=false
2017-06-20 21:01:11 +08:00
for pkg in ${required_pkgs[@]}; do
if dpkg -s $pkg 2>/dev/null >/dev/null; then
echo "Found $pkg"
elif [[ $use_sudo = true ]]; then
echo "Installing $pkg"
if [[ ! `sudo apt-get -y install $pkg` ]]; then
echo "Didn't install $pkg [required]"
required_missing=true
fi
else
echo "Missing $pkg [required]"
required_missing=true
fi
done
if [[ $required_missing = true ]]; then
echo "Missing required packages. EXITING!"
echo "Please, install required packages and rerun $0 again."
exit 2
fi
# setup ve
if [ ! -d "ve3" ]; then
virtualenv -p python3 ve3
fi
source ve3/bin/activate
pip3 install --upgrade pip
pip3 install -r requirements.txt