]>
git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/extrahd.cgi
5 # This code is distributed under the terms of the GPL
11 # enable only the following on debugging purpose
13 use CGI
:: Carp
'fatalsToBrowser' ;
15 require '/var/ipfire/general-functions.pl' ;
16 require "${General::swroot}/lang.pl" ;
17 require "${General::swroot}/header.pl" ;
19 my %extrahdsettings = ();
21 my $errormessage = "" ;
34 my @partitionline = ();
35 my $partitionentry = "" ;
36 my $devicefile = "/var/ipfire/extrahd/devices" ;
37 my $scanfile = "/var/ipfire/extrahd/scan" ;
38 my $partitionsfile = "/var/ipfire/extrahd/partitions" ;
39 system ( "/usr/local/bin/scanhd ide" );
40 system ( "/usr/local/bin/scanhd partitions" );
42 & Header
:: showhttpheaders
();
44 ### Values that have to be initialized
45 $extrahdsettings { 'PATH' } = '' ;
46 $extrahdsettings { 'FS' } = '' ;
47 $extrahdsettings { 'DEVICE' } = '' ;
48 $extrahdsettings { 'ACTION' } = '' ;
50 & General
:: readhash
( "${General::swroot}/extrahd/settings" , \
%extrahdsettings );
51 & Header
:: getcgihash
( \
%extrahdsettings );
53 & Header
:: openpage
( 'ExtraHD' , 1 , '' );
54 & Header
:: openbigbox
( '100%' , 'left' , '' , $errormessage );
56 ############################################################################################################################
57 ############################################################################################################################
59 if ( $extrahdsettings { 'ACTION' } eq $Lang :: tr
{ 'add' })
61 open ( FILE
, "< $devicefile " ) or die "Unable to read $devicefile " ;
64 foreach $deviceentry ( sort @devices )
66 @deviceline = split ( /\;/ , $deviceentry );
67 if ( " $extrahdsettings {'PATH'}" eq " $deviceline [2]" ) {
69 $errormessage = "You can't mount $extrahdsettings {'DEVICE'} to $extrahdsettings {'PATH'}, because there is already a device mounted." ;
71 if ( " $extrahdsettings {'PATH'}" eq "/" ) {
73 $errormessage = "You can't mount $extrahdsettings {'DEVICE'} to root /." ;
77 if ( " $ok " eq "true" ) {
78 open ( FILE
, ">> $devicefile " ) or die "Unable to write $devicefile " ;
80 $extrahdsettings {'DEVICE'}; $extrahdsettings {'FS'}; $extrahdsettings {'PATH'};
83 system ( "/usr/local/bin/extrahdctrl mount $extrahdsettings {'PATH'}" );
86 elsif ( $extrahdsettings { 'ACTION' } eq $Lang :: tr
{ 'delete' })
88 if ( `/usr/local/bin/extrahdctrl umount $extrahdsettings {'PATH'}` ) {
89 open ( FILE
, "< $devicefile " ) or die "Unable to read $devicefile " ;
92 open ( FILE
, "> $devicefile " ) or die "Unable to write $devicefile " ;
93 foreach $deviceentry ( sort @tmp )
95 @tmpline = split ( /\;/ , $deviceentry );
96 if ( $tmpline [ 2 ] ne $extrahdsettings { 'PATH' } )
98 print FILE
$deviceentry ;
103 $errormessage = "Can't umount $extrahdsettings {'PATH'}. Maybe the device is in use?" ;
108 & Header
:: openbox
( '100%' , 'left' , $Lang :: tr
{ 'error messages' });
109 print "<class name='base'> $errormessage \n " ;
110 print " </class> \n " ;
114 ############################################################################################################################
115 ############################################################################################################################
117 & Header
:: openbox
( '100%' , 'center' , 'ExtraHD' );
118 open ( FILE
, "< $devicefile " ) or die "Unable to read $devicefile " ;
122 <table border='0' width='600' cellspacing="0">
125 foreach $deviceentry ( sort @devices )
127 @deviceline = split ( /\;/ , $deviceentry );
128 my $color = " $Header ::colourred" ;
129 if ( `/bin/mount | /bin/fgrep $deviceline [2] | /bin/fgrep /dev/ $deviceline [0]` ) {
130 $color = $Header :: colourgreen
;
133 <tr><td colspan="5">
134 <tr><td align='center'><font color= $color ><b>/dev/ $deviceline [0]</b></font>
135 <td align='center'> $deviceline [1]
136 <td align='center'> $deviceline [2]
138 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
139 <input type='hidden' name='DEVICE' value=' $deviceline [0]' />
140 <input type='hidden' name='FS' value=' $deviceline [1]' />
141 <input type='hidden' name='PATH' value=' $deviceline [2]' />
142 <input type='hidden' name='ACTION' value= $Lang ::tr{'delete'} />
143 <input type='image' alt= $Lang ::tr{'delete'} src='/images/delete.gif' />
155 & Header
:: openbox
( '100%' , 'center' , 'Gefundene Laufwerke' );
157 <table border='0' width='600' cellspacing="0">
160 open ( FILE
, "< $scanfile " ) or die "Unable to read $scanfile " ;
163 open ( FILE
, "< $partitionsfile " ) or die "Unable to read $partitionsfile " ;
164 @partitions = < FILE
>;
166 foreach $scanentry ( sort @scans )
168 @scanline = split ( /\;/ , $scanentry );
170 <tr><td colspan="5">
171 <tr><td align='center'><b>/dev/ $scanline [0]</b>
172 <td align='center' colspan="2"> $scanline [1]
175 foreach $partitionentry ( sort @partitions )
177 @partitionline = split ( /\;/ , $partitionentry );
178 if ( " $partitionline [0]" eq " $scanline [0]" ) {
179 $size = int ( $partitionline [ 1 ] / 1024 );
181 <td align='center'> $Lang ::tr{'size'} $size MB
183 <tr><td colspan="5">
189 foreach $partitionentry ( sort @partitions )
191 @partitionline = split ( /\;/ , $partitionentry );
192 if (( " $partitionline [0]" =~ /^$scanline[0]/ ) && ! ( " $partitionline [0]" eq " $scanline [0]" )) {
193 $size = int ( $partitionline [ 1 ] / 1024 );
195 <form method='post' action=' $ENV {'SCRIPT_NAME'}'>
196 <tr><td align="center">/dev/ $partitionline [0]
197 <td align="center"> $Lang ::tr{'size'} $size MB
198 <td align='center'><select name="FS">
199 <option value="auto">auto</option>
200 <option value="ext3">ext3</option>
201 <option value="reiserfs">reiserfs</option>
202 <option value="vfat">fat</option>
203 <option value="ntfs-3g">ntfs (experimental)</option>
205 <td align="center"><input type='text' name='PATH' value=/mnt/harddisk />
207 <input type='hidden' name='DEVICE' value=' $partitionline [0]' />
208 <input type='hidden' name='ACTION' value= $Lang ::tr{'add'} />
209 <input type='image' alt= $Lang ::tr{'add'} src='/images/add.gif' />
219 <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.
225 & Header
:: closebigbox
();
226 & Header
:: closepage
();