93
my $smartctl = exists $ENV{smartctl} ? $ENV{smartctl} : undef;
93
my $smartctl = exists $ENV{smartctl} ? $ENV{smartctl} : '';
95
95
# If the envvar is not set, look for smartctl
97
$smartctl = `which smartctl 2>/dev/null` unless $smartctl;
99
$smartctl = undef unless -x $smartctl;
101
# Still not found? Check obvious places
102
my @dirs = qw(/usr/bin /usr/sbin /usr/local/bin /usr/local/sbin);
103
until ($smartctl or @dirs == 0) {
104
my $dir = shift @dirs;
105
my $path = $dir.'/smartctl';
106
$smartctl = $path if -x $path;
97
# Still not found? Check obvious places
98
my @dirs = split(':',$ENV{PATH});
99
push (@dirs, qw(/usr/bin /usr/sbin /usr/local/bin /usr/local/sbin) );
101
until ($smartctl or @dirs == 0) {
102
my $dir = shift @dirs;
103
my $path = $dir.'/smartctl';
104
$smartctl = $path if -x $path;
109
108
# Check version of smartctl to determine --nocheck capabilities
110
109
my $use_nocheck = 0;
111
if (`$smartctl --version` =~ / version (\d+\.\d+) /i) {
112
$use_nocheck = $1 >= 5.37;
110
if ($smartctl and `$smartctl --version` =~ / version (\d+\.\d+) /i) {
111
$use_nocheck = $1 >= 5.37;
115
114
# hdparm is used as a fallback
116
my $hdparm = `which hdparm`;
115
my $hdparm = `which hdparm 2>/dev/null`;