[ewg] [PATCH] ofed_1_3/ofed_scripts: Add vendor script pre/post hooks for OFED install/uninstall

Moshe Kazir moshek at voltaire.com
Tue Jan 1 22:50:04 PST 2008


 
I'm not sure this is the best way to implement this ....

Adding the vendor_pre_ function  as the first line of
install()/uninstall()

and the vendor_post function as the last line of install()/uninstall()

Will ensure that it will be performed o.k. (not forgotten) on all the
locations were the install / uninstall functions are called. 

Moshe
 


____________________________________________________________
Moshe Katzir   |  +972-9971-8639 (o)   |   +972-52-860-6042  (m)
 
Voltaire - The Grid Backbone
 
 www.voltaire.com

  

-----Original Message-----
From: ewg-bounces at lists.openfabrics.org
[mailto:ewg-bounces at lists.openfabrics.org] On Behalf Of Moni Shoua
Sent: Tuesday, January 01, 2008 12:18 PM
To: Vladimir Sokolovsky
Cc: Moni Levy; ewg
Subject: [ewg] [PATCH] ofed_1_3/ofed_scripts: Add vendor script pre/post
hooks for OFED install/uninstall

Vendors that distribute OFED sometimes need to add vendor specific
actions to the install and/or the uninstall process. This patch adds
this capability of adding scripts that would be executed before and
after OFED install and uninstall. Names of the scripts are given in the
configuration file for the install.pl script.

Examlpe (lines in ofed.conf)

vendor_pre_install=vendor_pre_install.sh
vendor_post_install=vendor_post_install.sh
vendor_pre_uninstall=vendor_pre_uninstall.sh
vendor_post_uninstall=vendor_post_uninstall.sh

Signed-off-by: Moni Shoua <monis at voltaire.com>
---

 install.pl               |   75
+++++++++++++++++++++++++++++++++++++++++++++++
 ofed-scripts.spec        |    4 ++
 uninstall.sh             |    4 ++
 vendor_post_uninstall.sh |    3 +
 vendor_pre_uninstall.sh  |    3 +
 5 files changed, 89 insertions(+)


diff --git a/install.pl b/install.pl
index dbf57ce..915530e 100755
--- a/install.pl
+++ b/install.pl
@@ -59,6 +59,11 @@ my $print_available = 0;  my $clear_string = `clear`;
my $upgrade_open_iscsi = 0;
 
+my $vendor_pre_install = "";
+my $vendor_post_install = "";
+my $vendor_pre_uninstall = "";
+my $vendor_post_uninstall = "";
+
 my $distro;
 
 my $build32 = 0;
@@ -2044,6 +2049,50 @@ sub select_packages
                     next;
                 }
 
