]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/scripts/hddshutdown
6bd24104f0bb91a9753072469d32062871b73b9c
3 # IPFire HDD Shutdown state reader
5 # This code is distributed under the terms of the GPL
7 # 20.08.2007 Maniacikarus - IPFire.org - maniacikarus@ipfire.org
12 my @proc = `cat /proc/diskstats`;
13 my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
17 my $status = "unknown";
19 if ($debug){print "### Reading Diskstats ###\n";}
22 my @line = split(/ +/,$_);
23 $diskstatus{$line[3]} =$line[12];
24 if ($debug){print "Getting device ".$line[3]." with the following value ".$line[12]."\n";}
27 if ($debug){print "### Searching for available Disks ###\n";}
31 if ($debug){print "Device ".$_." has ".$diskstatus{$_}." IO Requests.\n";}
32 $status = `hdparm -C /dev/$_ | tail -1 | cut -d: -f2`;
34 if ($diskstatus{$_} eq "0" && $status !=~/standby/){
35 if ($debug){print "Device ".$_." is set to standy.\n";}
36 system("/sbin/hdparm -y /dev/$_");
37 system("touch /tmp/hddshutdown-$_");
39 elsif ($diskstatus{$_} ne "0" || $status !=~/standby/){
40 if ($debug){print "Device ".$_." is active.\n";}
41 if ( -e
"/tmp/hddshutdown-$_" ) { system("unlink /tmp/hddshutdown-$_"); }