]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/scripts/hddshutdown
3 # IPFire HDD Shutdown state reader
5 # This code is distributed under the terms of the GPL
7 # 18.09.2007 Maniacikarus - IPFire.org - maniacikarus@ipfire.org
12 my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
14 my $newdiskstats = "";
16 my $status = "unknown";
18 if ($debug){print "### Searching for available Disks ###\n";}
22 $diskstats = `iostat -d -t $_ | tail -2 | head -1 | awk '{ print \$5","\$6}'`;
23 $status = `hdparm -C /dev/$_ | tail -1 | cut -d: -f2`;
26 if ($debug){print "Device ".$_." is in status".$status." and has ".$diskstats." write and read Requests.\n";}
28 $newdiskstats = `iostat -d -t $_ | tail -2 | head -1 | awk '{ print \$5","\$6}'`;
31 if ($diskstats eq $newdiskstats && $status !=~/standby/){
32 if ($debug){print "Device ".$_." is set to standy.\n";}
33 system("/sbin/hdparm -y /dev/$_");
34 system("touch /tmp/hddshutdown-$_");
36 elsif ($diskstatus{$_} ne "0" || $status !=~/standby/){
37 if ($debug){print "Device ".$_." is active.\n";}
38 if ( -e
"/tmp/hddshutdown-$_" ) { system("unlink /tmp/hddshutdown-$_"); }