From 2e5794ea4dc5de6a007efd2e67fc558f4ea84118 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 15 Mar 2018 09:16:08 +0100 Subject: [PATCH 1/3] mxraid_assemble: cleanup a bit --- mxraid/mxraid_assemble | 1 - 1 file changed, 1 deletion(-) diff --git a/mxraid/mxraid_assemble b/mxraid/mxraid_assemble index d890903..2702de8 100755 --- a/mxraid/mxraid_assemble +++ b/mxraid/mxraid_assemble @@ -105,7 +105,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; From ee001183a823965e9b05ecc539584743457142f2 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 15 Mar 2018 09:20:48 +0100 Subject: [PATCH 2/3] mxraid_assemble: output from check honors verbose setting This is useful if only the exit code matters. --- mxraid/mxraid_assemble | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mxraid/mxraid_assemble b/mxraid/mxraid_assemble index 2702de8..6fb151a 100755 --- a/mxraid/mxraid_assemble +++ b/mxraid/mxraid_assemble @@ -82,10 +82,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(); } From 1031e24eae94915bd8c41c6e701f82601066b8e7 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 15 Mar 2018 09:34:14 +0100 Subject: [PATCH 3/3] mxraid_assemble: specify database file as option This allows checkin the db-file before it gets disted. --- mxraid/mxraid_assemble | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mxraid/mxraid_assemble b/mxraid/mxraid_assemble index 6fb151a..34855c4 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 = '';