]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/extrahd.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
23 # enable only the following on debugging purpose
25 #use CGI::Carp 'fatalsToBrowser';
27 require '/var/ipfire/general-functions.pl' ;
28 require "${General::swroot}/lang.pl" ;
29 require "${General::swroot}/header.pl" ;
31 my %extrahdsettings = ();
33 my $errormessage = "" ;
46 my @partitionline = ();
47 my $partitionentry = "" ;
48 my $devicefile = "/var/ipfire/extrahd/devices" ;
49 my $scanfile = "/var/ipfire/extrahd/scan" ;
50 my $partitionsfile = "/var/ipfire/extrahd/partitions" ;
51 system ( "/usr/local/bin/scanhd ide" );
52 system ( "/usr/local/bin/scanhd partitions" );
54 & Header
:: showhttpheaders
();
56 ### Values that have to be initialized
57 $extrahdsettings { 'PATH' } = '' ;
58 $extrahdsettings { 'FS' } = '' ;
59 $extrahdsettings { 'DEVICE' } = '' ;
60 $extrahdsettings { 'ACTION' } = '' ;
62 & General
:: readhash
( "${General::swroot}/extrahd/settings" , \
%extrahdsettings );
63 & Header
:: getcgihash
( \
%extrahdsettings );
65 & Header
:: openpage
( 'ExtraHD' , 1 , '' );
66 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
68 ############################################################################################################################
69 ############################################################################################################################
71 if ( $extrahdsettings { 'ACTION' } eq $Lang :: tr
{ 'add' })
73 open ( FILE
, "< $devicefile " ) or die "Unable to read $devicefile " ;
76 foreach $deviceentry ( sort @devices )
78 @deviceline = split ( /\;/ , $deviceentry );
79 if ( " $extrahdsettings {'PATH'}" eq " $deviceline [2]" ) {
81 $errormessage = "You can't mount $extrahdsettings {'DEVICE'} to $extrahdsettings {'PATH'}, because there is already a device mounted." ;
83 if ( " $extrahdsettings {'PATH'}" eq "/" ) {
85 $errormessage = "You can't mount $extrahdsettings {'DEVICE'} to root /." ;
89 if ( " $ok " eq "true" ) {
90 open ( FILE
, ">> $devicefile " ) or die "Unable to write $devicefile " ;
92 $extrahdsettings {'DEVICE'}; $extrahdsettings {'FS'}; $extrahdsettings {'PATH'};
95 system ( "/usr/local/bin/extrahdctrl mount $extrahdsettings {'PATH'}" );
98 elsif ( $extrahdsettings { 'ACTION' } eq $Lang :: tr
{ 'delete' })
100 if ( `/usr/local/bin/extrahdctrl umount $extrahdsettings {'PATH'}` ) {
101 open ( FILE
, "< $devicefile " ) or die "Unable to read $devicefile " ;
104 open ( FILE
, "> $devicefile " ) or die "Unable to write $devicefile " ;
105 foreach $deviceentry ( sort @tmp )
107 @tmpline = split ( /\;/ , $deviceentry );
108 if ( $tmpline [ 2 ] ne $extrahdsettings { 'PATH' } )
110 print FILE
$deviceentry ;
115 $errormessage = "Can't umount $extrahdsettings {'PATH'}. Maybe the device is in use?" ;
120 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
121 print "<class name='base'> $errormessage \n " ;
122 print " </class> \n " ;
126 ############################################################################################################################
127 ############################################################################################################################
129 & Header
:: openbox
( '100%' , 'center' , 'ExtraHD' );
130 open ( FILE
, "< $devicefile " ) or die "Unable to read $devicefile " ;
134 <table border='0' width='600' cellspacing="0">
137 foreach $deviceentry ( sort @devices )
139 @deviceline = split ( /\;/ , $deviceentry );
140 my $color = " $Header ::colourred" ;
141 if ( `/bin/mount | /bin/fgrep $deviceline [2] | /bin/fgrep /dev/ $deviceline [0]` ) {
142 $color = $Header :: colourgreen
;
145 <tr><td colspan="5">
146 <tr><td align='center'><font color= $color ><b>/dev/ $deviceline [0]</b></font>
147 <td align='center'> $deviceline [1]
148 <td align='center'> $deviceline [2]
150 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
151 <input type='hidden' name='DEVICE' value=' $deviceline [0]' />
152 <input type='hidden' name='FS' value=' $deviceline [1]' />
153 <input type='hidden' name='PATH' value=' $deviceline [2]' />
154 <input type='hidden' name='ACTION' value= $Lang ::tr{'delete'} />
155 <input type='image' alt= $Lang ::tr{'delete'} src='/images/delete.gif' />
167 & Header
:: openbox
( '100%' , 'center' , 'Gefundene Laufwerke' );
169 <table border='0' width='600' cellspacing="0">
172 open ( FILE
, "< $scanfile " ) or die "Unable to read $scanfile " ;
175 open ( FILE
, "< $partitionsfile " ) or die "Unable to read $partitionsfile " ;
176 @partitions = < FILE
>;
178 foreach $scanentry ( sort @scans )
180 @scanline = split ( /\;/ , $scanentry );
182 <tr><td colspan="5">
183 <tr><td align='center'><b>/dev/ $scanline [0]</b>
184 <td align='center' colspan="2"> $scanline [1]
187 foreach $partitionentry ( sort @partitions )
189 @partitionline = split ( /\;/ , $partitionentry );
190 if ( " $partitionline [0]" eq " $scanline [0]" ) {
191 $size = int ( $partitionline [ 1 ] / 1024 );
193 <td align='center'> $Lang ::tr{'size'} $size MB
195 <tr><td colspan="5">
201 foreach $partitionentry ( sort @partitions )
203 @partitionline = split ( /\;/ , $partitionentry );
204 if (( " $partitionline [0]" =~ /^$scanline[0]/ ) && ! ( " $partitionline [0]" eq " $scanline [0]" )) {
205 $size = int ( $partitionline [ 1 ] / 1024 );
207 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
208 <tr><td align="center">/dev/ $partitionline [0]
209 <td align="center"> $Lang ::tr{'size'} $size MB
210 <td align='center'><select name="FS">
211 <option value="auto">auto</option>
212 <option value="ext3">ext3</option>
213 <option value="reiserfs">reiserfs</option>
214 <option value="vfat">fat</option>
215 <option value="ntfs-3g">ntfs (experimental)</option>
217 <td align="center"><input type='text' name='PATH' value=/mnt/harddisk />
219 <input type='hidden' name='DEVICE' value=' $partitionline [0]' />
220 <input type='hidden' name='ACTION' value= $Lang ::tr{'add'} />
221 <input type='image' alt= $Lang ::tr{'add'} src='/images/add.gif' />
231 <tr><td align="center" colspan="5">If your device isn't listed here, you need to install or load the driver.<br />If you can see your device but no partitions you have to create them first.
237 & Header
:: closebigbox
();
238 & Header
:: closepage
();