From b467e59458b1a3ef7fa0a7de1bb592b95a515556 Mon Sep 17 00:00:00 2001 From: Adam Malinowski Date: Mon, 23 Jun 2014 19:03:54 +0200 Subject: [PATCH] Fix user adding & deleting during installing and uninstalling process Verification: Build cynara and install it on "fresh" image which contains already installed cynara rush edition. Cynara service should start during installation without any warnings nor errors. run "systemctl status cynara.service" to check if cynara service works. Change-Id: I1c98165230277b7ae11d5157c2abd9712067f85f --- packaging/cynara.spec | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/packaging/cynara.spec b/packaging/cynara.spec index 8f33300..36d1f73 100644 --- a/packaging/cynara.spec +++ b/packaging/cynara.spec @@ -14,6 +14,9 @@ BuildRequires: pkgconfig(libsystemd-daemon) BuildRequires: pkgconfig(libsystemd-journal) %{?systemd_requires} +%global user_name %{name} +%global group_name %{name} + %global build_type %{?build_type:%build_type}%{!?build_type:RELEASE} %if %{?build_type} == "DEBUG" @@ -24,7 +27,6 @@ BuildRequires: binutils-devel %endif - %description service and client libraries (libcynara-client, libcynara-admin) @@ -71,7 +73,6 @@ Requires: cynara = %{version}-%{release} %description -n cynara-devel service (devel version) - %prep %setup -q cp -a %{SOURCE1001} . @@ -102,27 +103,23 @@ ln -s ../cynara.socket %{buildroot}/usr/lib/systemd/system/sockets.target.wants/ ln -s ../cynara-admin.socket %{buildroot}/usr/lib/systemd/system/sockets.target.wants/cynara-admin.socket %post -USER=%{name} -GROUP=%{name} - ### Add file capabilities if needed ### setcap/getcap binary are useful. To use them you must install libcap and libcap-tools packages ### In such case uncomment Requires with those packages systemctl daemon-reload -if [ $1 = 1 ]; then - - id -g $GROUP 2> /dev/null - if [ $? -eq 1 ]; then - groupadd $GROUP - fi +id -g %{group_name} > /dev/null 2>&1 +if [ $? -eq 1 ]; then + groupadd %{group_name} -r > /dev/null 2>&1 +fi - id -u $USER 2> /dev/null - if [ $? -eq 1 ]; then - useradd -m $USER - fi +id -u %{user_name} > /dev/null 2>&1 +if [ $? -eq 1 ]; then + useradd -m %{user_name} -r > /dev/null 2>&1 +fi +if [ $1 = 1 ]; then systemctl enable %{name}.service fi @@ -137,11 +134,9 @@ if [ $1 = 0 ]; then fi %postun -USER=%{name} -GROUP=%{name} if [ $1 = 0 ]; then - userdel -r $USER 2> /dev/null - groupdel $GROUP 2> /dev/null + userdel -r %{user_name} > /dev/null 2>&1 + groupdel %{user_name} > /dev/null 2>&1 systemctl daemon-reload fi -- 2.7.4