-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathmakefile
64 lines (51 loc) · 2.07 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
SHELL:=/bin/bash
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
.PHONY: all fresh dependencies install fulluninstall uninstall removedeps
all: dependencies
fresh: fulluninstall dependencies
fulluninstall: uninstall cleancode
install:
# Create link in /usr/local/bin to screeps stats program.
ln -s -f $(ROOT_DIR)/bin/screepsstats.sh /usr/local/bin/screepsstats
# Create link in /usr/local/bin to standalone service controller.
ln -s -f $(ROOT_DIR)/bin/screepsstatsctl.sh /usr/local/bin/screepsstatsctl
# Create screepsstats user- including home directory- for daemon
id -u screepsstats &>/dev/null || useradd screepsstats --create-home --shell /bin/false -U
# Move service file into place- note that symlinks will not work (bug 955379)
if [ -d /etc/systemd/system ]; then \
cp $(ROOT_DIR)/provisioning/etc/systemd/system/screepsstats.service /etc/systemd/system/screepsstats.service; \
systemctl enable screepsstats.service; \
systemctl start screepsstats.service; \
fi;
dependencies:
if [ ! -d $(ROOT_DIR)/env ]; then virtualenv $(ROOT_DIR)/env; fi
source $(ROOT_DIR)/env/bin/activate; yes w | pip install -r $(ROOT_DIR)/requirements.txt
uninstall:
# Remove user and home.
if getent passwd screepsstats > /dev/null 2>&1; then \
pkill -9 -u `id -u screepsstats`; \
deluser --remove-home screepsstats; \
fi
# Remove screepsstats link in /user/local/bin
if [ -L /usr/local/bin/screepsstats.sh ]; then \
rm /usr/local/bin/screepsstats; \
fi;
# Remove screepsstatsctl in /user/local/bin
if [ -L /usr/local/bin/screepsstatsctl.sh ]; then \
rm /usr/local/bin/screepsstatsctl; \
fi;
# Shut down, disbale, and remove all services.
if [ -L /etc/systemd/system/screepsstats.service ]; then \
systemctl disable screepsstats.service; \
systemctl stop screepsstats.service; \
rm /etc/systemd/system/screepsstats.service; \
fi;
cleancode:
# Remove existing environment
if [ -d $(ROOT_DIR)/env ]; then \
rm -rf $(ROOT_DIR)/env; \
fi;
# Remove compiled python files
if [ -d $(ROOT_DIR)/screep_etl ]; then \
rm -f $(ROOT_DIR)/screep_etl/*.pyc; \
fi;