Skip to content

Commit

Permalink
unblink
Browse files Browse the repository at this point in the history
  • Loading branch information
chicks-net committed Jul 29, 2014
1 parent 8d1e1df commit d5fa9eb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ Usage
10 sdl 0x5000cca02ab9e0c0
11 sdm 0x5000cca02ab9b350

`megablink` takes arguments of linux drives like `/dev/sda` or without the full path such as `sdb` and starts that drive blinking. Unblinking happens when the drive is replaced automatically, so there is no reversal script at this point.
`megablink` takes arguments of linux drives like `/dev/sda` or without the full
path such as `sdb` and starts that drive blinking. Unblinking happens when the
drive is replaced automatically, but there is also a `megaunblink` in case you
accidentally blink the wrong drive. `megablink -u` also unblinks a drive.

$ sudo ./megablink /dev/sdn
blinking drive 8 (sdn), running megacli -PdLocate -start -physdrv[0:8] -a0
Expand Down
11 changes: 10 additions & 1 deletion megablink
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use warnings;
use Data::Dumper;
use Carp;
use English qw( -no_match_vars );
use Getopt::Long;

our $VERSION = 0.3;

Expand All @@ -13,6 +14,12 @@ my $username = ( getpwuid $EUID );
croak "megacli requires root" if $username ne 'root';

# CLI arguments
my $unblink = 0;

GetOptions(
'u|unblink' => \$unblink,
) or croak "error in command line args";

croak "no arguments... please specify which drives to blink" unless scalar @ARGV;
my @drives = @ARGV;

Expand Down Expand Up @@ -46,7 +53,9 @@ foreach my $drive (@drives) {
$megaraid_id = $map{$drive} or croak "no mapping for $drive";
}
print "blinking drive $megaraid_id ($drive), ";
my $cmd = "megacli -PdLocate -start -physdrv[0:$megaraid_id] -a0";
my $gonogo = "-start";
$gonogo = "stop" if $unblink;
my $cmd = "megacli -PdLocate $gonogo -physdrv[0:$megaraid_id] -a0";
print "running $cmd\n";
system($cmd);
}
3 changes: 3 additions & 0 deletions megaunblink
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

megablink -u $*

0 comments on commit d5fa9eb

Please sign in to comment.