Compare commits

...

10 Commits

2 changed files with 48 additions and 14 deletions

View File

@ -1,6 +1,5 @@
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}")
@ -22,12 +21,39 @@ 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 --output=$@ --prefix=$(NAME)-$(VERSION)/ --worktree-attributes --verbose $(BRANCH) git archive --format=tar.gz \
--output=$@ \
--prefix=$(NAME)-$(VERSION)/ \
--worktree-attributes \
--verbose \
HEAD
.PHONY: install .PHONY: install
install: install:
install -D --no-target-directory server.conf.sample $(DESTDIR)$(SYSCONFDIR)/$(NAME)/server.conf install -D \
install -D --target-directory=$(DESTDIR)$(SYSCONFDIR)/$(NAME) server.conf.sample --no-target-directory \
install -D --target-directory=$(DESTDIR)$(UNITDIR) systemd/netoik-api-server.service server.conf.sample \
install -D --no-target-directory bin/server $(DESTDIR)$(BINDIR)/$(NAME)-server "$(DESTDIR)$(SYSCONFDIR)/$(NAME)/server.conf"
install --directory $(DESTDIR)$(VARDIR)/$(NAME)/captcha install -D \
--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!"

View File

@ -26,25 +26,33 @@ Netoik rest API server
%make_install %make_install
%pre %pre
useradd --no-create-home --system --user-group %{name} # Create user only if not already exisiting.
id %{name} || useradd --no-create-home --shell=%{_sbindir}/nologin --user-group %{name}
%post %post
systemctl stop %{name}-server.service # Reload systemctl daemon and (re)start service.
systemctl daemon-reload systemctl daemon-reload
systemctl start %{name}-server.service systemctl restart %{name}-server.service
systemctl enable %{name}-server.service
%preun %preun
systemctl stop %{name}-server.service # Stop service only if uninstalling.
if [ $1 -eq 0 ]; then
systemctl disable --now %{name}-server.service
fi
%postun %postun
systemctl daemon-reload # Reload systemctl daemon and remove netoik-api user only if uninstalling.
userdel %{name} if [ $1 -eq 0 ]; then
systemctl daemon-reload
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(644, root, root) %config(noreplace) %{_sysconfdir}/%{name}/server.conf %attr(640, root, %{name}) %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