[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
MiniVend configuration dumper
Copy it your MiniVend bin-directory and dump your catalog configurations
with MINIVEND_ROOT/bin/configdump CATALOG. I hope you find it useful.
Bye
Racke
#!/usr/bin/perl
#
# MiniVend configuration dumper
#
# Copyright 1999 by Stefan Hornburg <racke@linuxia.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
BEGIN {
eval {
require 5.004;
require FindBin;
1 and $Global::VendRoot = "$FindBin::RealBin";
1 and $Global::VendRoot =~ s/.bin$//;
};
($Global::VendRoot = $ENV{MINIVEND_ROOT})
if defined $ENV{MINIVEND_ROOT};
$Global::VendRoot = $Global::VendRoot || '/home/minivend';
$Global::ErrorFile = "$Global::VendRoot/error.log";
}
# dummy function used by Config.pm
sub debug { return undef }
$Global::ConfigFile = 'minivend.cfg';
use lib $Global::VendRoot;
use lib "$Global::VendRoot/lib";
use strict;
use Vend::Config;
my $USAGE = <<EOF;
usage: configdump catalog
EOF
# check commandline parameters
unless ($#ARGV == 0) {
print $USAGE;
exit 1;
}
my ($catalog, $name);
$Vend::Cfg = {};
$catalog = shift;
my($name,$dir,$param,$subcat,$subconfig,$junk);
chdir $Global::VendRoot;
if ($catalog) {
open(GLOBAL, $Global::ConfigFile) or
die "No global configuration file? Aborting.\n";
while(<GLOBAL>) {
next unless /^\s*(sub)?catalog\s+$catalog\s+/i;
$subcat = $1 || '';
chomp;
s/^\s+//;
unless($subcat) {
($junk,$name,$dir,$param) = split /\s+/, $_, 4;
}
else {
($junk,$name,$subconfig,$dir,$param) = split /\s+/, $_, 5;
}
last;
}
close GLOBAL;
}
global_config();
chdir $dir or die "Couldn't change directory to $dir: $!\n";
if ($catalog) {
$Vend::Cfg = config($name, $dir, 'config', $subconfig || undef);
}
my $value;
foreach (sort (keys (%$Vend::Cfg))) {
$value = $$Vend::Cfg{$_};
print_values ($value, $_, 1);
}
sub print_values {
my ($value, $prefix, $level) = @_;
if (ref($value) eq 'HASH') {
foreach my $subkey (sort (keys (%$value))) {
if (ref($$value{$subkey}) eq '') {
print "$prefix $subkey ", $$value{$subkey}, "\n";
} else {
print_values ($$value{$subkey}, "$prefix $subkey",
$level + 1);
}
}
} elsif (ref($value) eq 'ARRAY') {
for (my $i = 0; $i <= $#$value; $i++) {
if (ref($$value[$i]) eq '') {
print "$prefix #", $i + 1, ' ', $$value[$i], "\n";
} else {
print_values ($$value[$i], "$prefix #" . $i + 1, $level + 1);
}
}
} else {
print "$prefix $value\n";
}
}
--
LinuXia - Solutions of Cool Competence - Internetprogramming and more
D-30163 Hannover, Waldstraße 4, 0511-3941290 (http://www.linuxia.de/)
Wir realisieren Onlineshops mit Minivend (http://www.minivend.com)
und MiniMate (http://www.linuxia.de/minimate/).