iscsi service should start after openibd service.
 iscsi service should stop before openibd service.

Signed-off-by: Doron Shoham <[EMAIL PROTECTED]>
---
 install.pl |   93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 93 insertions(+), 0 deletions(-)

diff --git a/install.pl b/install.pl
index 354e896..422c9ca 100755
--- a/install.pl
+++ b/install.pl
@@ -76,6 +76,8 @@ chomp $kernel_sources;
 
 my $PACKAGE     = 'OFED';
 
+my $iscsi_selected = 0;
+
 # Set Linux Distribution
 if ( -f "/etc/SuSE-release" ) {
     $distro = "SuSE";
@@ -2478,6 +2480,7 @@ sub print_selected
 sub check_open_iscsi
 {
     my $oiscsi_name = $packages_info{'open-iscsi-generic'}{'name'};
+    $iscsi_selected=1;
     if (is_installed($oiscsi_name)) {
         my $vendor = `rpm --queryformat "[%{VENDOR}]" -q $oiscsi_name`;
         print "open-iscsi name $oiscsi_name vendor: $vendor\n" if ($verbose3);
@@ -2491,6 +2494,7 @@ sub check_open_iscsi
                 }
                 else {
                     print RED "Please uninstall $oiscsi_name before installing 
$PACKAGE with iSER support.", RESET "\n";
+                    $iscsi_selected=0;
                     exit 1;
                 }
             }
@@ -2498,6 +2502,7 @@ sub check_open_iscsi
                 if (not $upgrade_open_iscsi) {
                     print RED "Please uninstall $oiscsi_name before installing 
$PACKAGE with iSER support.", RESET "\n";
                     print RED "  Or put \"upgrade_open_iscsi=yes\" in the 
$config:", RESET "\n";
+                    $iscsi_selected=0;
                     exit 1;
                 }
             }
@@ -3673,6 +3678,87 @@ sub install
     }
 }
 
+sub set_iscsi_dep
+{
+    # set the dependencies of openibd and iscsi
+    # iscsi should start after openibd and stop before it
+
+    my $out='';
+    my $openibd_file='/etc/init.d/openibd';
+
+    if ($distro =~ /redhat/i) {
+        my @line;
+        my $openibd_start;
+        my $openibd_stop;
+        my $openiscsi_file='/etc/init.d/iscsi';
+        my $iscsi_start;
+        my $iscsi_stop;
+        open(IN,"<$openibd_file") || die "cannot open $openibd_file for 
reading: $!";
+           while (<IN>) { 
+            if (/chkconfig:/) {
+                @line=split(/ /);
+                # get the start and stop indexes of openibd
+                [EMAIL PROTECTED];
+                [EMAIL PROTECTED];
+            }
+        }
+        close(IN) || die "can't close $openibd_file: $!";
+
+        open(IN,"+<$openiscsi_file") || die "cannot open $openiscsi_file for 
reading: $!";
+        while (<IN>) {
+            if (/chkconfig:/) {
+                @line=split(/ /);
+                [EMAIL PROTECTED];
+                # set iscsi to start after openibd
+                if ( $iscsi_start<=$openibd_start ) {
+                    $openibd_start++;
+                    s/$iscsi_start/$openibd_start/;
+                }
+                   [EMAIL PROTECTED];
+                # set iscsi to stop before openibd
+                   if ( $iscsi_stop>=$openibd_stop ) {
+                    $openibd_stop--;
+                    s/$iscsi_stop/$openibd_stop\n/;
+                }
+            }
+            $out .= $_;
+        }
+        seek (IN, 0, 0);
+        print IN $out;
+        truncate (IN,tell(IN));
+        close(IN) || die "can't close $openiscsi_file: $!";
+    }
+    elsif ($distro=~/suse/i) {
+        my $openiscsi_file='/etc/init.d/open-iscsi';
+        open(IN,"+<$openibd_file") || die "cannot open $openibd_file for 
reading: $!";
+        while (<IN>) {
+            # set iscsi to stop before openibd
+            if (/Required-Stop:/) {
+                s/$/ open-iscsi/;
+            }
+            $out .= $_;
+        }
+        seek (IN, 0, 0);
+        print IN $out;
+        truncate (IN,tell(IN));
+        close(IN) || die "can't close $openibd_file: $!";
+
+        $out='';
+        open(IN,"+<$openiscsi_file") || die "cannot open $openiscsi_file for 
reading: $!";
+        while (<IN>) { 
+            # set iscsi to start after openibd
+            if (/Required-Start:/) {
+                s/$/ openibd/;
+            }
+            $out .= $_;
+        }
+        seek (IN, 0, 0);
+        print IN $out;
+        truncate (IN,tell(IN));
+        close(IN) || die "can't close $openiscsi_file: $!";
+    }
+}
+
 ### MAIN AREA ###
 sub main
 {
@@ -3837,6 +3923,13 @@ sub main
     if ($kernel_modules_info{'ipoib'}{'selected'}) {
         ipoib_config();
     }
+
+    # If open-iscsi was installed, set it to start after openibd
+    # and to stop before openibd
+    if ($iscsi_selected == 1) {
+        set_iscsi_dep();       
+    }
+
     print GREEN "\nInstallation finished successfully.", RESET;
     if ($interactive) {
         print GREEN "\nPress any key to continue...", RESET;
-- 
1.5.3.8


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

Reply via email to