-
Notifications
You must be signed in to change notification settings - Fork 20
/
makefile
133 lines (102 loc) · 4.62 KB
/
makefile
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
ENVPATH := vachan-ENV
ACTIVATE_VENV := . $(ENVPATH)/bin/activate &&
SHELL := /bin/bash
.PHONY: pre-requistite venv-configure venv-activate install-dependencies check-package into-database environmental-variables installing-usfmgrammar installing-docker kratosconfig
pre-requisite: #basic python packages to run the makefile
@if ! dpkg -s python3-pip &> /dev/null; then \
echo "python3-pip is not installed. Installing..."; \
sudo apt install -y python3-pip; \
else \
echo "python3-pip is already installed."; \
fi
@if ! dpkg -s python3-venv &> /dev/null; then \
echo "python3-venv is not installed. Installing..."; \
sudo apt install -y python3-venv; \
else \
echo "python3-venv is already installed."; \
fi
venv-configure: ## Configure virtual environment and install dependencies
@echo ">>> Configure virtual environment..."
python3 -m venv $(ENVPATH)
@echo ">>> Virtual environment configured..."
venv-activate: ## Activate virtual-env
@echo ">>> Virtual environment activation..."
@echo $$(source $(ENVPATH)/bin/activate && python -c "import sys; print(sys.prefix)")
install-dependencies: ## Install dependencies from requirements
@echo ">>> Installing dependencies..."
@$(ACTIVATE_VENV) pip install -r requirements.txt
check-package: ## Check if packages from requirements.txt are installed
@echo ">>> Checking packages..."
@$(ACTIVATE_VENV) pip install -r requirements.txt --upgrade --quiet && \
if [ $$? -eq 0 ]; then \
echo "All packages are installed."; \
else \
echo "Some packages are missing or failed to install."; \
fi
installing-psql:
@if psql --version | grep -q "15.3"; then \
echo "You already have psql 15.3 installed."; \
else \
read -p "You currently have a different version of psql installed. Do you want to proceed with installing psql 15.3? (y/N) " response; \
if [[ $$response =~ ^[Yy]$$ ]]; then \
echo "Installing psql 15.3..."; \
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $$(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'; \
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null; \
sudo apt update; \
sudo apt remove postgresql postgresql-contrib; \
sudo apt install postgresql-15 postgresql-contrib-15; \
else \
echo "Aborted installation."; \
fi; \
fi
into-database: ## Accessing the database folder
sudo -u postgres psql -tc "SELECT 1 FROM pg_database WHERE datname='vachan_db'" | grep -q 1 || sudo -u postgres psql -c "CREATE DATABASE vachan_db"
cd db && sudo -u postgres psql vachan_db < seed_DB.sql
environmental-variables:
chmod +x setup.sh
./setup.sh
installing-usfmgrammar:
sudo apt install npm
sudo npm install -g [email protected]
installing-docker:
@if docker --version | grep -q "Docker version 24.0."; then \
echo "You already have Docker 24.0.1 or above installed."; \
else \
read -p "Do you want to install/update to the latest Docker version? (y/N) " response; \
if [[ $$response =~ ^[Yy]$$ ]]; then \
if docker --version | grep -q "Docker version"; then \
echo "Removing existing Docker installation..."; \
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $$pkg; done; \
fi; \
echo "Installing the latest version of Docker..."; \
sudo apt-get update; \
sudo apt-get install -y ca-certificates curl gnupg; \
sudo install -m 0755 -d /etc/apt/keyrings; \
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg; \
sudo chmod a+r /etc/apt/keyrings/docker.gpg; \
echo "deb [arch=$$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu bionic stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null; \
sudo apt-get update --allow-releaseinfo-change; \
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin; \
if [[ $$? -eq 0 ]]; then \
echo "Docker has been installed/updated to the latest version."; \
else \
echo "Docker installation/update failed. Refer to the Docker installation documentation for manual installation: https://docs.docker.com/engine/install/debian/"; \
fi \
else \
echo "Docker installation/update canceled."; \
fi \
fi
kratosconfig:
cd docker/Kratos_config && docker compose -f quickstart.yml up
setup:
make pre-requisite
make venv-configure
make venv-activate
make install-dependencies
make check-package
make installing-psql
make into-database
make environmental-variables
make installing-usfmgrammar
make installing-docker
make kratosconfig