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