256ebe
From 7744475550cd27f58f536741e9c50c639d3b02d8 Mon Sep 17 00:00:00 2001
256ebe
From: "Bala.FA" <barumuga@redhat.com>
256ebe
Date: Thu, 6 Dec 2018 20:06:27 +0530
256ebe
Subject: [PATCH 07/52] build: add RHGS specific changes
256ebe
256ebe
Label: DOWNSTREAM ONLY
256ebe
256ebe
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1074947
256ebe
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1097782
256ebe
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1115267
256ebe
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1221743
256ebe
Change-Id: I08333334745adf2350e772c6454ffcfe9c08cb89
256ebe
Reviewed-on: https://code.engineering.redhat.com/gerrit/24983
256ebe
Reviewed-on: https://code.engineering.redhat.com/gerrit/25451
256ebe
Reviewed-on: https://code.engineering.redhat.com/gerrit/25518
256ebe
Reviewed-on: https://code.engineering.redhat.com/gerrit/25983
256ebe
Signed-off-by: Bala.FA <barumuga@redhat.com>
256ebe
Reviewed-on: https://code.engineering.redhat.com/gerrit/60134
256ebe
Tested-by: Milind Changire <mchangir@redhat.com>
256ebe
---
256ebe
 glusterfs.spec.in | 485 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
256ebe
 1 file changed, 481 insertions(+), 4 deletions(-)
256ebe
256ebe
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
256ebe
index 6be492e..eb04491 100644
256ebe
--- a/glusterfs.spec.in
256ebe
+++ b/glusterfs.spec.in
256ebe
@@ -95,9 +95,16 @@
256ebe
 %{?_without_server:%global _without_server --without-server}
256ebe
 
256ebe
 # disable server components forcefully as rhel <= 6
256ebe
-%if ( 0%{?rhel} && 0%{?rhel} <= 6 )
256ebe
+%if ( 0%{?rhel} )
256ebe
+%if ( "%{?dist}" == ".el6rhs" ) || ( "%{?dist}" == ".el7rhs" ) || ( "%{?dist}" == ".el7rhgs" )
256ebe
+%global _without_server %{nil}
256ebe
+%else
256ebe
 %global _without_server --without-server
256ebe
 %endif
256ebe
+%endif
256ebe
+
256ebe
+%global _without_extra_xlators 1
256ebe
+%global _without_regression_tests 1
256ebe
 
256ebe
 # syslog
256ebe
 # if you wish to build rpms without syslog logging, compile like this
256ebe
@@ -229,7 +236,8 @@ Release:          0.1%{?prereltag:.%{prereltag}}%{?dist}
256ebe
 %else
256ebe
 Name:             @PACKAGE_NAME@
256ebe
 Version:          @PACKAGE_VERSION@
256ebe
-Release:          0.@PACKAGE_RELEASE@%{?dist}
256ebe
+Release:          @PACKAGE_RELEASE@%{?dist}
256ebe
+ExcludeArch:      i686
256ebe
 %endif
256ebe
 License:          GPLv2 or LGPLv3+
256ebe
 URL:              http://docs.gluster.org/
256ebe
@@ -243,8 +251,6 @@ Source8:          glusterfsd.init
256ebe
 Source0:          @PACKAGE_NAME@-@PACKAGE_VERSION@.tar.gz
256ebe
 %endif
256ebe
 
256ebe
-BuildRoot:        %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
256ebe
-
256ebe
 Requires(pre):    shadow-utils
256ebe
 %if ( 0%{?_with_systemd:1} )
256ebe
 BuildRequires:    systemd
256ebe
@@ -384,7 +390,9 @@ This package provides cloudsync plugins for archival feature.
256ebe
 Summary:          Development Libraries
256ebe
 Requires:         %{name}%{?_isa} = %{version}-%{release}
256ebe
 # Needed for the Glupy examples to work
