#!/usr/bin/env bash

SUDO='';
if (( $EUID != 0 )); then
	SUDO='sudo';
fi;
if hash mongo &>/dev/null; then
	echo -e "\e[92mMongoDB jest zainstalowane\e[39m";
else
	echo -e "\e[93mMongoDB niezainstalowane. Instalowanie...\e[39m"
	$SUDO wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | $SUDO apt-key add - &&
	echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | $SUDO tee /etc/apt/sources.list.d/mongodb-org-4.2.list &&
	$SUDO apt-get update &&
	$SUDO apt-get install -y mongodb-org;
	$SUDO service mongod start;
fi;
if hash pip3 &>/dev/null; then;
else
	echo -e "\e[93mpip3 niezainstalowane. Instalowanie...\e[39m" &&
	$SUDO apt-get install python3-pip;
fi;
libffi="$(whereis libffi)"
if [ "$libffi" = "libffi:" ]; then
	echo -e "\e[93mlibffi niezainstalowane. Instalowanie...\e[39m" &&
	$SUDO apt-get install build-essential libffi-dev &&
	$SUDO apt-get install python3-cffi;
fi;
