e7a346
From 280eddebd49483343cc08b42c12f26d89f6d51e1 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
e7a346
Subject: [PATCH 12/74] 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
e7a346
index 458b8bc..68eba56 100644
e7a346
--- a/glusterfs.spec.in
e7a346
+++ b/glusterfs.spec.in
e7a346
@@ -1668,6 +1668,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
e7a346
@@ -1750,7 +1791,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
e7a346
@@ -1791,7 +1831,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