256ebe
+%if ( 0%{!?_without_extra_xlators:1} )
256ebe
 Requires:         %{name}-extra-xlators%{?_isa} = %{version}-%{release}
256ebe
+%endif
256ebe
 
256ebe
 %description devel
256ebe
 GlusterFS is a distributed file-system capable of scaling to several
256ebe
@@ -397,6 +405,7 @@ is in user space and easily manageable.
256ebe
 
256ebe
 This package provides the development libraries and include files.
256ebe
 
256ebe
+%if ( 0%{!?_without_extra_xlators:1} )
256ebe
 %package extra-xlators
256ebe
 Summary:          Extra Gluster filesystem Translators
256ebe
 # We need python-gluster rpm for gluster module's __init__.py in Python
256ebe
@@ -415,6 +424,7 @@ is in user space and easily manageable.
256ebe
 
256ebe
 This package provides extra filesystem Translators, such as Glupy,
256ebe
 for GlusterFS.
256ebe
+%endif
256ebe
 
256ebe
 %package fuse
256ebe
 Summary:          Fuse client
256ebe
@@ -440,6 +450,30 @@ is in user space and easily manageable.
256ebe
 This package provides support to FUSE based clients and inlcudes the
256ebe
 glusterfs(d) binary.
256ebe
 
256ebe
+%if ( 0%{!?_without_server:1} )
256ebe
+%package ganesha
256ebe
+Summary:          NFS-Ganesha configuration
256ebe
+Group:            Applications/File
256ebe
+
256ebe
+Requires:         %{name}-server%{?_isa} = %{version}-%{release}
256ebe
+Requires:         nfs-ganesha-gluster, pcs, dbus
256ebe
+%if ( 0%{?rhel} && 0%{?rhel} == 6 )
256ebe
+Requires:         cman, pacemaker, corosync
256ebe
+%endif
256ebe
+
256ebe
+%description ganesha
256ebe
+GlusterFS is a distributed file-system capable of scaling to several
256ebe
+petabytes. It aggregates various storage bricks over Infiniband RDMA
256ebe
+or TCP/IP interconnect into one large parallel network file
256ebe
+system. GlusterFS is one of the most sophisticated file systems in
256ebe
+terms of features and extensibility.  It borrows a powerful concept
256ebe
+called Translators from GNU Hurd kernel. Much of the code in GlusterFS
256ebe
+is in user space and easily manageable.
256ebe
+
256ebe
+This package provides the configuration and related files for using
256ebe
+NFS-Ganesha as the NFS server using GlusterFS
256ebe
+%endif
256ebe
+
256ebe
 %if ( 0%{!?_without_georeplication:1} )
256ebe
 %package geo-replication
256ebe
 Summary:          GlusterFS Geo-replication
256ebe
@@ -541,6 +575,7 @@ is in user space and easily manageable.
256ebe
 This package provides support to ib-verbs library.
256ebe
 %endif
256ebe
 
256ebe
+%if ( 0%{!?_without_regression_tests:1} )
256ebe
 %package regression-tests
256ebe
 Summary:          Development Tools
256ebe
 Requires:         %{name}%{?_isa} = %{version}-%{release}
256ebe
@@ -556,6 +591,7 @@ Requires:         nfs-utils xfsprogs yajl psmisc bc
256ebe
 %description regression-tests
256ebe
 The Gluster Test Framework, is a suite of scripts used for
256ebe
 regression testing of Gluster.
256ebe
+%endif
256ebe
 
256ebe
 %if ( 0%{!?_without_ocf:1} )
256ebe
 %package resource-agents
256ebe
@@ -1092,6 +1128,16 @@ exit 0
256ebe
 %if 0%{?_tmpfilesdir:1} && 0%{!?_without_server:1}
256ebe
 %{_tmpfilesdir}/gluster.conf
256ebe
 %endif
