Compare commits
No commits in common. "master" and "0.1.1" have entirely different histories.
40
Makefile
40
Makefile
|
@ -1,5 +1,6 @@
|
||||||
NAME = netoik-api
|
NAME = netoik-api
|
||||||
VERSION = $(shell [ -d ".git" ] && git describe | sed "s/-/./g")
|
VERSION = $(shell [ -d ".git" ] && git describe | sed "s/-/./g")
|
||||||
|
BRANCH = $(shell [ -d ".git" ] && git branch --show-current)
|
||||||
|
|
||||||
SYSCONFDIR = $(shell rpm --eval "%{_sysconfdir}")
|
SYSCONFDIR = $(shell rpm --eval "%{_sysconfdir}")
|
||||||
UNITDIR = $(shell rpm --eval "%{_unitdir}")
|
UNITDIR = $(shell rpm --eval "%{_unitdir}")
|
||||||
|
@ -21,39 +22,12 @@ version:
|
||||||
tarball: $(HOME)/rpmbuild/SOURCES/$(NAME)-$(VERSION).tar.gz
|
tarball: $(HOME)/rpmbuild/SOURCES/$(NAME)-$(VERSION).tar.gz
|
||||||
|
|
||||||
$(HOME)/rpmbuild/SOURCES/$(NAME)-%.tar.gz: .
|
$(HOME)/rpmbuild/SOURCES/$(NAME)-%.tar.gz: .
|
||||||
git archive --format=tar.gz \
|
git archive --format=tar.gz --output=$@ --prefix=$(NAME)-$(VERSION)/ --worktree-attributes --verbose $(BRANCH)
|
||||||
--output=$@ \
|
|
||||||
--prefix=$(NAME)-$(VERSION)/ \
|
|
||||||
--worktree-attributes \
|
|
||||||
--verbose \
|
|
||||||
HEAD
|
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install:
|
install:
|
||||||
install -D \
|
install -D --no-target-directory server.conf.sample $(DESTDIR)$(SYSCONFDIR)/$(NAME)/server.conf
|
||||||
--no-target-directory \
|
install -D --target-directory=$(DESTDIR)$(SYSCONFDIR)/$(NAME) server.conf.sample
|
||||||
server.conf.sample \
|
install -D --target-directory=$(DESTDIR)$(UNITDIR) systemd/netoik-api-server.service
|
||||||
"$(DESTDIR)$(SYSCONFDIR)/$(NAME)/server.conf"
|
install -D --no-target-directory bin/server $(DESTDIR)$(BINDIR)/$(NAME)-server
|
||||||
install -D \
|
install --directory $(DESTDIR)$(VARDIR)/$(NAME)/captcha
|
||||||
--target-directory="$(DESTDIR)$(SYSCONFDIR)/$(NAME)" \
|
|
||||||
server.conf.sample
|
|
||||||
install -D \
|
|
||||||
--target-directory="$(DESTDIR)$(UNITDIR)" \
|
|
||||||
systemd/netoik-api-server.service
|
|
||||||
install -D \
|
|
||||||
--no-target-directory \
|
|
||||||
bin/server \
|
|
||||||
"$(DESTDIR)$(BINDIR)/$(NAME)-server"
|
|
||||||
install --directory "$(DESTDIR)$(VARDIR)/$(NAME)/captcha"
|
|
||||||
|
|
||||||
.PHONY: check_format
|
|
||||||
check_format:
|
|
||||||
gofmt -d -e cmd/ pkg/
|
|
||||||
|
|
||||||
.PHONY: check_linting
|
|
||||||
check_linting:
|
|
||||||
@echo "Not implemented!"
|
|
||||||
|
|
||||||
.PHONY: unit_test
|
|
||||||
unit_test:
|
|
||||||
@echo "Not implemented!"
|
|
||||||
|
|
|
@ -26,33 +26,25 @@ Netoik rest API server
|
||||||
%make_install
|
%make_install
|
||||||
|
|
||||||
%pre
|
%pre
|
||||||
# Create user only if not already exisiting.
|
useradd --no-create-home --system --user-group %{name}
|
||||||
id %{name} || useradd --no-create-home --shell=%{_sbindir}/nologin --user-group %{name}
|
|
||||||
|
|
||||||
%post
|
%post
|
||||||
# Reload systemctl daemon and (re)start service.
|
systemctl stop %{name}-server.service
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl restart %{name}-server.service
|
systemctl start %{name}-server.service
|
||||||
systemctl enable %{name}-server.service
|
|
||||||
|
|
||||||
%preun
|
%preun
|
||||||
# Stop service only if uninstalling.
|
systemctl stop %{name}-server.service
|
||||||
if [ $1 -eq 0 ]; then
|
|
||||||
systemctl disable --now %{name}-server.service
|
|
||||||
fi
|
|
||||||
|
|
||||||
%postun
|
%postun
|
||||||
# Reload systemctl daemon and remove netoik-api user only if uninstalling.
|
|
||||||
if [ $1 -eq 0 ]; then
|
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
userdel %{name}
|
userdel %{name}
|
||||||
fi
|
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%attr(755, root, root) %dir %{_var}/%{name}
|
%attr(755, root, root) %dir %{_var}/%{name}
|
||||||
%attr(755, %{name}, %{name}) %dir %{_var}/%{name}/captcha
|
%attr(755, %{name}, %{name}) %dir %{_var}/%{name}/captcha
|
||||||
%attr(755, root, root) %dir %{_sysconfdir}/%{name}
|
%attr(755, root, root) %dir %{_sysconfdir}/%{name}
|
||||||
%attr(644, root, root) %{_sysconfdir}/%{name}/server.conf.sample
|
%attr(644, root, root) %{_sysconfdir}/%{name}/server.conf.sample
|
||||||
%attr(640, root, %{name}) %config(noreplace) %{_sysconfdir}/%{name}/server.conf
|
%attr(644, root, root) %config(noreplace) %{_sysconfdir}/%{name}/server.conf
|
||||||
%attr(644, root, root) %{_unitdir}/%{name}-server.service
|
%attr(644, root, root) %{_unitdir}/%{name}-server.service
|
||||||
%attr(755, root, root) %{_bindir}/%{name}-server
|
%attr(755, root, root) %{_bindir}/%{name}-server
|
||||||
|
|
Loading…
Reference in New Issue