Skip to content

Commit 664d761

Browse files
committed
Added missing files for deb package
Declarative sysusers setup in rpm package Minor fixes to rpm and deb service unit files
1 parent e127760 commit 664d761

File tree

7 files changed

+61
-18
lines changed

7 files changed

+61
-18
lines changed

.gitignore

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,8 @@ tapir-cli
2929
dnstapir-cli
3030
version.go
3131

32-
# Ignore rpm build directory and related stuff
33-
*.tar.gz
34-
*.src.rpm
35-
#rpm/
36-
#!rpm/SOURCES/tapir-renew.service
37-
#!rpm/SOURCES/tapir-renew.timer
38-
#!rpm/SOURCES/tapir-cli.yaml
39-
#!rpm/SPECS/tapir-cli.spec
40-
41-
# Ignore deb build directory and related stuff
42-
*.deb
43-
deb/
44-
!deb/DEBIAN/control.in
45-
!deb/DEBIAN/postinst
46-
!deb/DEBIAN/postrm
47-
4832
# Ignore built stuff
4933
out/
34+
*.tar.gz
35+
*.rpm
36+
*.deb

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,14 @@ srpm: tarball
5757
test -z "$(outdir)" || cp $(OUT)/$(PROG)-$(RPM_VERSION)-*.src.rpm "$(outdir)"
5858

5959
rpm: srpm
60-
rpmbuild --recompile --define "%_topdir $(OUT)/rpm" --undefine=dist $(OUT)/$(PROG)-$(RPM_VERSION)-*.src.rpm
60+
rpmbuild --rebuild --define "%_topdir $(OUT)/rpm" --undefine=dist $(OUT)/$(PROG)-$(RPM_VERSION)-*.rpm
61+
cp $(OUT)/rpm/RPMS/**/$(PROG)-$(RPM_VERSION)-*.rpm $(OUT)
62+
test -z "$(outdir)" || cp $(OUT)/$(PROG)-$(RPM_VERSION)-*.rpm "$(outdir)"
6163

6264
deb: build
6365
cp -r deb $(OUT)
6466
mkdir -p $(OUT)/deb/usr/bin
6567
mkdir -p $(OUT)/deb/etc/dnstapir/certs
66-
mkdir -p $(OUT)/deb/usr/lib/systemd/system
6768
cp $(OUT)/$(PROG) $(OUT)/deb/usr/bin
6869
sed -e "s/@@VERSION@@/$(DEB_VERSION)/g" $(OUT)/deb/DEBIAN/control.in > $(OUT)/deb/DEBIAN/control
6970
dpkg-deb -b $(OUT)/deb/ $(OUT)/$(PROG)-$(DEB_VERSION).deb

deb/DEBIAN/postrm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -e
3+
4+
case "$1" in
5+
remove)
6+
;;
7+
purge)
8+
rm -rf /etc/dnstapir/
9+
;;
10+
esac
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Unit]
2+
Description=DNS TAPIR Edge Certificate Renewal
3+
After=network-online.target
4+
5+
[Service]
6+
Type=oneshot
7+
User=dnstapir-renew
8+
Group=dnstapir
9+
ExecStart=/usr/bin/dnstapir-cli --standalone renew \
10+
--renew-datakey /etc/dnstapir/certs/datakey-priv.json \
11+
--renew-cacert-out /etc/dnstapir/certs/ca.crt \
12+
--renew-clientkey /etc/dnstapir/certs/tls.key \
13+
--renew-clientcert-out /etc/dnstapir/certs/tls.crt
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Unit]
2+
Description=Renew DNS TAPIR mTLS certificate every week
3+
ConditionPathExists=/etc/dnstapir/certs/datakey-priv.json
4+
ConditionPathExists=/etc/dnstapir/certs/ca.crt
5+
ConditionPathExists=/etc/dnstapir/certs/tls.key
6+
ConditionPathExists=/etc/dnstapir/certs/tls.crt
7+
8+
[Timer]
9+
OnCalendar=weekly
10+
AccuracySec=1h
11+
RandomizedDelaySec=100min
12+
13+
[Install]
14+
WantedBy=timers.target
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#Type Name ID GECOS Home directory Shell
2+
u dnstapir-renew - "DNS TAPIR Edge Certificate Renewal" /etc/dnstapir -
3+
g dnstapir -

rpm/SPECS/dnstapir-cli.spec.in

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Disable building of debug packages
22
%global debug_package %{nil}
33

4+
# Handle backwards compat for sysuser creation
5+
%if 0%{?fedora} < 42 || (0%{?rhel} && 0%{?rhel} <= 10) || (0%{?mageia} && 0%{?mageia} < 10) || (0%{?suse_version} && 0%{?suse_version} < 1660)
6+
%bcond_without sysusers_compat
7+
%else
8+
%bcond_with sysusers_compat
9+
%endif
10+
411
Name: dnstapir-cli
512
Version: @@VERSION@@
613
Release: 1%{?dist}
@@ -11,6 +18,7 @@ URL: https://www.github.com/dnstapir/cli
1118
Source0: %{name}.tar.gz
1219
Source1: dnstapir-renew.service
1320
Source2: dnstapir-renew.timer
21+
Source3: dnstapir-renew.sysusers.conf
1422
BuildRequires: git
1523
BuildRequires: golang
1624

@@ -35,17 +43,24 @@ DESTDIR=%{buildroot}%{_bindir} make install
3543
install -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}
3644
install -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}
3745

46+
# Users and Groups
47+
install -m 0644 -D %{SOURCE3} %{buildroot}%{_sysusersdir}/dnstapir-renew.conf
48+
49+
3850
%files
3951
%attr(0770,root,dnstapir) %dir %{_sysconfdir}/dnstapir
4052
%attr(0770,root,dnstapir) %dir %{_sysconfdir}/dnstapir/certs
4153
%attr(0770,root,dnstapir) %{_bindir}/%{name}
4254
%attr(0660,-,dnstapir) %ghost %{_sysconfdir}/dnstapir/dnstapir-cli.yaml
4355
%attr(0644,root,dnstapir) %{_unitdir}/dnstapir-renew.service
4456
%attr(0644,root,dnstapir) %{_unitdir}/dnstapir-renew.timer
57+
%{_sysusersdir}/dnstapir-renew.conf
4558

59+
%if %{with sysusers_compat}
4660
%pre
4761
/usr/bin/getent group dnstapir || /usr/sbin/groupadd -r dnstapir
4862
/usr/bin/getent passwd dnstapir-renew || /usr/sbin/useradd -r -d /etc/dnstapir -G dnstapir -s /sbin/nologin dnstapir-renew
63+
%endif
4964

5065
%post
5166

0 commit comments

Comments
 (0)