256ebe
+%if ( 0%{?_without_extra_xlators:1} )
256ebe
+%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/encryption/rot-13.so
256ebe
+%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/quiesce.so
256ebe
+%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/playground/template.so
256ebe
+%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/testing/performance/symlink-cache.so
256ebe
+%endif
256ebe
+%if ( 0%{?_without_regression_tests:1} )
256ebe
+%exclude %{_datadir}/glusterfs/run-tests.sh
256ebe
+%exclude %{_datadir}/glusterfs/tests
256ebe
+%endif
256ebe
 
256ebe
 %files api
256ebe
 %exclude %{_libdir}/*.so
256ebe
@@ -1134,12 +1180,14 @@ exit 0
256ebe
 %dir %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/protocol
256ebe
      %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/protocol/client.so
256ebe
 
256ebe
+%if ( 0%{!?_without_extra_xlators:1} )
256ebe
 %files extra-xlators
256ebe
 %dir %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator
256ebe
 %dir %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features
256ebe
      %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/quiesce.so
256ebe
 %dir %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/playground
256ebe
      %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/playground/template.so
256ebe
+%endif
256ebe
 
256ebe
 %files fuse
256ebe
 # glusterfs is a symlink to glusterfsd, -server depends on -fuse.
256ebe
@@ -1239,11 +1287,13 @@ exit 0
256ebe
      %{_libdir}/glusterfs/%{version}%{?prereltag}/rpc-transport/rdma*
256ebe
 %endif
256ebe
 
256ebe
+%if ( 0%{!?_without_regression_tests:1} )
256ebe
 %files regression-tests
256ebe
 %dir %{_datadir}/glusterfs
256ebe
      %{_datadir}/glusterfs/run-tests.sh
256ebe
      %{_datadir}/glusterfs/tests
256ebe
 %exclude %{_datadir}/glusterfs/tests/vagrant
256ebe
+%endif
256ebe
 
256ebe
 %if ( 0%{!?_without_ocf:1} )
256ebe
 %files resource-agents
256ebe
@@ -1424,6 +1474,433 @@ exit 0
256ebe
 %endif
256ebe
 %endif
256ebe
 
256ebe
+##-----------------------------------------------------------------------------
256ebe
+## All %pretrans should be placed here and keep them sorted
256ebe
+##
256ebe
+%if 0%{!?_without_server:1}
256ebe
+%pretrans -p <lua>
256ebe
+if not posix.access("/bin/bash", "x") then
256ebe
+    -- initial installation, no shell, no running glusterfsd
256ebe
+    return 0
256ebe
+end
256ebe
+
256ebe
+-- TODO: move this completely to a lua script
256ebe
+-- For now, we write a temporary bash script and execute that.
256ebe
+
256ebe
+script = [[#!/bin/sh
256ebe
+pidof -c -o %PPID -x glusterfsd &>/dev/null
256ebe
+
256ebe
+if [ $? -eq 0 ]; then
256ebe
+   pushd . > /dev/null 2>&1
256ebe
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
256ebe
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
256ebe
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
256ebe
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
256ebe
+          echo "ERROR: Distribute volumes detected. In-service rolling upgrade requires distribute volume(s) to be stopped."
256ebe
+          echo "ERROR: Please stop distribute volume(s) before proceeding... exiting!"
256ebe
+          exit 1;
256ebe
+       fi
256ebe
+   done
256ebe
+
256ebe
+   popd > /dev/null 2>&1
256ebe
+   echo "WARNING: Updating glusterfs requires its processes to be killed. This action does NOT incur downtime."
256ebe
+   echo "WARNING: Ensure to wait for the upgraded server to finish healing before proceeding."
256ebe
+   echo "WARNING: Refer upgrade section of install guide for more details"
256ebe
+   echo "Please run # service glusterd stop; pkill glusterfs; pkill glusterfsd; pkill gsyncd.py;"
256ebe
+   exit 1;
256ebe
+fi
256ebe
+]]
256ebe
+
256ebe
+-- rpm in RHEL5 does not have os.tmpname()
256ebe
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
256ebe
+tmpname = "/tmp/glusterfs_pretrans_" .. os.date("%s")
256ebe
+tmpfile = io.open(tmpname, "w")
256ebe
+tmpfile:write(script)
256ebe
+tmpfile:close()
256ebe
+ok, how, val = os.execute("/bin/bash " .. tmpname)
256ebe
+os.remove(tmpname)
256ebe
+if not (ok == 0) then
256ebe
+   error("Detected running glusterfs processes", ok)
256ebe
+end
256ebe
+
256ebe
+
256ebe
+
256ebe
+%pretrans api -p <lua>
256ebe
+if not posix.access("/bin/bash", "x") then
256ebe
+    -- initial installation, no shell, no running glusterfsd
256ebe
+    return 0
256ebe
+end
256ebe
+
256ebe
+-- TODO: move this completely to a lua script
256ebe
+-- For now, we write a temporary bash script and execute that.
256ebe
+
256ebe
+script = [[#!/bin/sh
256ebe
+pidof -c -o %PPID -x glusterfsd &>/dev/null
256ebe
+
256ebe
+if [ $? -eq 0 ]; then
256ebe
+   pushd . > /dev/null 2>&1
256ebe
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
256ebe
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
256ebe
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
256ebe
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
256ebe
+          exit 1;
256ebe
+       fi
256ebe
+   done
256ebe
+
256ebe
+   popd > /dev/null 2>&1
256ebe
+   exit 1;
256ebe
+fi
256ebe
+]]
256ebe
+
256ebe
+-- rpm in RHEL5 does not have os.tmpname()
256ebe
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
256ebe
+tmpname = "/tmp/glusterfs-api_pretrans_" .. os.date("%s")
256ebe
+tmpfile = io.open(tmpname, "w")
256ebe
+tmpfile:write(script)
256ebe
+tmpfile:close()
256ebe
+ok, how, val = os.execute("/bin/bash " .. tmpname)
256ebe
+os.remove(tmpname)
256ebe
+if not (ok == 0) then
256ebe
+   error("Detected running glusterfs processes", ok)
256ebe
+end
256ebe
+
256ebe
+
256ebe
+
256ebe
+%pretrans api-devel -p <lua>
256ebe
+if not posix.access("/bin/bash", "x") then
256ebe
+    -- initial installation, no shell, no running glusterfsd
256ebe
+    return 0
256ebe
+end
256ebe
+
256ebe
+-- TODO: move this completely to a lua script
256ebe
+-- For now, we write a temporary bash script and execute that.
256ebe
+
256ebe
+script = [[#!/bin/sh
256ebe
+pidof -c -o %PPID -x glusterfsd &>/dev/null
256ebe
+
256ebe
+if [ $? -eq 0 ]; then
256ebe
+   pushd . > /dev/null 2>&1
256ebe
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
256ebe
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
256ebe
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
256ebe
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
256ebe
+          exit 1;
256ebe
+       fi
256ebe
+   done
256ebe
+
256ebe
+   popd > /dev/null 2>&1
256ebe
+   exit 1;
256ebe
+fi
256ebe
+]]
256ebe
+
256ebe
+-- rpm in RHEL5 does not have os.tmpname()
256ebe
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
256ebe
+tmpname = "/tmp/glusterfs-api-devel_pretrans_" .. os.date("%s")
256ebe
+tmpfile = io.open(tmpname, "w")
256ebe
+tmpfile:write(script)
256ebe
+tmpfile:close()
256ebe
+ok, how, val = os.execute("/bin/bash " .. tmpname)
256ebe
+os.remove(tmpname)
256ebe
+if not (ok == 0) then
256ebe
+   error("Detected running glusterfs processes", ok)
256ebe
+end
256ebe
+
256ebe
+
256ebe
+
256ebe
+%pretrans devel -p <lua>
256ebe
+if not posix.access("/bin/bash", "x") then
256ebe
+    -- initial installation, no shell, no running glusterfsd
256ebe
+    return 0
256ebe
+end
256ebe
+
256ebe
+-- TODO: move this completely to a lua script
256ebe
+-- For now, we write a temporary bash script and execute that.
256ebe
+
256ebe
+script = [[#!/bin/sh
256ebe
+pidof -c -o %PPID -x glusterfsd &>/dev/null
256ebe
+
256ebe
+if [ $? -eq 0 ]; then
256ebe
+   pushd . > /dev/null 2>&1
256ebe
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
256ebe
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
256ebe
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
256ebe
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
256ebe
+          exit 1;
256ebe
+       fi
256ebe
+   done
256ebe
+
256ebe
+   popd > /dev/null 2>&1
256ebe
+   exit 1;
256ebe
+fi
256ebe
+]]
256ebe
+
256ebe
+-- rpm in RHEL5 does not have os.tmpname()
256ebe
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
256ebe
+tmpname = "/tmp/glusterfs-devel_pretrans_" .. os.date("%s")
256ebe
+tmpfile = io.open(tmpname, "w")
256ebe
+tmpfile:write(script)
256ebe
+tmpfile:close()
256ebe
+ok, how, val = os.execute("/bin/bash " .. tmpname)
256ebe
+os.remove(tmpname)
256ebe
+if not (ok == 0) then
256ebe
+   error("Detected running glusterfs processes", ok)
256ebe
+end
256ebe
+
256ebe
+
256ebe
+
256ebe
+%pretrans fuse -p <lua>
256ebe
+if not posix.access("/bin/bash", "x") then
256ebe
+    -- initial installation, no shell, no running glusterfsd
256ebe
+    return 0
256ebe
+end
256ebe
+
256ebe
+-- TODO: move this completely to a lua script
256ebe
+-- For now, we write a temporary bash script and execute that.
256ebe
+
256ebe
+script = [[#!/bin/sh
256ebe
+pidof -c -o %PPID -x glusterfsd &>/dev/null
256ebe
+
256ebe
+if [ $? -eq 0 ]; then
256ebe
+   pushd . > /dev/null 2>&1
256ebe
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
256ebe
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
256ebe
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
256ebe
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
256ebe
+          exit 1;
256ebe
+       fi
256ebe
+   done
256ebe
+
256ebe
+   popd > /dev/null 2>&1
256ebe
+   exit 1;
256ebe
+fi
256ebe
+]]
256ebe
+
256ebe
+-- rpm in RHEL5 does not have os.tmpname()
256ebe
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
256ebe
+tmpname = "/tmp/glusterfs-fuse_pretrans_" .. os.date("%s")
256ebe
+tmpfile = io.open(tmpname, "w")
256ebe
+tmpfile:write(script)
256ebe
+tmpfile:close()
256ebe
+ok, how, val = os.execute("/bin/bash " .. tmpname)
256ebe
+os.remove(tmpname)
256ebe
+if not (ok == 0) then
256ebe
+   error("Detected running glusterfs processes", ok)
256ebe
+end
256ebe
+
256ebe
+
256ebe
+
256ebe
+%if 0%{?_can_georeplicate}
256ebe
+%if ( 0%{!?_without_georeplication:1} )
256ebe
+%pretrans geo-replication -p <lua>
256ebe
+if not posix.access("/bin/bash", "x") then
256ebe
+    -- initial installation, no shell, no running glusterfsd
256ebe
+    return 0
256ebe
+end
256ebe
+
256ebe
+-- TODO: move this completely to a lua script
256ebe
+-- For now, we write a temporary bash script and execute that.
256ebe
+
256ebe
+script = [[#!/bin/sh
256ebe
+pidof -c -o %PPID -x glusterfsd &>/dev/null
256ebe
+
256ebe
+if [ $? -eq 0 ]; then
256ebe
+   pushd . > /dev/null 2>&1
256ebe
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
256ebe
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
256ebe
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
256ebe
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
256ebe
+          exit 1;
256ebe
+       fi
256ebe
+   done
256ebe
+
256ebe
+   popd > /dev/null 2>&1
256ebe
+   exit 1;
256ebe
+fi
256ebe
+]]
256ebe
+
256ebe
+-- rpm in RHEL5 does not have os.tmpname()
256ebe
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
256ebe
+tmpname = "/tmp/glusterfs-geo-replication_pretrans_" .. os.date("%s")
256ebe
+tmpfile = io.open(tmpname, "w")
256ebe
+tmpfile:write(script)
256ebe
+tmpfile:close()
256ebe
+ok, how, val = os.execute("/bin/bash " .. tmpname)
256ebe
+os.remove(tmpname)
256ebe
+if not (ok == 0) then
256ebe
+   error("Detected running glusterfs processes", ok)
256ebe
+end
256ebe
+%endif
256ebe
+%endif
256ebe
+
256ebe
+
256ebe
+
256ebe
+%pretrans libs -p <lua>
256ebe
+if not posix.access("/bin/bash", "x") then
256ebe
+    -- initial installation, no shell, no running glusterfsd
256ebe
+    return 0
256ebe
+end
256ebe
+
256ebe
+-- TODO: move this completely to a lua script
256ebe
+-- For now, we write a temporary bash script and execute that.
256ebe
+
256ebe
+script = [[#!/bin/sh
256ebe
+pidof -c -o %PPID -x glusterfsd &>/dev/null
256ebe
+
256ebe
+if [ $? -eq 0 ]; then
256ebe
+   pushd . > /dev/null 2>&1
256ebe
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
256ebe
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
256ebe
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
256ebe
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
256ebe
+          exit 1;
256ebe
+       fi
256ebe
+   done
256ebe
+
256ebe
+   popd > /dev/null 2>&1
256ebe
+   exit 1;
256ebe
+fi
256ebe
+]]
256ebe
+
256ebe
+-- rpm in RHEL5 does not have os.tmpname()
256ebe
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
256ebe
+tmpname = "/tmp/glusterfs-libs_pretrans_" .. os.date("%s")
256ebe
+tmpfile = io.open(tmpname, "w")
256ebe
+tmpfile:write(script)
256ebe
+tmpfile:close()
256ebe
+ok, how, val = os.execute("/bin/bash " .. tmpname)
256ebe
+os.remove(tmpname)
256ebe
+if not (ok == 0) then
256ebe
+   error("Detected running glusterfs processes", ok)
256ebe
+end
256ebe
+
256ebe
+
256ebe
+
256ebe
+%if ( 0%{!?_without_rdma:1} )
256ebe
+%pretrans rdma -p <lua>
256ebe
+if not posix.access("/bin/bash", "x") then
256ebe
+    -- initial installation, no shell, no running glusterfsd
256ebe
+    return 0
256ebe
+end
256ebe
+
256ebe
+-- TODO: move this completely to a lua script
256ebe
+-- For now, we write a temporary bash script and execute that.
256ebe
+
256ebe
+script = [[#!/bin/sh
256ebe
+pidof -c -o %PPID -x glusterfsd &>/dev/null
256ebe
+
256ebe
+if [ $? -eq 0 ]; then
256ebe
+   pushd . > /dev/null 2>&1
256ebe
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
256ebe
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
256ebe
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
256ebe
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
256ebe
+          exit 1;
256ebe
+       fi
256ebe
+   done
256ebe
+
256ebe
+   popd > /dev/null 2>&1
256ebe
+   exit 1;
256ebe
+fi
256ebe
+]]
256ebe
+
256ebe
+-- rpm in RHEL5 does not have os.tmpname()
256ebe
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
256ebe
+tmpname = "/tmp/glusterfs-rdma_pretrans_" .. os.date("%s")
256ebe
+tmpfile = io.open(tmpname, "w")
256ebe
+tmpfile:write(script)
256ebe
+tmpfile:close()
256ebe
+ok, how, val = os.execute("/bin/bash " .. tmpname)
256ebe
+os.remove(tmpname)
256ebe
+if not (ok == 0) then
256ebe
+   error("Detected running glusterfs processes", ok)
256ebe
+end
256ebe
+%endif
256ebe
+
256ebe
+
256ebe
+
256ebe
+%if ( 0%{!?_without_ocf:1} )
256ebe
+%pretrans resource-agents -p <lua>
256ebe
+if not posix.access("/bin/bash", "x") then
256ebe
+    -- initial installation, no shell, no running glusterfsd
256ebe
+    return 0
256ebe
+end
256ebe
+
256ebe
+-- TODO: move this completely to a lua script
256ebe
+-- For now, we write a temporary bash script and execute that.
256ebe
+
256ebe
+script = [[#!/bin/sh
256ebe
+pidof -c -o %PPID -x glusterfsd &>/dev/null
256ebe
+
256ebe
+if [ $? -eq 0 ]; then
256ebe
+   pushd . > /dev/null 2>&1
256ebe
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
256ebe
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
256ebe
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
256ebe
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
256ebe
+          exit 1;
256ebe
+       fi
256ebe
+   done
256ebe
+
256ebe
+   popd > /dev/null 2>&1
256ebe
+   exit 1;
256ebe
+fi
256ebe
+]]
256ebe
+
256ebe
+-- rpm in RHEL5 does not have os.tmpname()
256ebe
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
256ebe
+tmpname = "/tmp/glusterfs-resource-agents_pretrans_" .. os.date("%s")
256ebe
+tmpfile = io.open(tmpname, "w")
256ebe
+tmpfile:write(script)
256ebe
+tmpfile:close()
256ebe
+ok, how, val = os.execute("/bin/bash " .. tmpname)
256ebe
+os.remove(tmpname)
256ebe
+if not (ok == 0) then
256ebe
+   error("Detected running glusterfs processes", ok)
256ebe
+end
256ebe
+%endif
256ebe
+
256ebe
+
256ebe
+
256ebe
+%pretrans server -p <lua>
256ebe
+if not posix.access("/bin/bash", "x") then
256ebe
+    -- initial installation, no shell, no running glusterfsd
256ebe
+    return 0
256ebe
+end
256ebe
+
256ebe
+-- TODO: move this completely to a lua script
256ebe
+-- For now, we write a temporary bash script and execute that.
256ebe
+
256ebe
+script = [[#!/bin/sh
256ebe
+pidof -c -o %PPID -x glusterfsd &>/dev/null
256ebe
+
256ebe
+if [ $? -eq 0 ]; then
256ebe
+   pushd . > /dev/null 2>&1
256ebe
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
256ebe
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
256ebe
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
256ebe
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
256ebe
+          exit 1;
256ebe
+       fi
256ebe
+   done
256ebe
+
256ebe
+   popd > /dev/null 2>&1
256ebe
+   exit 1;
256ebe
+fi
256ebe
+]]
256ebe
+
256ebe
+-- rpm in RHEL5 does not have os.tmpname()
256ebe
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
256ebe
+tmpname = "/tmp/glusterfs-server_pretrans_" .. os.date("%s")
256ebe
+tmpfile = io.open(tmpname, "w")
256ebe
+tmpfile:write(script)
256ebe
+tmpfile:close()
256ebe
+ok, how, val = os.execute("/bin/bash " .. tmpname)
256ebe
+os.remove(tmpname)
256ebe
+if not (ok == 0) then
256ebe
+   error("Detected running glusterfs processes", ok)
256ebe
+end
256ebe
+%endif
256ebe
+
256ebe
 %changelog
256ebe
 * Wed Mar 6 2019 Kaleb S. KEITHLEY <kkeithle@redhat.com>
256ebe
 - remove unneeded ldconfig in scriptlets
256ebe
-- 
256ebe
1.8.3.1
256ebe