Jelajahi Sumber

Trying to implement multi OS support

Paul Trost 11 tahun lalu
induk
melakukan
b67d3f43b2
2 mengubah file dengan 9 tambahan dan 4 penghapusan
  1. TEMPAT SAMPAH
      dist/Disk-SMART-0.08.tar.gz
  2. 9 4
      lib/Disk/SMART.pm

TEMPAT SAMPAH
dist/Disk-SMART-0.08.tar.gz


+ 9 - 4
lib/Disk/SMART.pm

@@ -6,10 +6,11 @@ use Carp;
 use Math::Round;
 
 {
-    $Disk::SMART::VERSION = '0.08'
+    $Disk::SMART::VERSION = '0.09'
 }
 
-our $smartctl = '/usr/sbin/smartctl';
+our $smartctl = qx(which smartctl);
+chomp($smartctl);
 
 =head1 NAME
 
@@ -160,8 +161,8 @@ sub update_data {
     my ( $self, $device ) = @_;
 
     my $out;
-    $out = $ENV{'MOCK_TEST_DATA'} if ( defined $ENV{'MOCK_TEST_DATA'} );
-    $out = qx($smartctl -a $device) if -f $smartctl;
+    $out = $ENV{'MOCK_TEST_DATA'}   if defined $ENV{'MOCK_TEST_DATA'};
+    $out = qx($smartctl -a $device) if ( !defined $ENV{'MOCK_TEST_DATA'} && -f $smartctl );
     croak "Smartctl couldn't poll device $device\n"
         if ( !$out || $out !~ /START OF INFORMATION SECTION/ );
 
@@ -299,6 +300,10 @@ sub _validate_param {
 
 __END__
 
+=head1 COMPATIBILITY
+
+  This module should run on any UNIX like OS with Perl 5.10+ and has the smartctl progam installed from the smartmontools package.
+
 =head1 AUTHOR
 
  Paul Trost <ptrost@cpan.org>