-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
68 lines (58 loc) · 2.59 KB
/
Copy pathMakefile
File metadata and controls
68 lines (58 loc) · 2.59 KB
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
.PHONY: build test clean build-gostats build-goppstats build-dashgen \
install install-systemd uninstall
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
SYSCONFDIR ?= /etc
CONFDIR = $(SYSCONFDIR)/powerscale-data-insights
SYSTEMDDIR ?= /etc/systemd/system
build: build-gostats build-goppstats build-dashgen
build-gostats:
go build -o bin/gostats ./cmd/gostats/
build-goppstats:
go build -o bin/goppstats ./cmd/goppstats/
build-dashgen:
go build -o bin/dashgen ./cmd/dashgen/
test:
go test -v ./cmd/gostats/...
go test -v ./cmd/goppstats/...
clean:
rm -rf bin/
# Install binaries and example configs.
# Actual configs (gostats.toml, goppstats.toml) are only written if they do
# not already exist, so repeated installs do not overwrite a running config.
install: build
install -d $(DESTDIR)$(BINDIR)
install -m 755 bin/gostats bin/goppstats bin/dashgen $(DESTDIR)$(BINDIR)/
install -d $(DESTDIR)$(CONFDIR)
install -m 644 configs/gostats.example.toml $(DESTDIR)$(CONFDIR)/gostats.example.toml
install -m 644 configs/goppstats.example.toml $(DESTDIR)$(CONFDIR)/goppstats.example.toml
@if [ ! -f $(DESTDIR)$(CONFDIR)/gostats.toml ]; then \
install -m 640 configs/gostats.example.toml $(DESTDIR)$(CONFDIR)/gostats.toml; \
echo "Installed starter config: $(DESTDIR)$(CONFDIR)/gostats.toml — edit before use"; \
else \
echo "$(DESTDIR)$(CONFDIR)/gostats.toml exists, skipping"; \
fi
@if [ ! -f $(DESTDIR)$(CONFDIR)/goppstats.toml ]; then \
install -m 640 configs/goppstats.example.toml $(DESTDIR)$(CONFDIR)/goppstats.toml; \
echo "Installed starter config: $(DESTDIR)$(CONFDIR)/goppstats.toml — edit before use"; \
else \
echo "$(DESTDIR)$(CONFDIR)/goppstats.toml exists, skipping"; \
fi
# Install systemd service files. Run 'sudo systemctl daemon-reload' afterwards.
# The service files assume binaries in /usr/local/bin and configs in
# /etc/powerscale-data-insights; edit them if you used a different PREFIX.
install-systemd:
install -d $(DESTDIR)$(SYSTEMDDIR)
install -m 644 systemd/pdi-gostats.service $(DESTDIR)$(SYSTEMDDIR)/pdi-gostats.service
install -m 644 systemd/pdi-goppstats.service $(DESTDIR)$(SYSTEMDDIR)/pdi-goppstats.service
@echo ""
@echo "Service files installed. To activate:"
@echo " sudo systemctl daemon-reload"
@echo " sudo useradd -r -s /usr/sbin/nologin pdi"
@echo " sudo mkdir -p /var/log/powerscale-data-insights"
@echo " sudo chown pdi:pdi /var/log/powerscale-data-insights"
@echo " sudo systemctl enable --now pdi-gostats pdi-goppstats"
uninstall:
rm -f $(DESTDIR)$(BINDIR)/gostats
rm -f $(DESTDIR)$(BINDIR)/goppstats
rm -f $(DESTDIR)$(BINDIR)/dashgen