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
BuildRequires: go-toolset
BuildRequires: systemd-rpm-macros
# for internal LIKWID installation
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 0644 scripts/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
install -Dpm 0600 scripts/%{name}.config %{buildroot}%{_sysconfdir}/default/%{name}
install -Dpm 0644 scripts/%{name}.sysusers %{buildroot}%{_sysusersdir}/%{name}.conf
%check
# go test should be here... :)
%pre
getent group clustercockpit >/dev/null || groupadd -r clustercockpit
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
%sysusers_create_compat scripts/%{name}.sysusers
%post
%systemd_post %{name}.service
@ -52,13 +50,6 @@ exit 0
%preun
%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
%dir %{_sysconfdir}/%{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}/receivers.json
%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/%{name}/router.json
%{_sysusersdir}/%{name}.conf
%changelog
* Thu Mar 03 2022 Thomas Gruber - 0.3
- Add clustercockpit user installation
* Mon Feb 14 2022 Thomas Gruber - 0.2
- Add component specific configuration 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