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