Create synapse user and group declaratively

This commit is contained in:
Kai A. Hiller 2022-01-21 19:55:06 +01:00
parent 6132902215
commit 49740b547f
2 changed files with 6 additions and 5 deletions

View file

@ -14,6 +14,7 @@ URL: https://github.com/matrix-org/%{srcname}
Source0: %{url}/archive/v%{version}%{rcx}/%{srcname}-%{version}%{rcx}.tar.gz
Source1: synapse.sysconfig
Source2: synapse.service
Source3: matrix-synapse.sysusers
# non-upstreamable patch to accept any version of python-cryptography, see RHBZ#1978949
Patch1: 0001-relax-cryptography-dependency-version-requirement.patch
BuildArch: noarch
@ -103,6 +104,7 @@ install -p -D -T -m 0644 contrib/systemd/log_config.yaml %{buildroot}%{_sysconfd
install -p -D -T -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/sysconfig/synapse
install -p -D -T -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/synapse.service
install -p -d -m 755 %{buildroot}/%{_sharedstatedir}/synapse
install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_sysusersdir}/%{name}.conf
%check
@ -110,11 +112,7 @@ PYTHONPATH=. trial-3 tests
%pre
getent group synapse >/dev/null || groupadd -r synapse
getent passwd synapse >/dev/null || \
useradd -r -g synapse -d %{_sharedstatedir}/synapse -s /sbin/nologin \
-c "The user for the Synapse Matrix server" synapse
exit 0
%sysusers_create_compat %{SOURCE3}
%post
%systemd_post synapse.service
@ -137,6 +135,7 @@ exit 0
%attr(755,synapse,synapse) %dir %{_sharedstatedir}/synapse
%attr(755,synapse,synapse) %dir %{_sysconfdir}/synapse
%attr(644,synapse,synapse) %config(noreplace) %{_sysconfdir}/synapse/*
%{_sysusersdir}/%{name}.conf
%changelog

2
matrix-synapse.sysusers Normal file
View file

@ -0,0 +1,2 @@
#Type Name ID GECOS Home directory Shell
u synapse - "Runs the Synapse Matrix homeserver" /run/synapse /sbin/nologin