-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
56 lines (48 loc) · 1.55 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
#! /bin/bash
# TODO: extend the installation to other contexts
system_dependencies=("firefox" "python" "geckodriver")
venv_directory="$1"
if [[ "$venv_directory" ]]; then
if [[ ! -d "$venv_directory" ]]; then
echo "Invalid directory for the virtual environment"
exit 1
fi
else
venv_directory="."
fi
function detectOS(){
local os=""
if [[ "$OSTYPE" == "linux-gnu" ]]; then
os=$(cat /etc/os-release | grep -m 1 "NAME" | cut -f 2 -d '=' | tr -d '"')
else
echo "Unsupported OS, you'll have to do it manually :("
exit 1
fi
echo "$os"
}
function check_dependencies(){
local -a dependencies_to_install
for dependency in "$@"
do
if [[ $(pacman -Q "$dependency" | grep error) ]]; then
dependencies_to_install+=("$dependency")
fi
done
echo "${dependencies_to_install[@]}"
}
echo "Detecting OS..."
if [[ $(detectOS) == "Arch Linux" ]]; then
echo "Checking system dependencies..."
dependencies_to_install=$(check_dependencies "${system_dependencies[@]}")
if [[ ${dependencies_to_install[@]} ]]; then
echo "The following dependencies are missing: ${dependencies_to_install[@]}. Proceeding to install..."
sudo pacman -S ${dependencies_to_install[@]}
fi
echo "Creating virtual environment for python and installing the package dependencies..."
python -m venv "$venv_directory/.venv"
source "$venv_directory/.venv/bin/activate"
pip install .
echo "Done."
else
echo "Unsupported OS, you'll have to do it manually :("
fi