From 269e21c66206f4befdde25ceaec820467ff1cbe3 Mon Sep 17 00:00:00 2001 From: Arne Fitzenreiter Date: Mon, 16 Jan 2012 22:22:17 +0100 Subject: [PATCH] Fix block device detection for graphs and other scripts. --- config/rootfiles/core/56/filelists/files | 5 +++++ html/cgi-bin/hardwaregraphs.cgi | 4 ++-- html/cgi-bin/media.cgi | 4 ++-- src/initscripts/init.d/smartenabler | 2 +- src/scripts/hddshutdown | 3 ++- src/scripts/makegraphs | 2 +- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/config/rootfiles/core/56/filelists/files b/config/rootfiles/core/56/filelists/files index 409e5fe8ac..c82a52e087 100644 --- a/config/rootfiles/core/56/filelists/files +++ b/config/rootfiles/core/56/filelists/files @@ -1,2 +1,7 @@ etc/system-release etc/issue +etc/rc.d/init.d/smartenabler +srv/web/ipfire/cgi-bin/hardwaregraphs.cgi +srv/web/ipfire/cgi-bin/media.cgi +usr/local/bin/hddshutdown +usr/local/bin/makegraphs diff --git a/html/cgi-bin/hardwaregraphs.cgi b/html/cgi-bin/hardwaregraphs.cgi index e32f07c254..b0a5d3a36d 100644 --- a/html/cgi-bin/hardwaregraphs.cgi +++ b/html/cgi-bin/hardwaregraphs.cgi @@ -67,7 +67,7 @@ if ( $querry[0] =~ "hwtemp"){ print "Content-type: image/png\n\n"; binmode(STDOUT); &Graphs::updatethermaltempgraph($querry[1]); -}elsif ( $querry[0] =~ "sd?" || $querry[0] =~ "hd?" || $querry[0] =~ "xvd??" ){ +}elsif ( $querry[0] =~ "sd?" ){ print "Content-type: image/png\n\n"; binmode(STDOUT); &Graphs::updatehddgraph($querry[0],$querry[1]); @@ -93,7 +93,7 @@ if ( $querry[0] =~ "hwtemp"){ &General::writehash("${General::swroot}/sensors/settings", \%sensorsettings); } - my @disks = `find /sys/block/* -maxdepth 0 ! -name sr* ! -name loop* ! -name ram* -exec basename {} \\; | sort | uniq`; + my @disks = `ls -1 /sys/block | grep -E '^sd' | sort | uniq`; foreach (@disks){ my $disk = $_; diff --git a/html/cgi-bin/media.cgi b/html/cgi-bin/media.cgi index 9fbb041323..f67c1787ad 100644 --- a/html/cgi-bin/media.cgi +++ b/html/cgi-bin/media.cgi @@ -45,9 +45,9 @@ my @querry = split(/\?/,$ENV{'QUERY_STRING'}); $querry[0] = '' unless defined $querry[0]; $querry[1] = 'hour' unless defined $querry[1]; -my @devices = `find /sys/block/* -maxdepth 0 ! -name sr* ! -name loop* ! -name ram* -exec basename {} \\; | sort | uniq`; +my @devices = `ls -1 /sys/block | grep -E '^sd|^xvd|^vd|^md' | sort | uniq`; -if ( $querry[0] =~ "sd?" || $querry[0] =~ "hd?" || $querry[0] =~ "xvd??"){ +if ( $querry[0] =~ "sd?" || $querry[0] =~ "xvd??" || $querry[0] =~ "vd?" || $querry[0] =~ "md*" ){ print "Content-type: image/png\n\n"; binmode(STDOUT); diff --git a/src/initscripts/init.d/smartenabler b/src/initscripts/init.d/smartenabler index 7344c2f1c6..4df693656f 100644 --- a/src/initscripts/init.d/smartenabler +++ b/src/initscripts/init.d/smartenabler @@ -7,7 +7,7 @@ case "$1" in start) boot_mesg -n "Enabling S.M.A.R.T.: "; - for disk in `find /sys/block/* -maxdepth 0 ! -name sr* ! -name ram* ! -name loop* -exec basename {} \; | sort | uniq`; do + for disk in `ls -1 /sys/block | grep -E '^sd' | sort | uniq`; do /usr/sbin/smartctl --smart=on /dev/$disk > /dev/nul; if [ ${?} = 0 ]; then boot_mesg -n "$SUCCESS$disk$NORMAL "; diff --git a/src/scripts/hddshutdown b/src/scripts/hddshutdown index dc49a17060..146cc73474 100644 --- a/src/scripts/hddshutdown +++ b/src/scripts/hddshutdown @@ -22,7 +22,8 @@ # IPFire HDD Shutdown state reader # -my @devices = `find /sys/block/* -maxdepth 0 ! -name sr* ! -name loop* ! -name ram* -exec basename {} \\; | sort | uniq`; +# Also devices that cannot shutdown must be here for mediagraphs. +my @devices = `ls -1 /sys/block | grep -E '^sd|^xvd|^vd|^md' | sort | uniq`; my $diskstats = ""; my $newdiskstats = ""; my $debug = 1; diff --git a/src/scripts/makegraphs b/src/scripts/makegraphs index 48444f5e18..7cdd2f9bc7 100644 --- a/src/scripts/makegraphs +++ b/src/scripts/makegraphs @@ -102,7 +102,7 @@ sub updatehdddata{ ## Update vnstat system ('/usr/bin/vnstat -u'); -my @disks = `find /sys/block/* -maxdepth 0 ! -name sr* ! -name loop* ! -name ram* -exec basename {} \\; | sort | uniq`; +my @disks = `ls -1 /sys/block | grep -E '^sd|^xvd|^vd|^md' | sort | uniq`; system("unlink /var/run/hddstatus 2>/dev/null && touch /var/run/hddstatus"); foreach (@disks){ my $disk = $_; -- 2.39.5