Add user creation in RPM

This commit is contained in:
Thomas Roehl 2022-03-03 13:43:43 +01:00
parent 60de21c41e
commit 948c34d74d
2 changed files with 8 additions and 12 deletions

View File

@ -7,6 +7,7 @@ License: MIT
Source0: %{name}-%{version}.tar.gz Source0: %{name}-%{version}.tar.gz
BuildRequires: go-toolset BuildRequires: go-toolset
BuildRequires: systemd-rpm-macros
# for internal LIKWID installation # for internal LIKWID installation
BuildRequires: wget perl-Data-Dumper BuildRequires: wget perl-Data-Dumper
@ -34,17 +35,14 @@ install -Dpm 0600 receivers.json %{buildroot}%{_sysconfdir}/%{name}/receivers.js
install -Dpm 0600 router.json %{buildroot}%{_sysconfdir}/%{name}/router.json install -Dpm 0600 router.json %{buildroot}%{_sysconfdir}/%{name}/router.json
install -Dpm 0644 scripts/%{name}.service %{buildroot}%{_unitdir}/%{name}.service install -Dpm 0644 scripts/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
install -Dpm 0600 scripts/%{name}.config %{buildroot}%{_sysconfdir}/default/%{name} install -Dpm 0600 scripts/%{name}.config %{buildroot}%{_sysconfdir}/default/%{name}
install -Dpm 0644 scripts/%{name}.sysusers %{buildroot}%{_sysusersdir}/%{name}.conf
%check %check
# go test should be here... :) # go test should be here... :)
%pre %pre
getent group clustercockpit >/dev/null || groupadd -r clustercockpit %sysusers_create_compat scripts/%{name}.sysusers
getent passwd clustercockpit >/dev/null || \
useradd -r -g clustercockpit -d /nonexistent -s /sbin/nologin \
-c "Create system user and group for CC metric collector" clustercockpit
exit 0
%post %post
%systemd_post %{name}.service %systemd_post %{name}.service
@ -52,13 +50,6 @@ exit 0
%preun %preun
%systemd_preun %{name}.service %systemd_preun %{name}.service
%postun
if [ "$1" = "1" ]; then
getent passwd clustercockpit >/dev/null && userdel clustercockpit
getent group clustercockpit >/dev/null && groupdel clustercockpit
fi
exit 0
%files %files
%dir %{_sysconfdir}/%{name} %dir %{_sysconfdir}/%{name}
%{_sbindir}/%{name} %{_sbindir}/%{name}
@ -69,8 +60,11 @@ exit 0
%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/%{name}/sinks.json %attr(0600,root,root) %config(noreplace) %{_sysconfdir}/%{name}/sinks.json
%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/%{name}/receivers.json %attr(0600,root,root) %config(noreplace) %{_sysconfdir}/%{name}/receivers.json
%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/%{name}/router.json %attr(0600,root,root) %config(noreplace) %{_sysconfdir}/%{name}/router.json
%{_sysusersdir}/%{name}.conf
%changelog %changelog
* Thu Mar 03 2022 Thomas Gruber - 0.3
- Add clustercockpit user installation
* Mon Feb 14 2022 Thomas Gruber - 0.2 * Mon Feb 14 2022 Thomas Gruber - 0.2
- Add component specific configuration files - Add component specific configuration files
- Add %attr to config files - Add %attr to config files

View File

@ -0,0 +1,2 @@
#Type Name ID GECOS Home directory Shell
s hpcop - "User for ClusterCockpit" /run/cc-metric-collector /sbin/nologin