Skip to content

Commit

Permalink
Merge pull request #32 from mariux64/enable-pre-install-sanity-check
Browse files Browse the repository at this point in the history
Enable pre install sanity check
  • Loading branch information
thomas authored Mar 15, 2018
2 parents 90e2957 + 1031e24 commit f82e143
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions mxraid/mxraid_assemble
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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};

Expand All @@ -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 = '';
Expand All @@ -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();
}
Expand All @@ -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;
Expand Down

0 comments on commit f82e143

Please sign in to comment.