diff --git a/mxraid/mxraid_assemble b/mxraid/mxraid_assemble index d8909036..34855c42 100755 --- a/mxraid/mxraid_assemble +++ b/mxraid/mxraid_assemble @@ -30,6 +30,7 @@ sub exec_usage { -a assemble arrays when run as root -c check database + -d file alternative database file -h print this help and exit -q be quiet -v be more verbose @@ -62,7 +63,7 @@ sub exec_version { my $ROOT=$<==0?1:0; my %opts; -getopts('achqvV', \%opts) or die "# ERROR: getopts failed, try -h.\n"; # Values in %opts +getopts('acd:hqvV', \%opts) or die "# ERROR: getopts failed, try -h.\n"; # Values in %opts exec_usage if $opts{h}; exec_version if $opts{V}; @@ -73,6 +74,15 @@ $VERBOSE+=1 if $opts{v}; my $MDADMCONF_DB = '/etc/mxmd.conf'; # the 'database' with serials +if ($opts{d}) { + my $db = $opts{d}; + if (-e $db) { + $MDADMCONF_DB = $db; + } else { + die "# db file '$db' does not exist, stopped"; + } +} + my $MDADM_CONF_BASE = '/dev/shm/mdadm.conf'; # config for mdadm, created with information from above my $MDADM_ASSEMBLE_OPTIONS = ''; @@ -82,10 +92,12 @@ my $hd = MxRaid::HostData->new($cd); $hd->verbose($VERBOSE); my $utils = MxRaid::Utils->new(); if ($opts{c}) { - printf "# Database file :'%s'\n", $MDADMCONF_DB; - printf "# Record count : %d\n", $cd->number_of_db_records; - printf "# Successor labels: %s\n", join(', ', @{$cd->next_db_labels}); - print "\n"; + if ($VERBOSE >= 1) { + printf "# Database file :'%s'\n", $MDADMCONF_DB; + printf "# Record count : %d\n", $cd->number_of_db_records; + printf "# Successor labels: %s\n", join(', ', @{$cd->next_db_labels}); + print "\n"; + } } else { create_mdadm_configs(); } @@ -105,7 +117,6 @@ sub create_mdadm_configs { my @mdadm_conf; my $dev_no = 0; for my $rlabel (@{$hd->raid_labels()}) { -### my $pfx = ''; # :xxx: this is a cheat, fix this my $condition_active = 0; my $condition_incomplete = 0; my $active_dev_no = -1;