From cfe68fcca5eeed28417663f7d3beba36ebf703cc Mon Sep 17 00:00:00 2001 From: Alexey Avramov Date: Tue, 23 Jul 2019 22:58:13 +0900 Subject: [PATCH] fix Makefile --- Makefile | 32 +++++++++++++++++------------ nohang.service => nohang.service.in | 2 +- 2 files changed, 20 insertions(+), 14 deletions(-) rename nohang.service => nohang.service.in (80%) diff --git a/Makefile b/Makefile index e02816b..807ad0c 100644 --- a/Makefile +++ b/Makefile @@ -1,43 +1,48 @@ DESTDIR ?= BINDIR ?= /usr/local/bin -SYSTEMDUNITDIR ?= /etc/systemd/system CONFDIR ?= /etc MANDIR ?= /usr/share/man/man1 LOGDIR ?= /var/log +SYSTEMDUNITDIR ?= /etc/systemd/system all: @ echo "Use: make install, make systemd, make uninstall" install: install -d $(DESTDIR)$(BINDIR) - install -m0755 ./nohang $(DESTDIR)$(BINDIR)/nohang - install -m0755 ./nohang_notify_helper $(DESTDIR)$(BINDIR)/nohang_notify_helper - install -m0755 ./oom-sort $(DESTDIR)$(BINDIR)/oom-sort - install -m0755 ./psi-top $(DESTDIR)$(BINDIR)/psi-top - install -m0755 ./psi-monitor $(DESTDIR)$(BINDIR)/psi-monitor + + install -m0755 nohang $(DESTDIR)$(BINDIR)/nohang + install -m0755 nohang_notify_helper $(DESTDIR)$(BINDIR)/nohang_notify_helper + install -m0755 oom-sort $(DESTDIR)$(BINDIR)/oom-sort + install -m0755 psi-top $(DESTDIR)$(BINDIR)/psi-top + install -m0755 psi-monitor $(DESTDIR)$(BINDIR)/psi-monitor install -d $(DESTDIR)$(CONFDIR)/nohang - -git describe --tags --long --dirty > ./version - -install -m0644 ./version $(DESTDIR)$(CONFDIR)/nohang/version - -rm -fvr ./version + -git describe --tags --long --dirty > version + -install -m0644 version $(DESTDIR)$(CONFDIR)/nohang/version + -rm -fv version - install -m0644 ./nohang.conf $(DESTDIR)$(CONFDIR)/nohang/nohang.conf - install -m0644 ./nohang.conf $(DESTDIR)$(CONFDIR)/nohang/nohang.conf.default + install -m0644 nohang.conf $(DESTDIR)$(CONFDIR)/nohang/nohang.conf + install -m0644 nohang.conf $(DESTDIR)$(CONFDIR)/nohang/nohang.conf.default install -d $(DESTDIR)$(CONFDIR)/logrotate.d - install -m0644 ./nohang.logrotate $(DESTDIR)$(CONFDIR)/logrotate.d/nohang + install -m0644 nohang.logrotate $(DESTDIR)$(CONFDIR)/logrotate.d/nohang install -d $(DESTDIR)$(MANDIR) gzip -c nohang.1 > $(DESTDIR)$(MANDIR)/nohang.1.gz gzip -c oom-sort.1 > $(DESTDIR)$(MANDIR)/oom-sort.1.gz -install -d $(DESTDIR)$(SYSTEMDUNITDIR) - -install -m0644 ./nohang.service $(DESTDIR)$(SYSTEMDUNITDIR)/nohang.service + -sed "s|:TARGET_BIN:|$(DESTDIR)$(BINDIR)|g;s|:TARGET_CONF:|$(DESTDIR)$(CONFDIR)|g" nohang.service.in > nohang.service + -install -m0644 nohang.service $(DESTDIR)$(SYSTEMDUNITDIR)/nohang.service + -rm -fv nohang.service -chcon -t systemd_unit_file_t $(DESTDIR)$(SYSTEMDUNITDIR)/nohang.service uninstall: # 'make uninstall' must not fail with error if systemctl is unavailable or returns error + -systemctl stop nohang.service || true -systemctl disable nohang.service || true + -systemctl daemon-reload rm -fv $(DESTDIR)$(BINDIR)/nohang rm -fv $(DESTDIR)$(BINDIR)/nohang_notify_helper rm -fv $(DESTDIR)$(BINDIR)/oom-sort @@ -54,3 +59,4 @@ systemd: -systemctl daemon-reload -systemctl enable nohang.service -systemctl restart nohang + -systemctl status nohang diff --git a/nohang.service b/nohang.service.in similarity index 80% rename from nohang.service rename to nohang.service.in index 3b3a3bd..479000e 100644 --- a/nohang.service +++ b/nohang.service.in @@ -3,7 +3,7 @@ Description=Highly configurable OOM prevention daemon Documentation=man:nohang(1) https://github.com/hakavlad/nohang [Service] -ExecStart=/usr/local/bin/nohang --config /etc/nohang/nohang.conf +ExecStart=:TARGET_BIN:/nohang --config :TARGET_CONF:/nohang/nohang.conf Slice=nohang.slice Restart=always KillMode=mixed