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