MT#55283 el: use rpm macros to create users, tmpfiles

Change-Id: I291830712ded006eca6e7b1bb8fc65e78dd70098
pull/2101/head
Sergey Safarov 8 months ago committed by Richard Fuchs
parent 8b55ce8958
commit bbcabbf534

@ -0,0 +1,2 @@
x /run/rtpengine-recording/rtpengine-recording.pid
d /run/rtpengine-recording 0700 ngcp-rtpengine ngcp-rtpengine 7d

@ -37,6 +37,8 @@ BuildRequires: glib2-devel libcurl-devel openssl-devel
BuildRequires: pcre2-devel BuildRequires: pcre2-devel
BuildRequires: zlib-devel hiredis-devel BuildRequires: zlib-devel hiredis-devel
BuildRequires: systemd-devel BuildRequires: systemd-devel
BuildRequires: systemd-rpm-macros
BuildRequires: libnftnl-devel
BuildRequires: libpcap-devel libevent-devel json-glib-devel BuildRequires: libpcap-devel libevent-devel json-glib-devel
BuildRequires: mosquitto-devel BuildRequires: mosquitto-devel
BuildRequires: gperf perl-IPC-Cmd BuildRequires: gperf perl-IPC-Cmd
@ -168,9 +170,15 @@ RTPENGINE_VERSION="\"%{version}-%{release}\"" make DESTDIR=%{buildroot} with_tra
%endif %endif
## Install the init.d script and configuration file ## Install the init.d script and configuration file
install -D -p -m644 el/%{binname}.sysusers \
%{buildroot}%{_sysusersdir}/%{binname}.conf
install -D -p -m644 el/%{binname}.tmpfiles \
%{buildroot}%{_tmpfilesdir}/%{binname}.conf
install -D -p -m644 el/%{binname}.service \ install -D -p -m644 el/%{binname}.service \
%{buildroot}%{_unitdir}/%{binname}.service %{buildroot}%{_unitdir}/%{binname}.service
%if 0%{?with_transcoding} > 0 %if 0%{?with_transcoding} > 0
install -D -p -m644 el/%{binname}-recording.tmpfiles \
%{buildroot}%{_tmpfilesdir}/%{binname}-recording.conf
install -D -p -m644 el/%{binname}-recording.service \ install -D -p -m644 el/%{binname}-recording.service \
%{buildroot}%{_unitdir}/%{binname}-recording.service %{buildroot}%{_unitdir}/%{binname}-recording.service
%endif %endif
@ -215,16 +223,18 @@ install -m444 fixtures/* %{buildroot}%{_datarootdir}/%{binname}-perftest
%endif %endif
%pre %pre
getent group %{name} >/dev/null || /usr/sbin/groupadd -r %{name} %sysusers_create_package %{binname} el/%{binname}.sysusers
getent passwd %{name} >/dev/null || /usr/sbin/useradd -r -g %{name} \
-s /sbin/nologin -c "%{name} daemon" -d %{_sharedstatedir}/%{name} %{name}
%post %post
if [ $1 -eq 1 ]; then %tmpfiles_create %{binname}.conf
systemctl daemon-reload %systemd_post %{binname}.service
fi
%if 0%{?with_transcoding}
%post recording
%tmpfiles_create %{binname}-recording.conf
%systemd_post %{binname}-recording.service
%endif
%post dkms %post dkms
# Add to DKMS registry, build, and install module # Add to DKMS registry, build, and install module
@ -258,16 +268,25 @@ true
%preun %preun
if [ $1 = 0 ] ; then %systemd_preun %{binname}.service
systemctl stop %{binname}.service
systemctl disable %{binname}.service %if 0%{?with_transcoding}
fi %preun recording
%systemd_preun %{binname}-recording.service
%endif
%preun dkms %preun dkms
# Remove from DKMS registry # Remove from DKMS registry
dkms remove -m %{name} -v %{version}-%{release} --rpm_safe_upgrade --all dkms remove -m %{name} -v %{version}-%{release} --rpm_safe_upgrade --all
true true
%postun
%systemd_postun %{binname}.service
%if 0%{?with_transcoding}
%postun recording
%systemd_postun %{binname}-recording.service
%endif
%files %files
# Userspace daemon # Userspace daemon
@ -275,6 +294,10 @@ true
# CLI (command line interface) # CLI (command line interface)
%{_bindir}/%{binname}-ctl %{_bindir}/%{binname}-ctl
# CLI table helper # CLI table helper
%{_sysusersdir}/%{binname}.conf
# sysusers file for user creation
%{_tmpfilesdir}/%{binname}.conf
# tmpfiles
# init.d script and configuration file # init.d script and configuration file
%{_unitdir}/%{binname}.service %{_unitdir}/%{binname}.service
%config(noreplace) %{_sysconfdir}/sysconfig/%{binname} %config(noreplace) %{_sysconfdir}/sysconfig/%{binname}
@ -307,6 +330,8 @@ true
%files recording %files recording
# Recording daemon # Recording daemon
%{_bindir}/%{binname}-recording %{_bindir}/%{binname}-recording
# tmpfiles
%{_tmpfilesdir}/%{binname}-recording.conf
# Init script # Init script
%{_unitdir}/%{binname}-recording.service %{_unitdir}/%{binname}-recording.service
# Sysconfig # Sysconfig

@ -0,0 +1 @@
u ngcp-rtpengine - "RTPengine server" /var/lib/rtpengine

@ -0,0 +1,2 @@
x /run/rtpengine/rtpengine.pid
d /run/rtpengine 0700 ngcp-rtpengine ngcp-rtpengine 7d
Loading…
Cancel
Save