7f4c2a
From 7c15202eaf63ad33d59bc40f23f77f071560e846 Mon Sep 17 00:00:00 2001
7f4c2a
From: Niels de Vos <ndevos@redhat.com>
7f4c2a
Date: Wed, 22 Apr 2015 15:39:59 +0200
7f4c2a
Subject: [PATCH 61/73] spec: fix/add pre-transaction scripts for geo-rep and cli packages
7f4c2a
7f4c2a
The cli subpackage never had a %pretrans script, this has been added
7f4c2a
now.
7f4c2a
7f4c2a
The %pretrans script for ge-repliaction was never included in the RPM
7f4c2a
package because it was disable by a undefined macro (_can_georeplicate).
7f4c2a
This macro is not used/set anywhere else and _without_georeplication
7f4c2a
should take care of it anyway.
7f4c2a
7f4c2a
Note: This is a Red Hat Gluster Storage specific patch. Upstream
7f4c2a
      packaging guidelines do not allow these kind of 'features'.
7f4c2a
7f4c2a
Label: DOWNSTREAM ONLY
7f4c2a
7f4c2a
BUG: 1211839
7f4c2a
Change-Id: I16aab5bba72f1ed178f3bcac47f9d8ef767cfcef
7f4c2a
Signed-off-by: Niels de Vos <ndevos@redhat.com>
7f4c2a
Signed-off-by: Bala.FA <barumuga@redhat.com>
7f4c2a
Reviewed-on: https://code.engineering.redhat.com/gerrit/50491
7f4c2a
---
7f4c2a
 glusterfs.spec.in |   43 +++++++++++++++++++++++++++++++++++++++++--
7f4c2a
 1 files changed, 41 insertions(+), 2 deletions(-)
7f4c2a
7f4c2a
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
7f4c2a
index 3fcc00e..4b02f85 100644
7f4c2a
--- a/glusterfs.spec.in
7f4c2a
+++ b/glusterfs.spec.in
7f4c2a
@@ -1455,6 +1455,47 @@ end
7f4c2a
 
7f4c2a
 
7f4c2a
 
7f4c2a
+%pretrans cli -p <lua>
7f4c2a
+if not posix.access("/bin/bash", "x") then
7f4c2a
+    -- initial installation, no shell, no running glusterfsd
7f4c2a
+    return 0
7f4c2a
+end
7f4c2a
+
7f4c2a
+-- TODO: move this completely to a lua script
7f4c2a
+-- For now, we write a temporary bash script and execute that.
7f4c2a
+
7f4c2a
+script = [[#!/bin/sh
7f4c2a
+pidof -c -o %PPID -x glusterfsd &>/dev/null
7f4c2a
+
7f4c2a
+if [ $? -eq 0 ]; then
7f4c2a
+   pushd . > /dev/null 2>&1
7f4c2a
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
7f4c2a
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
7f4c2a
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
7f4c2a
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
7f4c2a
+          exit 1;
7f4c2a
+       fi
7f4c2a
+   done
7f4c2a
+
7f4c2a
+   popd > /dev/null 2>&1
7f4c2a
+   exit 1;
7f4c2a
+fi
7f4c2a
+]]
7f4c2a
+
7f4c2a
+-- rpm in RHEL5 does not have os.tmpname()
7f4c2a
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
7f4c2a
+tmpname = "/tmp/glusterfs-cli_pretrans_" .. os.date("%s")
7f4c2a
+tmpfile = io.open(tmpname, "w")
7f4c2a
+tmpfile:write(script)
7f4c2a
+tmpfile:close()
7f4c2a
+ok, how, val = os.execute("/bin/bash " .. tmpname)
7f4c2a
+os.remove(tmpname)
7f4c2a
+if not (ok == 0) then
7f4c2a
+   error("Detected running glusterfs processes", ok)
7f4c2a
+end
7f4c2a
+
7f4c2a
+
7f4c2a
+
7f4c2a
 %pretrans devel -p <lua>
7f4c2a
 if not posix.access("/bin/bash", "x") then
7f4c2a
     -- initial installation, no shell, no running glusterfsd
7f4c2a
@@ -1537,7 +1578,6 @@ end
7f4c2a
 
7f4c2a
 
7f4c2a
 
7f4c2a
-%if 0%{?_can_georeplicate}
7f4c2a
 %if ( 0%{!?_without_georeplication:1} )
7f4c2a
 %pretrans geo-replication -p <lua>
7f4c2a
 if not posix.access("/bin/bash", "x") then
7f4c2a
@@ -1578,7 +1618,6 @@ if not (ok == 0) then
7f4c2a
    error("Detected running glusterfs processes", ok)
7f4c2a
 end
7f4c2a
 %endif
7f4c2a
-%endif
7f4c2a
 
7f4c2a
 
7f4c2a
 
7f4c2a
-- 
7f4c2a
1.7.1
7f4c2a