diff --git a/davmail-user.conf b/davmail-user.conf new file mode 100644 index 00000000..087a4c46 --- /dev/null +++ b/davmail-user.conf @@ -0,0 +1,3 @@ +#Type Name ID GECOS Home directory Shell +g davmail - +u davmail - "davmail" /var/lib/davmail - diff --git a/davmail.changes b/davmail.changes index 1e723d4f..35304043 100644 --- a/davmail.changes +++ b/davmail.changes @@ -1,3 +1,7 @@ +------------------------------------------------------------------- +Thu May 23 2024 Tristan Miller + - Change to using systemd-sysusers + ------------------------------------------------------------------- Sat Mar 30 2024 Mickael Guessant - update to 6.2.2 diff --git a/davmail.spec b/davmail.spec index 6371bf1c..0fe350bc 100644 --- a/davmail.spec +++ b/davmail.spec @@ -50,10 +50,16 @@ BuildRequires: openjfx Requires: coreutils Requires: filesystem -Requires(pre): /usr/sbin/useradd, /usr/sbin/groupadd Requires(post): coreutils, filesystem -Requires(preun): /sbin/service, coreutils, /usr/sbin/userdel, /usr/sbin/groupdel Requires(postun): /sbin/service +%if %systemd_macros +Requires(preun): /sbin/service, coreutils +BuildRequires: sysuser-tools +%sysusers_requires +%else +Requires(preun): /sbin/service, coreutils, /usr/sbin/userdel, /usr/sbin/groupdel +Requires(pre): /usr/sbin/useradd, /usr/sbin/groupadd +%endif %{?fedora:Requires: java} %if 0%{?el7} || 0%{?el8} @@ -69,6 +75,7 @@ Requires: eclipse-swt %endif Source0: %{name}-src-%{version}.tgz +Source1: %{name}-user.conf %description A POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange gateway allowing @@ -104,6 +111,10 @@ rm lib/swt* # we have java 8 ant -Dant.java.version=1.8 prepare-dist +%if %systemd_macros +%sysusers_generate_pre %{SOURCE1} davmail %{name}-user.conf +%endif + %install rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT%{_bindir} @@ -145,12 +156,20 @@ mkdir -p $RPM_BUILD_ROOT%{_datadir}/metainfo install -m 0644 src/appstream/org.davmail.DavMail.appdata.xml $RPM_BUILD_ROOT%{_datadir}/metainfo %endif -%pre +%if %systemd_macros +mkdir -p %{buildroot}%{_sysusersdir} +install -m 0644 %{SOURCE1} %{buildroot}%{_sysusersdir}/ +%else /usr/sbin/groupadd -f -r davmail > /dev/null 2>&1 || : /usr/sbin/useradd -r -s /sbin/nologin -d /var/lib/davmail -M \ -g davmail davmail > /dev/null 2>&1 || : +%endif + %if %systemd_macros +%pre -f davmail.pre %service_add_pre davmail.service +%else +%pre %endif %post @@ -226,6 +245,9 @@ fi %files %defattr (-,root,root,-) %{_bindir}/* +%if %systemd_macros +%{_sysusersdir}/%{name}-user.conf +%endif %if %systemd_support %{_unitdir}/davmail.service