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