>From a16a68cde215eecdf794d7f100778ae6faf3fb7d Mon Sep 17 00:00:00 2001
From: Richard Sharpe <[EMAIL PROTECTED]>
Date: Fri, 25 Jul 2008 18:06:10 -0700
Subject: [PATCH] Allow -show to be used without a config file as well.
Also, only
             parse the config once if an alternate config file is specified.

Signed-off-by: Richard Sharpe <[EMAIL PROTECTED]>

---
 scripts/tgt-admin |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/scripts/tgt-admin b/scripts/tgt-admin
index 76fab79..41c828c 100755
--- a/scripts/tgt-admin
+++ b/scripts/tgt-admin
@@ -61,16 +61,16 @@ if (($help == 1) || ($param eq undef)) {
        &usage
 }

-# Parse the config file with Config::General
-my %conf = ParseConfig(-ConfigFile => "$configfile", -UseApacheInclude => 1, -I
ncludeGlob => 1,);
-
 # Show all the targets and exit
 if ($show == 1) {
        execute("tgtadm --lld iscsi --op show --mode target");
        exit;
 }

-# Check if alternative configuration file was given
+my %conf;
+
+# Check if alternative configuration file was given and use that, else
+# use the default. ParseConfig will die if config file not found.
 if ($alternate_conf ne 0) {
        # Check if alternative configuration file exist
        if (-e $alternate_conf) {
@@ -81,6 +81,10 @@ if ($alternate_conf ne 0) {
                die("file $alternate_conf not found. Exiting...\n");
        }
 }
+else {
+       # Parse the config file with Config::General
+       my %conf = ParseConfig(-ConfigFile => "$configfile", -UseApacheInclude =
> 1, -IncludeGlob => 1,);
+}

 # Some variables/arrays/hashes we will use globally
 my %tgtadm_output;
--
1.5.5.1

Attachment: 0002-Allow-show-to-be-used-without-a-config-file-as-well.patch
Description: Binary data

_______________________________________________
Stgt-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/stgt-devel

Reply via email to