X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=html%2Fcgi-bin%2Fextrahd.cgi;h=da1efb2ddff23245887643be8a3fcc60c4ae7ba0;hb=70187da6a665120f1af623899a10b0b1eff670e3;hp=0afe9ef6e6ae54f9fcfe1cb55d6e213f36e63a18;hpb=aa2870e623d6989bf405db7fa14069e7250707c9;p=people%2Fpmueller%2Fipfire-2.x.git diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi index 0afe9ef6e6..da1efb2ddf 100644 --- a/html/cgi-bin/extrahd.cgi +++ b/html/cgi-bin/extrahd.cgi @@ -1,16 +1,28 @@ #!/usr/bin/perl -# -# IPFire CGIs -# -# This code is distributed under the terms of the GPL -# -# (c) The IPFire Team -# +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2011 IPFire Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### use strict; # enable only the following on debugging purpose -use warnings; -use CGI::Carp 'fatalsToBrowser'; +#use warnings; +#use CGI::Carp 'fatalsToBrowser'; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; @@ -36,8 +48,13 @@ my $partitionentry = ""; my $devicefile = "/var/ipfire/extrahd/devices"; my $scanfile = "/var/ipfire/extrahd/scan"; my $partitionsfile = "/var/ipfire/extrahd/partitions"; -system("/usr/local/bin/scanhd ide"); -system("/usr/local/bin/scanhd partitions"); + +#workaround to suppress a warning when a variable is used only once +my @dummy = ( ${Header::colourgreen}, ${Header::colourred} ); +undef (@dummy); + +system("/usr/local/bin/extrahdctrl scanhd ide >/dev/null"); +system("/usr/local/bin/extrahdctrl scanhd partitions >/dev/null"); &Header::showhttpheaders(); @@ -46,6 +63,7 @@ $extrahdsettings{'PATH'} = ''; $extrahdsettings{'FS'} = ''; $extrahdsettings{'DEVICE'} = ''; $extrahdsettings{'ACTION'} = ''; +$extrahdsettings{'UUID'} = ''; &General::readhash("${General::swroot}/extrahd/settings", \%extrahdsettings); &Header::getcgihash(\%extrahdsettings); @@ -66,18 +84,18 @@ if ($extrahdsettings{'ACTION'} eq $Lang::tr{'add'}) @deviceline = split( /\;/, $deviceentry ); if ( "$extrahdsettings{'PATH'}" eq "$deviceline[2]" ) { $ok = "false"; - $errormessage = "You can't mount $extrahdsettings{'DEVICE'} to $extrahdsettings{'PATH'}, because there is already a device mounted."; + $errormessage = "$Lang::tr{'extrahd you cant mount'} $extrahdsettings{'DEVICE'} $Lang::tr{'extrahd to'} $extrahdsettings{'PATH'}$Lang::tr{'extrahd because there is already a device mounted'}."; } if ( "$extrahdsettings{'PATH'}" eq "/" ) { $ok = "false"; - $errormessage = "You can't mount $extrahdsettings{'DEVICE'} to root /."; + $errormessage = "$Lang::tr{'extrahd you cant mount'} $extrahdsettings{'DEVICE'} $Lang::tr{'extrahd to root'}."; } } if ( "$ok" eq "true" ) { open(FILE, ">> $devicefile" ) or die "Unable to write $devicefile"; print FILE <; close FILE; @@ -126,22 +143,22 @@ END { @deviceline = split( /\;/, $deviceentry ); my $color="$Header::colourred"; - if ( `/bin/mount | /bin/fgrep $deviceline[2] | /bin/fgrep /dev/$deviceline[0]` ) { + if ( ! `/bin/mountpoint $deviceline[2] | grep " not "` ) { $color=$Header::colourgreen; } print <  - /dev/$deviceline[0] - $deviceline[1] - $deviceline[2] +   + $deviceline[0] + $deviceline[1] + $deviceline[2]
- -
+ + END ; } @@ -149,10 +166,7 @@ END END ; - -&Header::closebox(); - -&Header::openbox('100%', 'center', 'Gefundene Laufwerke'); +&Header::openbox('100%', 'center', $Lang::tr{'extrahd detected drives'}); print < END @@ -166,21 +180,26 @@ END foreach $scanentry (sort @scans) { @scanline = split( /\;/, $scanentry ); - print <  - /dev/$scanline[0] - $scanline[1] + # remove wrong entries like usb controller name + if ($scanline[1] ne "\n") + { + print <  + /dev/$scanline[0] + $scanline[1] END ; + + } foreach $partitionentry (sort @partitions) { @partitionline = split( /\;/, $partitionentry ); if ( "$partitionline[0]" eq "$scanline[0]" ) { $size = int($partitionline[1] / 1024); print <$Lang::tr{'size'} $size MB -   -   + $Lang::tr{'size'} $size MB +   +   END ; } @@ -189,25 +208,31 @@ END foreach $partitionentry (sort @partitions) { @partitionline = split( /\;/, $partitionentry ); - if (( "$partitionline[0]" =~ /^$scanline[0]/ ) && ! ( "$partitionline[0]" eq "$scanline[0]" )) { + if (( "$partitionline[0]" =~ /^$scanline[0]/ ) && !( "$partitionline[2]" eq "" )) { $size = int($partitionline[1] / 1024); print < - /dev/$partitionline[0] - $Lang::tr{'size'} $size MB - + - - + + + - - + + +END +; END ; @@ -216,7 +241,9 @@ END } print <If your device isn't listed here, you need to install or load the driver.
If you can see your device but no partitions you have to create them first. +   +   + $Lang::tr{'extrahd install or load driver'} END ;