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