From 24e65ec0cbcbb27f257b2641c57145a01ddb45df9765e1b76c9feb688fc8af88 Mon Sep 17 00:00:00 2001 From: Jan Fajerski Date: Wed, 7 Mar 2018 12:18:37 +0000 Subject: [PATCH] Accepting request 583872 from home:jfajerski:branches:server:monitoring OBS-URL: https://build.opensuse.org/request/show/583872 OBS-URL: https://build.opensuse.org/package/show/server:monitoring/grafana?expand=0&rev=2 --- grafana.spec | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/grafana.spec b/grafana.spec index 53d9f67..9b85b4d 100644 --- a/grafana.spec +++ b/grafana.spec @@ -18,6 +18,7 @@ %define GRAFANA_USER %{name} %define GRAFANA_GROUP %{name} +%define GRAFANA_HOME %{_datadir}/%{name} Name: grafana Version: 5.0.0 @@ -108,17 +109,10 @@ ln -s %{_bindir}/phantomjs %{buildroot}%{_datadir}/%{name}/tools/phantomjs/phant %pre %service_add_pre %{name}-server.service -if [ $1 -eq 1 ]; then -if ! %{_bindir}/id %{GRAFANA_USER} &>/dev/null; then -echo -n "Create a new group %{GRAFANA_GROUP}:" -%{_sbindir}/groupadd -r %{GRAFANA_GROUP} ||: -echo "... done" -echo -n "Create a new user %{GRAFANA_USER}:" -%{_sbindir}/useradd -r -g %{GRAFANA_GROUP} -d %{_datadir}/%{name} \ --s /sbin/nologin -c "%{GRAFANA_USER} user" %{GRAFANA_GROUP} -echo "... done"; -fi -fi +echo "Creating user %{GRAFANA_USER} and group %{GRAFANA_GROUP} if not present" +getent group %{GRAFANA_GROUP} > /dev/null || groupadd -r %{GRAFANA_GROUP} +getent passwd %{GRAFANA_GROUP} > /dev/null || useradd -r -g %{GRAFANA_GROUP} \ +-d %{GRAFANA_HOME} -s /sbin/nologin -c "%{GRAFANA_USER} user" %{GRAFANA_GROUP} %post %{fillup_only -n %{name}-server} @@ -129,11 +123,6 @@ fi %postun %service_del_postun %{name}-server.service -if [ $1 -eq 0 ]; then -userdel %{GRAFANA_USER} || logger "User \"%{GRAFANA_USER}\" could not be deleted." -groupdel %{GRAFANA_GROUP} || logger "Group \"%{GRAFANA_GROUP}\" could not be deleted." -rm -rf %{_localstatedir}/lib/%{name} -rm -rf %{_localstatedir}/log/%{name}; fi %files %defattr(-,root,root)