Compare commits
12 Commits
Author | SHA1 | Date |
---|---|---|
|
0c6c4e4ad9 | |
|
8f3bab75ce | |
|
47a0ca0ec4 | |
|
e52ab0e19a | |
|
51367fea5c | |
|
5ff10a2b86 | |
|
139c6beab6 | |
|
084ac3bb9e | |
|
82c6f7af2a | |
|
a17d9372bc | |
|
8fb7ce644c | |
|
4fe9fb445f |
43
Makefile
43
Makefile
|
@ -1,6 +1,5 @@
|
|||
NAME = netoik-api
|
||||
VERSION = $(shell [ -d ".git" ] && git describe | sed "s/-/./g")
|
||||
BRANCH = $(shell [ -d ".git" ] && git branch --show-current)
|
||||
|
||||
SYSCONFDIR = $(shell rpm --eval "%{_sysconfdir}")
|
||||
UNITDIR = $(shell rpm --eval "%{_unitdir}")
|
||||
|
@ -22,15 +21,39 @@ version:
|
|||
tarball: $(HOME)/rpmbuild/SOURCES/$(NAME)-$(VERSION).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
|
||||
install:
|
||||
mkdir --parents $(DESTDIR)$(VARDIR)/$(NAME)/captcha
|
||||
mkdir --parents $(DESTDIR)$(SYSCONFDIR)/$(NAME)
|
||||
install server.conf.sample $(DESTDIR)$(SYSCONFDIR)/$(NAME)/server.conf.sample
|
||||
install server.conf.sample $(DESTDIR)$(SYSCONFDIR)/$(NAME)/server.conf
|
||||
mkdir --parents $(DESTDIR)$(UNITDIR)
|
||||
install systemd/netoik-api-server.service $(DESTDIR)$(UNITDIR)/netoik-api-server.service
|
||||
mkdir --parents $(DESTDIR)$(BINDIR)
|
||||
install bin/server $(DESTDIR)$(BINDIR)/$(NAME)-server
|
||||
install -D \
|
||||
--no-target-directory \
|
||||
server.conf.sample \
|
||||
"$(DESTDIR)$(SYSCONFDIR)/$(NAME)/server.conf"
|
||||
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!"
|
||||
|
|
|
@ -26,25 +26,33 @@ Netoik rest API server
|
|||
%make_install
|
||||
|
||||
%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
|
||||
systemctl stop %{name}-server.service
|
||||
# Reload systemctl daemon and (re)start service.
|
||||
systemctl daemon-reload
|
||||
systemctl start %{name}-server.service
|
||||
systemctl restart %{name}-server.service
|
||||
systemctl enable %{name}-server.service
|
||||
|
||||
%preun
|
||||
systemctl stop %{name}-server.service
|
||||
# Stop service only if uninstalling.
|
||||
if [ $1 -eq 0 ]; then
|
||||
systemctl disable --now %{name}-server.service
|
||||
fi
|
||||
|
||||
%postun
|
||||
systemctl daemon-reload
|
||||
userdel %{name}
|
||||
# Reload systemctl daemon and remove netoik-api user only if uninstalling.
|
||||
if [ $1 -eq 0 ]; then
|
||||
systemctl daemon-reload
|
||||
userdel %{name}
|
||||
fi
|
||||
|
||||
%files
|
||||
%attr(755, root, root) %dir %{_var}/%{name}
|
||||
%attr(755, %{name}, %{name}) %dir %{_var}/%{name}/captcha
|
||||
%attr(755, root, root) %dir %{_sysconfdir}/%{name}
|
||||
%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(755, root, root) %{_bindir}/%{name}-server
|
||||
|
|
Loading…
Reference in New Issue