]> git.openfabrics.org - ~vlad/ofed_scripts.git/commitdiff
ofed_1_3/ofed_scripts: Add vendor script pre/post hooks for OFED install/uninstall
authorMoni Shoua <monis@voltaire.com>
Tue, 1 Jan 2008 10:17:36 +0000 (12:17 +0200)
committerVladimir Sokolovsky <vlad@mellanox.co.il>
Sun, 6 Jan 2008 17:25:56 +0000 (19:25 +0200)
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@voltaire.com>
install.pl
ofed-scripts.spec
uninstall.sh
vendor_post_uninstall.sh [new file with mode: 0755]
vendor_pre_uninstall.sh [new file with mode: 0755]

index dbf57ce111bff6530d1fc01848caea715a2f8371..915530ecae62d324fbd3daa23aafc6d2808290c9 100755 (executable)
@@ -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();
     }
index 6c952aae8904aa770fb77a2ff25f7262646daa31..e58bf08c75a88e40eb27ef4bbf917a17f0538b5e 100644 (file)
@@ -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@mellanox.co.il>
index a65f0e5ae3bed9abd561360f38ff3ec79b43a6f1..eb25e16c6e7e635a8e31b10875c70102177e3eec 100755 (executable)
@@ -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 (executable)
index 0000000..8c3cbfc
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exit 0
diff --git a/vendor_pre_uninstall.sh b/vendor_pre_uninstall.sh
new file mode 100755 (executable)
index 0000000..8c3cbfc
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exit 0