[PATCH] Allow -show to be used without a config file as well.

Richard Sharpe realrichardsharpe
Sat Jul 26 03:06:10 CEST 2008


Also, only
             parse the config once if an alternate config file is specified.

Signed-off-by: Richard Sharpe <realrichardsharpe at gmail.com>

---
 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

------=_Part_21314_20473588.1217006538442
Content-Type: application/octet-stream;
 name=0002-Allow-show-to-be-used-without-a-config-file-as-well.patch
Content-Transfer-Encoding: base64
X-Attachment-Id: f_fj328v0h0
Content-Disposition: attachment;
 filename=0002-Allow-show-to-be-used-without-a-config-file-as-well.patch

RnJvbSBhMTZhNjhjZGUyMTVlZWNkZjc5NGQ3ZjEwMDc3OGFlNmZhZjNmYjdkIE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBSaWNoYXJkIFNoYXJwZSA8cmVhbHJpY2hhcmRzaGFycGVAZ21h
aWwuY29tPgpE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