-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
73 lines (62 loc) · 2.02 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
pwd := $(shell pwd)
python=python3
pip=pip3
venv_path=venv
build_path=$(pwd)/installer/files
#
# Not available in arch based distros
# systemd_path=/usr/local/lib/systemd/system
systemd_path=/etc/systemd/system
inbound_state=$(shell systemctl is-active swob_inbound.service)
outbound_state=$(shell systemctl is-active swob_outbound.service)
gen_configs:
@cp -nv .configs/example.config.ini .configs/config.ini
@echo "[*] Copied config files..."
@mkdir -p $(build_path)
@echo "[*] Created dependencies build path $(build_path)"
@$(python) installer/generate.py
@echo "[*] Generated service files"
enable:
@sudo systemctl enable swob_inbound.service
@echo "+ Starting gateway service..."
@sudo systemctl enable swob_outbound.service
@echo "+ Starting cluster service..."
start:
@sudo systemctl start swob_inbound.service
@echo "+ Starting gateway service..."
@sudo systemctl start swob_outbound.service
@echo "+ Starting cluster service..."
init_systemd:
@sudo ln -s $(build_path)/*.service $(systemd_path)/
@sudo systemctl daemon-reload
@echo "[*] Copied service files to $(systemd_path)"
install:requirements.txt init_systemd
@$(python) -m venv $(venv_path)
@( \
. $(venv_path)/bin/activate; \
$(pip) install -r requirements.txt \
)
@echo "[*] Installation completed successfully"
remove:
@echo "Stopping services..."
@if [ "$(inbound_state)" = "active" ]; then \
echo "- gateway"; \
sudo systemctl kill swob_inbound.service; \
fi
@if [ "$(outbound_state)" = "active" ]; then \
echo "- cluster"; \
sudo systemctl kill swob_outbound.service; \
fi
@echo "Disabling services..."
@if [ "$(systemctl is-enabled swob_inbound.service)" = "enabled" ]; then \
sudo systemctl disable swob_inbound.service; \
fi
@if [ "$(systemctl is-enabled swob_outbound.service)" = "enabled" ]; then \
sudo systemctl disable swob_outbound.service; \
fi
@sudo rm -fv $(systemd_path)/swob_*.service
@rm -rfv $(build_path)
@sudo systemctl daemon-reload
@echo "complete"
fuckit:remove
@echo "Alright developer, have a go at it!"