language changes in Menu and on statuspage (index.cgi)
[people/teissler/ipfire-2.x.git] / html / cgi-bin / index.cgi
CommitLineData
ac1cfefa 1#!/usr/bin/perl
70df8302
MT
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
b81b96d2 5# Copyright (C) 2007-2012 IPFire Team <info@ipfire.org> #
70df8302
MT
6# #
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. #
11# #
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. #
16# #
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/>. #
19# #
20###############################################################################
ac1cfefa
MT
21
22use strict;
54fd0535 23use Net::Telnet;
ac1cfefa
MT
24
25# enable only the following on debugging purpose
cb5e9c6c
CS
26#use warnings;
27#use CGI::Carp 'fatalsToBrowser';
ac1cfefa 28
e383179b 29require '/var/ipfire/general-functions.pl';
ac1cfefa
MT
30require "${General::swroot}/lang.pl";
31require "${General::swroot}/header.pl";
2b38ab5c 32require "/opt/pakfire/lib/functions.pl";
ac1cfefa
MT
33
34my %cgiparams=();
35my %pppsettings=();
36my %modemsettings=();
37my %netsettings=();
38my %ddnssettings=();
39my $warnmessage = '';
c85ec3b4 40my $refresh = "";
e383179b 41my $ipaddr='';
ac1cfefa 42
043cfbc0
AM
43my $haveipsec=0;
44my $haveovpn=0;
337305ef 45
ac1cfefa
MT
46&Header::showhttpheaders();
47
48$cgiparams{'ACTION'} = '';
49&Header::getcgihash(\%cgiparams);
50$pppsettings{'VALID'} = '';
51$pppsettings{'PROFILENAME'} = 'None';
52&General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
53&General::readhash("${General::swroot}/modem/settings", \%modemsettings);
54&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
55&General::readhash("${General::swroot}/ddns/settings", \%ddnssettings);
56
f2fdd0c1
CS
57my %color = ();
58my %mainsettings = ();
59&General::readhash("${General::swroot}/main/settings", \%mainsettings);
60&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
61
ac1cfefa 62my $connstate = &Header::connectionstatus();
56b7a3e2 63
e85d32bb 64 if ( -e "/var/ipfire/main/gpl-accepted" ) {
043cfbc0 65if ($connstate =~ /$Lang::tr{'connecting'}/ || /$Lang::tr{'connection closed'}/ ){
ac1cfefa 66 $refresh = "<meta http-equiv='refresh' content='5;'>";
56b7a3e2
CS
67} elsif ($connstate =~ /$Lang::tr{'dod waiting'}/ || -e "${General::swroot}/main/refreshindex") {
68 $refresh = "<meta http-equiv='refresh' content='30;'>";
ac1cfefa 69}
f341a168 70}
ac1cfefa 71
957363eb
CS
72if ($cgiparams{'ACTION'} eq $Lang::tr{'dial profile'})
73{
74 my $profile = $cgiparams{'PROFILE'};
75 my %tempcgiparams = ();
76 $tempcgiparams{'PROFILE'} = '';
77 &General::readhash("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}",
78 \%tempcgiparams);
79
80 # make a link from the selected profile to the "default" one.
81 unlink("${General::swroot}/ppp/settings");
82 link("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}",
83 "${General::swroot}/ppp/settings");
84 system ("/usr/bin/touch", "${General::swroot}/ppp/updatesettings");
85
86 # read in the new params "early" so we can write secrets.
87 %cgiparams = ();
88 &General::readhash("${General::swroot}/ppp/settings", \%cgiparams);
89 $cgiparams{'PROFILE'} = $profile;
90 $cgiparams{'BACKUPPROFILE'} = $profile;
91 &General::writehash("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}",
92 \%cgiparams);
93
94 # write secrets file.
95 open(FILE, ">/${General::swroot}/ppp/secrets") or die "Unable to write secrets file.";
96 flock(FILE, 2);
97 my $username = $cgiparams{'USERNAME'};
98 my $password = $cgiparams{'PASSWORD'};
99 print FILE "'$username' * '$password'\n";
100 chmod 0600, "${General::swroot}/ppp/secrets";
101 close FILE;
102
103 &General::log("$Lang::tr{'profile made current'} $tempcgiparams{'PROFILENAME'}");
104 $cgiparams{'ACTION'} = "$Lang::tr{'dial'}";
105}
106
107if ($cgiparams{'ACTION'} eq $Lang::tr{'dial'}) {
a56b5be4 108 system('/usr/local/bin/redctrl start > /dev/null') == 0
957363eb
CS
109 or &General::log("Dial failed: $?"); sleep 1;}
110elsif ($cgiparams{'ACTION'} eq $Lang::tr{'hangup'}) {
a56b5be4 111 system('/usr/local/bin/redctrl stop > /dev/null') == 0
957363eb
CS
112 or &General::log("Hangup failed: $?"); sleep 1;}
113
e383179b
MT
114my $c;
115my $maxprofiles = 5;
116my @profilenames = ();
117
118for ($c = 1; $c <= $maxprofiles; $c++)
119{
120 my %temppppsettings = ();
121 $temppppsettings{'PROFILENAME'} = '';
122 &General::readhash("${General::swroot}/ppp/settings-$c", \%temppppsettings);
123 $profilenames[$c] = $temppppsettings{'PROFILENAME'};
124}
125my %selected;
126for ($c = 1; $c <= $maxprofiles; $c++) {
127 $selected{'PROFILE'}{$c} = '';
128}
129$selected{'PROFILE'}{$pppsettings{'PROFILE'}} = "selected='selected'";
130my $dialButtonDisabled = "disabled='disabled'";
131
132
ac1cfefa
MT
133&Header::openpage($Lang::tr{'main page'}, 1, $refresh);
134&Header::openbigbox('', 'center');
ac1cfefa 135
7fa7c7dd 136# licence agreement
0cac94cc 137if ($cgiparams{'ACTION'} eq $Lang::tr{'yes'} && $cgiparams{'gpl_accepted'} eq '1') {
7fa7c7dd
JPT
138 system('touch /var/ipfire/main/gpl_accepted')
139}
f341a168 140if ( -e "/var/ipfire/main/gpl_accepted" ) {
043cfbc0 141&Header::openbox('100%', 'center', '');
3489ebac
MT
142
143
a08a5f33 144if ( ( $pppsettings{'VALID'} eq 'yes' && $modemsettings{'VALID'} eq 'yes' ) || ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ )) {
986e08d9
MT
145 if (open(IPADDR,"${General::swroot}/ddns/ipcache")) {
146 $ipaddr = <IPADDR>;
147 close IPADDR;
148 chomp ($ipaddr);
149 }
150 if (open(IPADDR,"${General::swroot}/red/local-ipaddress")) {
786f2c8a 151 $ipaddr = <IPADDR>;
986e08d9
MT
152 close IPADDR;
153 chomp ($ipaddr);
154 }
ac1cfefa
MT
155} elsif ($modemsettings{'VALID'} eq 'no') {
156 print "$Lang::tr{'modem settings have errors'}\n </b></font>\n";
157} else {
158 print "$Lang::tr{'profile has errors'}\n </b></font>\n";
159}
160
a56b5be4 161print <<END;
e383179b 162<!-- Table of networks -->
043cfbc0 163<table width=80% class='tbl'>
e5d406ab 164 <tr> <th bgcolor='$color{'color20'}'>$Lang::tr{'network'}</th>
4bf6a597 165 <th bgcolor='$color{'color20'}'>$Lang::tr{'ip address'}</th>
e5d406ab
EK
166 <th bgcolor='$color{'color20'}'>$Lang::tr{'status'}</th></tr>
167 <tr> <td align='center' bgcolor='$Header::colourred' width='25%'><a href="/cgi-bin/pppsetup.cgi"><font size='2' color='white'><b>$Lang::tr{'internet'}</b></font></a><br></td>
168 <td width='30%' align='center'>$ipaddr </td>
169 <td width='45%' align='center'>$connstate
f3bbb213 170END
043cfbc0
AM
171 my $HOSTNAME = (gethostbyaddr(pack("C4", split(/\./, $ipaddr)), 2))[0];
172 if ( "$HOSTNAME" ne "" ) {
173 print <<END;
174 <tr><td><b>Hostname:</b><td align='center'>$HOSTNAME<td>&nbsp;
175END
176 }
177
178 if ( -e "/var/ipfire/red/remote-ipaddress" ) {
179 my $GATEWAY = `cat /var/ipfire/red/remote-ipaddress`;
180 chomp($GATEWAY);
181 print <<END;
182 <tr><td><b>Gateway:</b><td align='center'>$GATEWAY<td>&nbsp;
183END
184 }
185
186 my $DNS1 = `cat /var/ipfire/red/dns1`;
187 my $DNS2 = `cat /var/ipfire/red/dns2`;
188 chomp($DNS1);
189 chomp($DNS1);
190
191 if ( $DNS1 ) { print <<END;
192 <tr><td><b>DNS-Server:</b><td align='center'>$DNS1
193END
194 }
195 if ( $DNS2 ) { print <<END;
196 <td align='center'>$DNS2
197END
198 } else { print <<END;
199 <td>&nbsp;</td>
200 </tr>
201 </table>
202END
203 }
204
205#Dial profiles
c85ec3b4 206if ( $netsettings{'RED_TYPE'} ne "STATIC" && $netsettings{'RED_TYPE'} ne "DHCP" ){
f3bbb213
MT
207print `/usr/local/bin/dialctrl.pl show`;
208print <<END;
043cfbc0
AM
209<br>
210 <table width='80%'>
211 <tr><td>
957363eb 212 <form method='post' action='$ENV{'SCRIPT_NAME'}'>$Lang::tr{'profile'}:
e383179b
MT
213 <select name='PROFILE'>
214END
215 for ($c = 1; $c <= $maxprofiles; $c++)
216 {
217 if ($profilenames[$c] ne '') {
218 $dialButtonDisabled = "";
219 print "\t<option value='$c' $selected{'PROFILE'}{$c}>$c. $profilenames[$c]</option>\n";
220 }
221 }
c6aa4ac1 222 $dialButtonDisabled = "disabled='disabled'" if (-e '/var/run/ppp-ipfire.pid' || -e "${General::swroot}/red/active");
a08a5f33 223 if ( ( $pppsettings{'VALID'} eq 'yes' ) || ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) ) {
e383179b
MT
224 print <<END;
225 </select>
226 <input type='submit' name='ACTION' value='$Lang::tr{'dial profile'}' $dialButtonDisabled />
227 </form>
228 <td align='center'>
229 <table width='100%' border='0'>
230 <tr>
957363eb 231 <td width='50%' align='right'> <form method='post' action='$ENV{'SCRIPT_NAME'}'>
e383179b
MT
232 <input type='submit' name='ACTION' value='$Lang::tr{'dial'}'>
233 </form>
957363eb 234 <td width='50%' align='left'> <form method='post' action='$ENV{'SCRIPT_NAME'}'>
e383179b
MT
235 <input type='submit' name='ACTION' value='$Lang::tr{'hangup'}'>
236 </form>
237 </table>
238END
239 } else {
240 print "$Lang::tr{'profile has errors'}\n </b></font>\n";
241 }
043cfbc0 242 print"</tr></table>";
c85ec3b4 243}
043cfbc0
AM
244 if ( $netsettings{'GREEN_DEV'} ) {
245 my $sub=&General::iporsubtocidr($netsettings{'GREEN_NETMASK'});
786f2c8a 246 print <<END;
043cfbc0
AM
247 <br>
248 <table width='80%' class='tbl'>
249 <tr>
250 <th>$Lang::tr{'network'}</th>
4bf6a597 251 <th>$Lang::tr{'ip address'}</th>
043cfbc0
AM
252 <th>$Lang::tr{'status'}</th>
253 </tr>
33e1f48c 254 <tr><td align='center' bgcolor='$Header::colourgreen' width='25%'><a href="/cgi-bin/dhcp.cgi"><font size='2' color='white'><b>$Lang::tr{'lan'}</b></font></a>
043cfbc0
AM
255 <td width='30%' align='center'>$netsettings{'GREEN_ADDRESS'}/$sub
256 <td width='45%' align='center'>
e383179b 257END
072cd997 258 if ( `cat /var/ipfire/proxy/advanced/settings | grep ^ENABLE=on` ) {
ef482d53 259 print $Lang::tr{'advproxy on'};
072cd997 260 if ( `cat /var/ipfire/proxy/advanced/settings | grep ^TRANSPARENT=on` ) { print " (transparent)"; }
ef482d53 261 } else { print $Lang::tr{'advproxy off'}; }
072cd997 262 }
043cfbc0
AM
263 if ( $netsettings{'BLUE_DEV'} ) {
264 my $sub=&General::iporsubtocidr($netsettings{'BLUE_NETMASK'});
265 print <<END;
33e1f48c 266 <tr><td align='center' bgcolor='$Header::colourblue' width='25%'><a href="/cgi-bin/wireless.cgi"><font size='2' color='white'><b>$Lang::tr{'wireless'}</b></font></a><br>
043cfbc0
AM
267 <td width='30%' align='center'>$netsettings{'BLUE_ADDRESS'}/$sub
268 <td width='45%' align='center'>
e383179b 269END
072cd997 270 if ( `cat /var/ipfire/proxy/advanced/settings | grep ^ENABLE_BLUE=on` ) {
ef482d53 271 print $Lang::tr{'advproxy on'};
072cd997 272 if ( `cat /var/ipfire/proxy/advanced/settings | grep ^TRANSPARENT_BLUE=on` ) { print " (transparent)"; }
ef482d53 273 } else { print $Lang::tr{'advproxy off'}; }
072cd997 274 }
043cfbc0
AM
275 if ( $netsettings{'ORANGE_DEV'} ) {
276 my $sub=&General::iporsubtocidr($netsettings{'ORANGE_NETMASK'});
277 print <<END;
b161bfa8 278 <tr><td align='center' bgcolor='$Header::colourorange' width='25%'><a href="/cgi-bin/firewall.cgi"><font size='2' color='white'><b>$Lang::tr{'dmz'}</b></font></a><br>
043cfbc0
AM
279 <td width='30%' align='center'>$netsettings{'ORANGE_ADDRESS'}/$sub
280 <td width='45%' align='center'><font color=$Header::colourgreen>Online</font>
281END
282 }
283#check if IPSEC is running
284if ( `cat /var/ipfire/vpn/settings | grep ^ENABLED=on` ||
285 `cat /var/ipfire/vpn/settings | grep ^ENABLED_BLUE=on` ) {
286 $haveipsec=1;
287 my $ipsecip = `cat /var/ipfire/vpn/settings | grep ^VPN_IP= | cut -c 8-`;
288print<<END;
f536ab26 289 <tr><td align='center' bgcolor='$Header::colourvpn' width='25%'><a href="/cgi-bin/vpnmain.cgi"><font size='2' color='white'><b>$Lang::tr{'ipsec'}</b></font></a><br>
043cfbc0
AM
290 <td width='30%' align='center'>$ipsecip
291 <td width='45%' align='center'><font color=$Header::colourgreen>Online</font>
292END
293}
294
295#check if OpenVPN is running
296my %confighash=();
297&General::readhash("${General::swroot}/ovpn/settings", \%confighash);
298
299if (($confighash{'ENABLED'} eq "on") ||
300 ($confighash{'ENABLED_BLUE'} eq "on") ||
301 ($confighash{'ENABLED_ORANGE'} eq "on")) {
302 my ($ovpnip,$sub) = split("/",$confighash{'DOVPN_SUBNET'});
303 $sub=&General::iporsubtocidr($sub);
304 $ovpnip="$ovpnip/$sub";
305 $haveovpn=1;
306print <<END;
307 <tr>
308 <td align='center' bgcolor='$Header::colourovpn' width='25%'>
309 <a href="/cgi-bin/ovpnmain.cgi"><font size='2' color='white'><b>OpenVPN</b></font></a><br>
310 </td>
311 <td width='30%' align='center'>$ovpnip
312 <td width='45%' align='center'><font color=$Header::colourgreen>Online</font>
e383179b 313END
072cd997 314 }
043cfbc0
AM
315print"</td></tr></table>";
316&Header::closebox();
317
318# Start of Box wich contains all vpn connections
319 &Header::openbox('100%', 'center', $Lang::tr{'vpn'}) if ($haveipsec || $haveovpn);
320
321#show ipsec connectiontable
322 if ( $haveipsec ) {
072cd997 323 my $ipsecip = `cat /var/ipfire/vpn/settings | grep ^VPN_IP= | cut -c 8-`;
db073a10 324 my @status = `/usr/local/bin/ipsecctrl I`;
e455cafe
MT
325 my %confighash = ();
326 &General::readhasharray("${General::swroot}/vpn/config", \%confighash);
072cd997 327 print <<END;
043cfbc0
AM
328 <br>
329 <table width='80%' class='tbl'>
330 <tr>
331 <th>$Lang::tr{'ipsec network'}</th>
4bf6a597 332 <th>$Lang::tr{'ip address'}</th>
043cfbc0
AM
333 <th>$Lang::tr{'status'}</th>
334 </tr>
e383179b 335END
e455cafe
MT
336 my $id = 0;
337 my $gif;
043cfbc0 338 my $col="";
542b31d6 339 foreach my $key (sort { uc($confighash{$a}[1]) cmp uc($confighash{$b}[1]) } keys %confighash) {
e455cafe 340 if ($confighash{$key}[0] eq 'on') { $gif = 'on.gif'; } else { $gif = 'off.gif'; }
4bf6a597
AM
341 my ($vpnip,$vpnsub) = split("/",$confighash{$key}[11]);
342 $vpnsub=&General::iporsubtocidr($vpnsub);
343 $vpnip="$vpnip/$vpnsub";
e455cafe 344 if ($id % 2) {
043cfbc0 345 $col="bgcolor='$color{'color20'}'";
4bf6a597 346 print "<tr><td align='left' nowrap='nowrap' bgcolor='$Header::colourvpn' width='50%'><font color=white>$confighash{$key}[1] / " . $Lang::tr{"$confighash{$key}[3]"} . " (" . $Lang::tr{"$confighash{$key}[4]"} . ")</td><td align='center' $col>$vpnip</td>";
e455cafe 347 } else {
043cfbc0 348 $col="bgcolor='$color{'color22'}'";
4bf6a597 349 print "<tr></td><td align='left' nowrap='nowrap' bgcolor='$Header::colourvpn' width='50%'><font color=white>$confighash{$key}[1] / " . $Lang::tr{"$confighash{$key}[3]"} . " (" . $Lang::tr{"$confighash{$key}[4]"} . ")</td><td align='center' $col>$vpnip</td>";
e455cafe 350 }
fe6cda92 351
043cfbc0 352 my $active = "<td bgcolor='${Header::colourred}' width='15%' align='center'><b><font color='#FFFFFF'>$Lang::tr{'capsclosed'}</font></b></td>";
e455cafe 353 if ($confighash{$key}[0] eq 'off') {
043cfbc0 354 $active = "<td bgcolor='${Header::colourblue}' width='15%' align='center'><b><font color='#FFFFFF'>$Lang::tr{'capsclosed'}</font></b></td>";
e455cafe
MT
355 } else {
356 foreach my $line (@status) {
4b4b8959 357 if (($line =~ /\"$confighash{$key}[1]\".*IPsec SA established/) ||
264c0195 358 ($line =~/$confighash{$key}[1]\{.*INSTALLED/ ))
4b4b8959 359 {
f2fdd0c1 360 $active = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourgreen}' width='100%'><tr><td align='center'><b><font color='#FFFFFF'>$Lang::tr{'capsopen'}</font></b></td></tr></table>";
e455cafe
MT
361 }
362 }
363 }
043cfbc0 364 print "$active</td>";
e455cafe 365 }
043cfbc0 366 print "</tr></table>";
072cd997 367 }
4715ddb3
SS
368
369###
370# Check if there is any OpenVPN connection configured.
371###
372
043cfbc0
AM
373if ( $haveovpn )
374{
4715ddb3 375 print <<END;
043cfbc0
AM
376 <br>
377 <table width='80%' class='tbl'>
4715ddb3 378 <tr>
043cfbc0 379 <th>$Lang::tr{'openvpn network'}</th>
4bf6a597 380 <th>$Lang::tr{'ip address'}</th>
043cfbc0 381 <th>$Lang::tr{'status'}</th>
4715ddb3
SS
382END
383 # Check if the OpenVPN server for Road Warrior Connections is running and display status information.
384 my %confighash=();
385
386 &General::readhash("${General::swroot}/ovpn/settings", \%confighash);
4715ddb3
SS
387 # Print the OpenVPN N2N connection status.
388 if ( -d "${General::swroot}/ovpn/n2nconf") {
389 my %confighash=();
390
391 &General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%confighash);
043cfbc0
AM
392 my $lines;
393 my $col="";
4715ddb3 394 foreach my $dkey (keys %confighash) {
043cfbc0 395 $lines++;
4715ddb3
SS
396 if (($confighash{$dkey}[3] eq 'net') && (-e "/var/run/$confighash{$dkey}[1]n2n.pid")) {
397 my $tport = $confighash{$dkey}[22];
398 next if ($tport eq '');
399
400 my $tnet = new Net::Telnet ( Timeout=>5, Errmode=>'return', Port=>$tport);
401 $tnet->open('127.0.0.1');
402 my @output = $tnet->cmd(String => 'state', Prompt => '/(END.*\n|ERROR:.*\n)/');
403 my @tustate = split(/\,/, $output[1]);
404
405 my $display;
406 my $display_colour = $Header::colourred;
407 if ( $tustate[1] eq 'CONNECTED') {
408 $display_colour = $Header::colourgreen;
409 $display = $Lang::tr{'capsopen'};
410 } else {
411 $display = $tustate[1];
412 }
043cfbc0
AM
413 if ($lines %2){
414 $col="bgcolor='$color{'color20'}'";
415 }else{
416 $col="bgcolor='$color{'color22'}'";
417 }
4bf6a597
AM
418 #make cidr from ip
419 my ($vpnip,$vpnsub) = split("/",$confighash{$dkey}[11]);
420 my $vpnsub=&General::iporsubtocidr($vpnsub);
421 my $vpnip="$vpnip/$vpnsub";
4715ddb3
SS
422 print <<END;
423 <tr>
043cfbc0 424 <td align='left' nowrap='nowrap' bgcolor='$Header::colourovpn' width='50%'><font color=white>
4715ddb3
SS
425 $confighash{$dkey}[1]
426 </td>
043cfbc0 427 <td align='center' $col>
4bf6a597 428 $vpnip
4715ddb3 429 </td>
043cfbc0 430 <td align='center' bgcolor='$display_colour' width='15%'>
4715ddb3
SS
431 <b>
432 <font color='#FFFFFF'>
433 $display
434 </font>
435 </b>
436 </td>
437 </tr>
54fd0535 438END
4715ddb3 439 }
acb305f5
MT
440 }
441 }
54fd0535 442}
043cfbc0 443&Header::closebox();
579a39d0
MT
444# Fireinfo
445if ( ! -e "/var/ipfire/main/send_profile") {
446 $warnmessage .= "<li><a style='color: white;' href='fireinfo.cgi'>$Lang::tr{'fireinfo please enable'}</a></li>";
447}
448
ac1cfefa
MT
449# Memory usage warning
450my @free = `/usr/bin/free`;
451$free[1] =~ m/(\d+)/;
452my $mem = $1;
453$free[2] =~ m/(\d+)/;
454my $used = $1;
455my $pct = int 100 * ($mem - $used) / $mem;
456if ($used / $mem > 90) {
457 $warnmessage .= "<li> $Lang::tr{'high memory usage'}: $pct% !</li>\n";
458}
459
460# Diskspace usage warning
461my @temp=();
462my $temp2=();
8955b5a7 463my @df = `/bin/df -B M -P -x rootfs`;
ac1cfefa
MT
464foreach my $line (@df) {
465 next if $line =~ m/^Filesystem/;
466 if ($line =~ m/root/ ) {
467 $line =~ m/^.* (\d+)M.*$/;
468 @temp = split(/ +/,$line);
469 if ($1<5) {
470 # available:plain value in MB, and not %used as 10% is too much to waste on small disk
471 # and root size should not vary during time
62f1526a 472 $warnmessage .= "<li> $Lang::tr{'filesystem full'}: $temp[0] <b>$Lang::tr{'free'}=$1M</b> !</li>\n";
ac1cfefa
MT
473 }
474
475 } else {
476 # $line =~ m/^.* (\d+)m.*$/;
477 $line =~ m/^.* (\d+)\%.*$/;
478 if ($1>90) {
479 @temp = split(/ /,$line);
480 $temp2=int(100-$1);
62f1526a 481 $warnmessage .= "<li> $Lang::tr{'filesystem full'}: $temp[0] <b>$Lang::tr{'free'}=$temp2%</b> !</li>\n";
ac1cfefa
MT
482 }
483 }
484}
485
c1712013 486# S.M.A.R.T. health warning
73c7eff8 487my @files = `/bin/ls /var/run/smartctl_out_hddtemp-* 2>/dev/null`;
c1712013
AF
488foreach my $file (@files) {
489 chomp ($file);
490 my $disk=`echo $file | cut -d"-" -f2`;
491 chomp ($disk);
492 if (`/bin/grep "SAVE ALL DATA" $file`) {
62f1526a 493 $warnmessage .= "<li> $Lang::tr{'smartwarn1'} /dev/$disk $Lang::tr{'smartwarn2'} !</li>\n\n";
c1712013
AF
494 }
495}
496
b81b96d2
AF
497# Reiser4 warning
498my @files = `mount | grep " reiser4 (" 2>/dev/null`;
499foreach my $disk (@files) {
500 chomp ($disk);
501 $warnmessage .= "<li>$disk - $Lang::tr{'deprecated fs warn'}</li>\n\n";
502}
503
504
ac1cfefa 505if ($warnmessage) {
02dc0a76 506 print "<tr><td align='center' bgcolor=$Header::colourred colspan='3'><font color='white'>$warnmessage</font></table>";
ac1cfefa 507}
02dc0a76
MT
508print <<END;
509</table>
2b38ab5c
JPT
510END
511;
512&Pakfire::dblist("upgrade", "notice");
513print <<END;
02dc0a76 514END
f341a168 515if ( -e "/var/run/need_reboot" ) {
7274a673 516 print "<br /><br /><font color='red'>$Lang::tr{'needreboot'}!</font>";
337305ef 517}
ac1cfefa 518&Header::closebox();
7fa7c7dd
JPT
519}
520
521else {
522&Header::openbox('100%', 'left', $Lang::tr{'gpl license agreement'});
523print <<END;
7fa7c7dd
JPT
524 $Lang::tr{'gpl please read carefully the general public license and accept it below'}.
525 <br /><br />
7274a673
JPT
526END
527;
f341a168 528if ( -e "/usr/share/doc/licenses/GPLv3" ) {
7274a673
JPT
529 print '<textarea rows=\'25\' cols=\'75\' readonly=\'true\'>';
530 print `cat /usr/share/doc/licenses/GPLv3`;
92209271 531 print '</textarea>';
7274a673
JPT
532}
533else {
92209271 534 print '<br /><a href=\'http://www.gnu.org/licenses/gpl-3.0.txt\' target=\'_blank\'>GNU GENERAL PUBLIC LICENSE</a><br />';
7274a673
JPT
535}
536print <<END;
7fa7c7dd
JPT
537 <p>
538 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
539 <input type='checkbox' name='gpl_accepted' value='1'/> $Lang::tr{'gpl i accept these terms and conditions'}.
540 <br/ >
541 <input type='submit' name='ACTION' value=$Lang::tr{'yes'} />
542 </form>
543 </p>
7274a673 544 <a href='http://www.gnu.org/licenses/translations.html' target='_blank'>$Lang::tr{'gpl unofficial translation of the general public license v3'}</a>
7fa7c7dd
JPT
545
546END
547
548&Header::closebox();
549}
550
ac1cfefa 551&Header::closebigbox();
ac1cfefa 552&Header::closepage();