+                if ($package eq "vendor_pre_install") {
+		    if ( -f $selected ) {
+			$vendor_pre_install = dirname($selected) . '/' .
basename($selected);
+		    }
+		    else {
+			print RED "\nVendor script $selected is not
found", RESET "\n" if (not $quiet);
+			exit 1
+		    }
+                    next;
+                }
+
+                if ($package eq "vendor_post_install") {
+		    if ( -f $selected ) {
+			$vendor_post_install = dirname($selected) . '/'
. basename($selected);
+		    }
+		    else {
+			print RED "\nVendor script $selected is not
found", RESET "\n" if (not $quiet);
+			exit 1
+		    }
+                    next;
+                }
+
+                if ($package eq "vendor_pre_uninstall") {
+		    if ( -f $selected ) {
+			$vendor_pre_uninstall = dirname($selected) . '/'
. basename($selected);
+		    }
+		    else {
+			print RED "\nVendor script $selected is not
found", RESET "\n" if (not $quiet);
+			exit 1
+		    }
+                    next;
+                }
+
+                if ($package eq "vendor_post_uninstall") {
+		    if ( -f $selected ) {
+			$vendor_post_uninstall = dirname($selected) .
'/' . basename($selected);
+		    }
+		    else {
+			print RED "\nVendor script $selected is not
found", RESET "\n" if (not $quiet);
+			exit 1
+		    }
+                    next;
+                }
+
                 if ($package eq "kernel_configure_options" or $package
eq "OFA_KERNEL_PARAMS") {
                     $kernel_configure_options = $selected;
                     next;
@@ -3696,7 +3745,33 @@ sub main
     
     # Uninstall the previous installations
     uninstall();
+    my $vendor_ret;
+    if (length($vendor_pre_install) > 0) {
+	    print BLUE "\nRunning vendor pre install script:
$vendor_pre_install", RESET "\n" if (not $quiet);
+	    $vendor_ret = system ( "$vendor_pre_install",
"CONFIG=$config",
+		"RPMS=$RPMS", "SRPMS=$SRPMS", "PREFIX=$prefix",
"TOPDIR=$TOPDIR", "QUIET=$quiet" );
+	    if ($vendor_ret != 0) {
+		    print RED "\nExecution of vendor pre install script
failed.", RESET "\n" if (not $quiet);
+		    exit 1;
+	    }
+    }
     install();
+    if (length($vendor_pre_uninstall) > 0) {
+	    system "cp $vendor_pre_uninstall
$prefix/sbin/vendor_pre_uninstall.sh";
+    }
+    if (length($vendor_post_uninstall) > 0) {
+	    system "cp $vendor_post_uninstall
$prefix/sbin/vendor_post_uninstall.sh";
+    }
+    if (length($vendor_post_install) > 0) {
+	    print BLUE "\nRunning vendor post install script:
$vendor_post_install", RESET "\n" if (not $quiet);
+	    $vendor_ret = system ( "$vendor_post_install",
"CONFIG=$config",
+		"RPMS=$RPMS", "SRPMS=$SRPMS", "PREFIX=$prefix",
"TOPDIR=$TOPDIR", "QUIET=$quiet");
+	    if ($vendor_ret != 0) {
+		    print RED "\nExecution of vendor post install script
failed.", RESET "\n" if (not $quiet);
+		    exit 1;
+	    }
+    }
+
     if ($kernel_modules_info{'ipoib'}{'selected'}) {
         ipoib_config();
     }
diff --git a/ofed-scripts.spec b/ofed-scripts.spec index
6c952aa..e58bf08 100644
--- a/ofed-scripts.spec
+++ b/ofed-scripts.spec
@@ -49,6 +49,8 @@ OpenFabrics scripts
 install -d $RPM_BUILD_ROOT%{_prefix}/bin  install -d
$RPM_BUILD_ROOT%{_prefix}/sbin  install -m 0755 uninstall.sh
$RPM_BUILD_ROOT%{_prefix}/sbin/ofed_uninstall.sh
+install -m 0755 vendor_pre_uninstall.sh $RPM_BUILD_ROOT%{_prefix}/sbin 
+install -m 0755 vendor_post_uninstall.sh $RPM_BUILD_ROOT%{_prefix}/sbin
 install -m 0755 ofed_info $RPM_BUILD_ROOT%{_prefix}/bin
 
 perl -ni -e "s@(STACK_PREFIX=).*@\$1%{_prefix}@; print"
$RPM_BUILD_ROOT%{_prefix}/sbin/ofed_uninstall.sh
@@ -115,6 +117,8 @@ esac
 %defattr(-,root,root)
 %{_prefix}/bin/ofed_info
 %{_prefix}/sbin/ofed_uninstall.sh
+%{_prefix}/sbin/vendor_pre_uninstall.sh
+%{_prefix}/sbin/vendor_post_uninstall.sh
 
 %changelog
 * Tue Oct  9 2007 Vladimir Sokolovsky <vlad at mellanox.co.il> diff --git
a/uninstall.sh b/uninstall.sh index a65f0e5..eb25e16 100755
--- a/uninstall.sh
+++ b/uninstall.sh
@@ -266,7 +266,11 @@ echo
 
 read -p "Do you want to continue?[y/N]:" ans_r  if [[ "$ans_r" == "y"
|| "$ans_r" == "Y" || "$ans_r" == "yes" ]]; then
+    [ -x $STACK_PREFIX/sbin/vendor_pre_uninstall.sh ] && ex
$STACK_PREFIX/sbin/vendor_pre_uninstall.sh
+    [ -x $STACK_PREFIX/sbin/vendor_post_uninstall.sh ] && \
+	cp $STACK_PREFIX/sbin/vendor_post_uninstall.sh 
+/tmp/$$-ofed_vendor_post_uninstall.sh
     uninstall
+    [ -x /tmp/$$-ofed_vendor_post_uninstall.sh ] && ex 
+ /tmp/$$-ofed_vendor_post_uninstall.sh
 else    
     exit 1
 fi
diff --git a/vendor_post_uninstall.sh b/vendor_post_uninstall.sh new
file mode 100755 index 0000000..8c3cbfc
--- /dev/null
+++ b/vendor_post_uninstall.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exit 0
diff --git a/vendor_pre_uninstall.sh b/vendor_pre_uninstall.sh new file
mode 100644 index 0000000..8c3cbfc
--- /dev/null
+++ b/vendor_pre_uninstall.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exit 0

_______________________________________________
ewg mailing list
ewg at lists.openfabrics.org
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/ewg



More information about the ewg mailing list