]>
Commit | Line | Data |
---|---|---|
ac1cfefa | 1 | #!/usr/bin/perl |
70df8302 MT |
2 | ############################################################################### |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2007 Michael Tremer & Christian Schmidt # | |
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 | |
22 | use strict; | |
23 | ||
24 | # enable only the following on debugging purpose | |
cb5e9c6c CS |
25 | #use warnings; |
26 | #use CGI::Carp 'fatalsToBrowser'; | |
ac1cfefa | 27 | |
e383179b | 28 | require '/var/ipfire/general-functions.pl'; |
ac1cfefa MT |
29 | require "${General::swroot}/lang.pl"; |
30 | require "${General::swroot}/header.pl"; | |
2b38ab5c | 31 | require "/opt/pakfire/lib/functions.pl"; |
ac1cfefa MT |
32 | |
33 | my %cgiparams=(); | |
34 | my %pppsettings=(); | |
35 | my %modemsettings=(); | |
36 | my %netsettings=(); | |
37 | my %ddnssettings=(); | |
38 | my $warnmessage = ''; | |
c85ec3b4 | 39 | my $refresh = ""; |
e383179b | 40 | my $ipaddr=''; |
ac1cfefa | 41 | |
337305ef | 42 | |
ac1cfefa MT |
43 | &Header::showhttpheaders(); |
44 | ||
45 | $cgiparams{'ACTION'} = ''; | |
46 | &Header::getcgihash(\%cgiparams); | |
47 | $pppsettings{'VALID'} = ''; | |
48 | $pppsettings{'PROFILENAME'} = 'None'; | |
49 | &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); | |
50 | &General::readhash("${General::swroot}/modem/settings", \%modemsettings); | |
51 | &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); | |
52 | &General::readhash("${General::swroot}/ddns/settings", \%ddnssettings); | |
53 | ||
f2fdd0c1 CS |
54 | my %color = (); |
55 | my %mainsettings = (); | |
56 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
57 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
58 | ||
ac1cfefa | 59 | my $connstate = &Header::connectionstatus(); |
56b7a3e2 | 60 | |
337305ef JPT |
61 | # check if reboot is necessary |
62 | my $reboot = 0; | |
63 | if (`find /var/run/need_reboot 2>/dev/null`) { | |
64 | $reboot = 1; | |
65 | } | |
66 | ||
56b7a3e2 CS |
67 | if ($cgiparams{'ACTION'} eq $Lang::tr{'shutdown'} || $cgiparams{'ACTION'} eq $Lang::tr{'reboot'}) { |
68 | $refresh = "<meta http-equiv='refresh' content='300;'>"; | |
8a5898e7 | 69 | } elsif ($connstate =~ /$Lang::tr{'connecting'}/ || /$Lang::tr{'connection closed'}/ ){ |
ac1cfefa | 70 | $refresh = "<meta http-equiv='refresh' content='5;'>"; |
56b7a3e2 CS |
71 | } elsif ($connstate =~ /$Lang::tr{'dod waiting'}/ || -e "${General::swroot}/main/refreshindex") { |
72 | $refresh = "<meta http-equiv='refresh' content='30;'>"; | |
ac1cfefa MT |
73 | } |
74 | ||
957363eb CS |
75 | if ($cgiparams{'ACTION'} eq $Lang::tr{'dial profile'}) |
76 | { | |
77 | my $profile = $cgiparams{'PROFILE'}; | |
78 | my %tempcgiparams = (); | |
79 | $tempcgiparams{'PROFILE'} = ''; | |
80 | &General::readhash("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}", | |
81 | \%tempcgiparams); | |
82 | ||
83 | # make a link from the selected profile to the "default" one. | |
84 | unlink("${General::swroot}/ppp/settings"); | |
85 | link("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}", | |
86 | "${General::swroot}/ppp/settings"); | |
87 | system ("/usr/bin/touch", "${General::swroot}/ppp/updatesettings"); | |
88 | ||
89 | # read in the new params "early" so we can write secrets. | |
90 | %cgiparams = (); | |
91 | &General::readhash("${General::swroot}/ppp/settings", \%cgiparams); | |
92 | $cgiparams{'PROFILE'} = $profile; | |
93 | $cgiparams{'BACKUPPROFILE'} = $profile; | |
94 | &General::writehash("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}", | |
95 | \%cgiparams); | |
96 | ||
97 | # write secrets file. | |
98 | open(FILE, ">/${General::swroot}/ppp/secrets") or die "Unable to write secrets file."; | |
99 | flock(FILE, 2); | |
100 | my $username = $cgiparams{'USERNAME'}; | |
101 | my $password = $cgiparams{'PASSWORD'}; | |
102 | print FILE "'$username' * '$password'\n"; | |
103 | chmod 0600, "${General::swroot}/ppp/secrets"; | |
104 | close FILE; | |
105 | ||
106 | &General::log("$Lang::tr{'profile made current'} $tempcgiparams{'PROFILENAME'}"); | |
107 | $cgiparams{'ACTION'} = "$Lang::tr{'dial'}"; | |
108 | } | |
109 | ||
110 | if ($cgiparams{'ACTION'} eq $Lang::tr{'dial'}) { | |
a56b5be4 | 111 | system('/usr/local/bin/redctrl start > /dev/null') == 0 |
957363eb CS |
112 | or &General::log("Dial failed: $?"); sleep 1;} |
113 | elsif ($cgiparams{'ACTION'} eq $Lang::tr{'hangup'}) { | |
a56b5be4 | 114 | system('/usr/local/bin/redctrl stop > /dev/null') == 0 |
957363eb CS |
115 | or &General::log("Hangup failed: $?"); sleep 1;} |
116 | ||
e383179b MT |
117 | my $c; |
118 | my $maxprofiles = 5; | |
119 | my @profilenames = (); | |
120 | ||
121 | for ($c = 1; $c <= $maxprofiles; $c++) | |
122 | { | |
123 | my %temppppsettings = (); | |
124 | $temppppsettings{'PROFILENAME'} = ''; | |
125 | &General::readhash("${General::swroot}/ppp/settings-$c", \%temppppsettings); | |
126 | $profilenames[$c] = $temppppsettings{'PROFILENAME'}; | |
127 | } | |
128 | my %selected; | |
129 | for ($c = 1; $c <= $maxprofiles; $c++) { | |
130 | $selected{'PROFILE'}{$c} = ''; | |
131 | } | |
132 | $selected{'PROFILE'}{$pppsettings{'PROFILE'}} = "selected='selected'"; | |
133 | my $dialButtonDisabled = "disabled='disabled'"; | |
134 | ||
135 | ||
ac1cfefa MT |
136 | &Header::openpage($Lang::tr{'main page'}, 1, $refresh); |
137 | &Header::openbigbox('', 'center'); | |
138 | &Header::openbox('100%', 'center', &Header::cleanhtml(`/bin/uname -n`,"y")); | |
139 | ||
3489ebac MT |
140 | |
141 | ||
a08a5f33 | 142 | if ( ( $pppsettings{'VALID'} eq 'yes' && $modemsettings{'VALID'} eq 'yes' ) || ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ )) { |
986e08d9 MT |
143 | if (open(IPADDR,"${General::swroot}/ddns/ipcache")) { |
144 | $ipaddr = <IPADDR>; | |
145 | close IPADDR; | |
146 | chomp ($ipaddr); | |
147 | } | |
148 | if (open(IPADDR,"${General::swroot}/red/local-ipaddress")) { | |
786f2c8a | 149 | $ipaddr = <IPADDR>; |
986e08d9 MT |
150 | close IPADDR; |
151 | chomp ($ipaddr); | |
152 | } | |
ac1cfefa MT |
153 | } elsif ($modemsettings{'VALID'} eq 'no') { |
154 | print "$Lang::tr{'modem settings have errors'}\n </b></font>\n"; | |
155 | } else { | |
156 | print "$Lang::tr{'profile has errors'}\n </b></font>\n"; | |
157 | } | |
158 | ||
3489ebac MT |
159 | #if ( $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) { |
160 | # $ipaddr = $netsettings{'RED_ADDRESS'}; | |
161 | #} | |
e383179b | 162 | |
a56b5be4 CS |
163 | my $death = 0; |
164 | my $rebirth = 0; | |
165 | ||
166 | if ($cgiparams{'ACTION'} eq $Lang::tr{'shutdown'}) { | |
167 | $death = 1; | |
168 | &General::log($Lang::tr{'shutting down ipfire'}); | |
169 | system '/usr/local/bin/ipfirereboot down'; | |
170 | } elsif ($cgiparams{'ACTION'} eq $Lang::tr{'reboot'}) { | |
171 | $rebirth = 1; | |
172 | &General::log($Lang::tr{'rebooting ipfire'}); | |
173 | system '/usr/local/bin/ipfirereboot boot'; | |
174 | } | |
175 | ||
176 | if ($death == 0 && $rebirth == 0) { | |
0ab4385a JPT |
177 | |
178 | if ($mainsettings{'REBOOTQUESTION'} eq "off") { | |
179 | print <<END | |
180 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
181 | <table width='100%'> | |
182 | <tr> | |
183 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'reboot'}' /></td> | |
184 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}' /></td> | |
185 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'shutdown'}' /></td> | |
186 | </tr> | |
187 | </table> | |
188 | </form> | |
c853dcce JPT |
189 | END |
190 | ; | |
0ab4385a JPT |
191 | } else { |
192 | if ($cgiparams{'ACTION'} eq $Lang::tr{'reboot ask'}) { | |
193 | print <<END | |
194 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
195 | <table width='100%'> | |
196 | <tr> | |
197 | <td colspan="3" align='left'><font color="red">$Lang::tr{'reboot sure'}</font></td> | |
198 | </tr> | |
199 | <tr> | |
200 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'reboot'}' /></td> | |
201 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}' /></td> | |
202 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'shutdown ask'}' /></td> | |
203 | </tr> | |
204 | </table> | |
205 | </form> | |
b4ad0027 JPT |
206 | END |
207 | ; | |
0ab4385a | 208 | } elsif ($cgiparams{'ACTION'} eq $Lang::tr{'shutdown ask'}) { |
a56b5be4 | 209 | print <<END |
0ab4385a JPT |
210 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> |
211 | <table width='100%'> | |
212 | <tr> | |
213 | <td colspan="3" align='right'><font color="red">$Lang::tr{'shutdown sure'}</font></td> | |
214 | </tr> | |
215 | <tr> | |
216 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'reboot ask'}' /></td> | |
217 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}' /></td> | |
218 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'shutdown'}' /></td> | |
219 | </tr> | |
220 | </table> | |
221 | </form> | |
a56b5be4 CS |
222 | END |
223 | ; | |
0ab4385a JPT |
224 | } else { |
225 | print <<END | |
226 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
227 | <table width='100%'> | |
228 | <tr> | |
229 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'reboot ask'}' /></td> | |
230 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}' /></td> | |
231 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'shutdown ask'}' /></td> | |
232 | </tr> | |
233 | </table> | |
234 | </form> | |
235 | END | |
236 | ; | |
237 | } | |
b4ad0027 | 238 | } |
a56b5be4 | 239 | print <<END; |
e383179b | 240 | |
0ab4385a | 241 | |
e383179b MT |
242 | <!-- Table of networks --> |
243 | <table border='0' width=80%> | |
f2fdd0c1 CS |
244 | <tr> <th bgcolor='$color{'color20'}'>$Lang::tr{'network'} |
245 | <th bgcolor='$color{'color20'}'>IP | |
246 | <th bgcolor='$color{'color20'}'>$Lang::tr{'status'} | |
33e1f48c | 247 | <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> |
c85ec3b4 CS |
248 | <td width='30%' align='center'>$ipaddr |
249 | <td width='45%' align='center'>$connstate | |
f3bbb213 | 250 | END |
c85ec3b4 | 251 | if ( $netsettings{'RED_TYPE'} ne "STATIC" && $netsettings{'RED_TYPE'} ne "DHCP" ){ |
f3bbb213 MT |
252 | print `/usr/local/bin/dialctrl.pl show`; |
253 | print <<END; | |
e383179b | 254 | <tr><td colspan='2'> |
957363eb | 255 | <form method='post' action='$ENV{'SCRIPT_NAME'}'>$Lang::tr{'profile'}: |
e383179b MT |
256 | <select name='PROFILE'> |
257 | END | |
258 | for ($c = 1; $c <= $maxprofiles; $c++) | |
259 | { | |
260 | if ($profilenames[$c] ne '') { | |
261 | $dialButtonDisabled = ""; | |
262 | print "\t<option value='$c' $selected{'PROFILE'}{$c}>$c. $profilenames[$c]</option>\n"; | |
263 | } | |
264 | } | |
c6aa4ac1 | 265 | $dialButtonDisabled = "disabled='disabled'" if (-e '/var/run/ppp-ipfire.pid' || -e "${General::swroot}/red/active"); |
a08a5f33 | 266 | if ( ( $pppsettings{'VALID'} eq 'yes' ) || ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) ) { |
e383179b MT |
267 | print <<END; |
268 | </select> | |
269 | <input type='submit' name='ACTION' value='$Lang::tr{'dial profile'}' $dialButtonDisabled /> | |
270 | </form> | |
271 | <td align='center'> | |
272 | <table width='100%' border='0'> | |
273 | <tr> | |
957363eb | 274 | <td width='50%' align='right'> <form method='post' action='$ENV{'SCRIPT_NAME'}'> |
e383179b MT |
275 | <input type='submit' name='ACTION' value='$Lang::tr{'dial'}'> |
276 | </form> | |
957363eb | 277 | <td width='50%' align='left'> <form method='post' action='$ENV{'SCRIPT_NAME'}'> |
e383179b MT |
278 | <input type='submit' name='ACTION' value='$Lang::tr{'hangup'}'> |
279 | </form> | |
280 | </table> | |
281 | END | |
282 | } else { | |
283 | print "$Lang::tr{'profile has errors'}\n </b></font>\n"; | |
284 | } | |
c85ec3b4 | 285 | } |
786f2c8a MT |
286 | my $HOSTNAME = (gethostbyaddr(pack("C4", split(/\./, $ipaddr)), 2))[0]; |
287 | if ( "$HOSTNAME" ne "" ) { | |
288 | print <<END; | |
c85ec3b4 | 289 | <tr><td><b>Hostname:</b><td align='center'>$HOSTNAME<td> |
786f2c8a MT |
290 | END |
291 | } | |
292 | ||
293 | if ( -e "/var/ipfire/red/remote-ipaddress" ) { | |
294 | my $GATEWAY = `cat /var/ipfire/red/remote-ipaddress`; | |
295 | chomp($GATEWAY); | |
296 | print <<END; | |
c85ec3b4 | 297 | <tr><td><b>Gateway:</b><td align='center'>$GATEWAY<td> |
786f2c8a MT |
298 | END |
299 | } | |
300 | ||
c6aa4ac1 MT |
301 | my $DNS1 = `cat /var/ipfire/red/dns1`; |
302 | my $DNS2 = `cat /var/ipfire/red/dns2`; | |
303 | chomp($DNS1); | |
304 | chomp($DNS1); | |
305 | ||
306 | if ( $DNS1 ) { print <<END; | |
c85ec3b4 | 307 | <tr><td><b>DNS-Server:</b><td align='center'>$DNS1 |
c6aa4ac1 MT |
308 | END |
309 | } | |
310 | if ( $DNS2 ) { print <<END; | |
c85ec3b4 | 311 | <td align='center'>$DNS2 |
c6aa4ac1 MT |
312 | END |
313 | } else { print <<END; | |
314 | <td> | |
315 | END | |
316 | } | |
317 | ||
072cd997 | 318 | if ( $netsettings{'GREEN_DEV'} ) { print <<END; |
33e1f48c | 319 | <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> |
c85ec3b4 CS |
320 | <td width='30%' align='center'>$netsettings{'GREEN_ADDRESS'} |
321 | <td width='45%' align='center'> | |
e383179b | 322 | END |
072cd997 | 323 | if ( `cat /var/ipfire/proxy/advanced/settings | grep ^ENABLE=on` ) { |
ef482d53 | 324 | print $Lang::tr{'advproxy on'}; |
072cd997 | 325 | if ( `cat /var/ipfire/proxy/advanced/settings | grep ^TRANSPARENT=on` ) { print " (transparent)"; } |
ef482d53 | 326 | } else { print $Lang::tr{'advproxy off'}; } |
072cd997 MT |
327 | } |
328 | if ( $netsettings{'BLUE_DEV'} ) { print <<END; | |
33e1f48c | 329 | <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> |
c85ec3b4 CS |
330 | <td width='30%' align='center'>$netsettings{'BLUE_ADDRESS'} |
331 | <td width='45%' align='center'> | |
e383179b | 332 | END |
072cd997 | 333 | if ( `cat /var/ipfire/proxy/advanced/settings | grep ^ENABLE_BLUE=on` ) { |
ef482d53 | 334 | print $Lang::tr{'advproxy on'}; |
072cd997 | 335 | if ( `cat /var/ipfire/proxy/advanced/settings | grep ^TRANSPARENT_BLUE=on` ) { print " (transparent)"; } |
ef482d53 | 336 | } else { print $Lang::tr{'advproxy off'}; } |
072cd997 | 337 | } |
39a7cc11 | 338 | if ( $netsettings{'ORANGE_DEV'} ) { print <<END; |
33e1f48c | 339 | <tr><td align='center' bgcolor='$Header::colourorange' width='25%'><a href="/cgi-bin/dmzholes.cgi"><font size='2' color='white'><b>$Lang::tr{'dmz'}</b></font></a><br> |
c85ec3b4 CS |
340 | <td width='30%' align='center'>$netsettings{'ORANGE_ADDRESS'} |
341 | <td width='45%' align='center'><font color=$Header::colourgreen>Online</font> | |
e383179b | 342 | END |
072cd997 | 343 | } |
39a7cc11 MT |
344 | if ( `cat /var/ipfire/vpn/settings | grep ^ENABLED=on` || |
345 | `cat /var/ipfire/vpn/settings | grep ^ENABLED_BLUE=on` ) { | |
072cd997 | 346 | my $ipsecip = `cat /var/ipfire/vpn/settings | grep ^VPN_IP= | cut -c 8-`; |
db073a10 | 347 | my @status = `/usr/local/bin/ipsecctrl I`; |
e455cafe MT |
348 | my %confighash = (); |
349 | &General::readhasharray("${General::swroot}/vpn/config", \%confighash); | |
072cd997 | 350 | print <<END; |
33e1f48c | 351 | <tr><td align='center' bgcolor='$Header::colourvpn' width='25%'><a href="/cgi-bin/vpnmain.cgi"><font size='2' color='white'><b>$Lang::tr{'vpn'}</b></font></a><br> |
c85ec3b4 CS |
352 | <td width='30%' align='center'>$ipsecip |
353 | <td width='45%' align='center'><font color=$Header::colourgreen>Online</font> | |
e383179b | 354 | END |
e455cafe MT |
355 | my $id = 0; |
356 | my $gif; | |
357 | foreach my $key (keys %confighash) { | |
358 | if ($confighash{$key}[0] eq 'on') { $gif = 'on.gif'; } else { $gif = 'off.gif'; } | |
359 | ||
360 | if ($id % 2) { | |
9a2a723e | 361 | print "<tr><td align='left' nowrap='nowrap' bgcolor='$color{'color20'}'>$confighash{$key}[1] / " . $Lang::tr{"$confighash{$key}[3]"} . " (" . $Lang::tr{"$confighash{$key}[4]"} . ")</td><td align='center'>$confighash{$key}[11]</td>"; |
e455cafe | 362 | } else { |
9a2a723e | 363 | print "<tr></td><td align='left' nowrap='nowrap' bgcolor='$color{'color22'}'>$confighash{$key}[1] / " . $Lang::tr{"$confighash{$key}[3]"} . " (" . $Lang::tr{"$confighash{$key}[4]"} . ")</td><td align='center'>$confighash{$key}[11]</td>"; |
e455cafe | 364 | } |
fe6cda92 | 365 | |
e455cafe MT |
366 | my $active = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourred}' width='100%'><tr><td align='center'><b><font color='#FFFFFF'>$Lang::tr{'capsclosed'}</font></b></td></tr></table>"; |
367 | if ($confighash{$key}[0] eq 'off') { | |
368 | $active = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourblue}' width='100%'><tr><td align='center'><b><font color='#FFFFFF'>$Lang::tr{'capsclosed'}</font></b></td></tr></table>"; | |
369 | } else { | |
370 | foreach my $line (@status) { | |
371 | if ($line =~ /\"$confighash{$key}[1]\".*IPsec SA established/) { | |
f2fdd0c1 | 372 | $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 |
373 | } |
374 | } | |
375 | } | |
376 | print "<td align='center'>$active</td>"; | |
377 | } | |
072cd997 MT |
378 | } |
379 | if ( `cat /var/ipfire/ovpn/settings | grep ^ENABLED=on` || | |
380 | `cat /var/ipfire/ovpn/settings | grep ^ENABLED_BLUE=on` || | |
381 | `cat /var/ipfire/ovpn/settings | grep ^ENABLED_ORANGE=on`) { | |
382 | my $ovpnip = `cat /var/ipfire/ovpn/settings | grep ^DOVPN_SUBNET= | cut -c 14- | sed -e 's\/\\/255.255.255.0\/\/'`; | |
383 | print <<END; | |
33e1f48c | 384 | <tr><td align='center' bgcolor='$Header::colourovpn' width='25%'><a href="/cgi-bin/ovpnmain.cgi"><font size='2' color='white'><b>OpenVPN</b></font></a><br> |
c85ec3b4 CS |
385 | <td width='30%' align='center'>$ovpnip |
386 | <td width='45%' align='center'><font color=$Header::colourgreen>Online</font> | |
072cd997 MT |
387 | END |
388 | } | |
ac1cfefa MT |
389 | |
390 | # Memory usage warning | |
391 | my @free = `/usr/bin/free`; | |
392 | $free[1] =~ m/(\d+)/; | |
393 | my $mem = $1; | |
394 | $free[2] =~ m/(\d+)/; | |
395 | my $used = $1; | |
396 | my $pct = int 100 * ($mem - $used) / $mem; | |
397 | if ($used / $mem > 90) { | |
398 | $warnmessage .= "<li> $Lang::tr{'high memory usage'}: $pct% !</li>\n"; | |
399 | } | |
400 | ||
401 | # Diskspace usage warning | |
402 | my @temp=(); | |
403 | my $temp2=(); | |
404 | my @df = `/bin/df -B M -x rootfs`; | |
405 | foreach my $line (@df) { | |
406 | next if $line =~ m/^Filesystem/; | |
407 | if ($line =~ m/root/ ) { | |
408 | $line =~ m/^.* (\d+)M.*$/; | |
409 | @temp = split(/ +/,$line); | |
410 | if ($1<5) { | |
411 | # available:plain value in MB, and not %used as 10% is too much to waste on small disk | |
412 | # and root size should not vary during time | |
62f1526a | 413 | $warnmessage .= "<li> $Lang::tr{'filesystem full'}: $temp[0] <b>$Lang::tr{'free'}=$1M</b> !</li>\n"; |
ac1cfefa MT |
414 | } |
415 | ||
416 | } else { | |
417 | # $line =~ m/^.* (\d+)m.*$/; | |
418 | $line =~ m/^.* (\d+)\%.*$/; | |
419 | if ($1>90) { | |
420 | @temp = split(/ /,$line); | |
421 | $temp2=int(100-$1); | |
62f1526a | 422 | $warnmessage .= "<li> $Lang::tr{'filesystem full'}: $temp[0] <b>$Lang::tr{'free'}=$temp2%</b> !</li>\n"; |
ac1cfefa MT |
423 | } |
424 | } | |
425 | } | |
426 | ||
c1712013 AF |
427 | # S.M.A.R.T. health warning |
428 | my @files = `/bin/ls /var/run/smartctl_out_hddtemp-*`; | |
429 | foreach my $file (@files) { | |
430 | chomp ($file); | |
431 | my $disk=`echo $file | cut -d"-" -f2`; | |
432 | chomp ($disk); | |
433 | if (`/bin/grep "SAVE ALL DATA" $file`) { | |
62f1526a | 434 | $warnmessage .= "<li> $Lang::tr{'smartwarn1'} /dev/$disk $Lang::tr{'smartwarn2'} !</li>\n\n"; |
c1712013 AF |
435 | } |
436 | } | |
437 | ||
337305ef | 438 | |
ac1cfefa | 439 | if ($warnmessage) { |
02dc0a76 | 440 | print "<tr><td align='center' bgcolor=$Header::colourred colspan='3'><font color='white'>$warnmessage</font></table>"; |
ac1cfefa | 441 | } |
02dc0a76 MT |
442 | print <<END; |
443 | </table> | |
2b38ab5c JPT |
444 | END |
445 | ; | |
446 | &Pakfire::dblist("upgrade", "notice"); | |
447 | print <<END; | |
02dc0a76 | 448 | END |
6b1c728d | 449 | if ($reboot == 1) { |
337305ef JPT |
450 | print "<br /><font color='red'>$Lang::tr{'needreboot'}!</font>"; |
451 | } | |
8de160ff MT |
452 | } else { |
453 | my $message=''; | |
454 | if ($death) { | |
455 | $message = $Lang::tr{'ipfire has now shutdown'}; | |
456 | } else { | |
457 | $message = $Lang::tr{'ipfire has now rebooted'}; | |
458 | } | |
459 | print <<END | |
460 | <div align='center'> | |
461 | <table width='100%' bgcolor='#ffffff'> | |
462 | <tr><td align='center'> | |
94ec137d | 463 | <br /><br /><img src='/images/IPFire.png' /><br /><br /><br /> |
8de160ff MT |
464 | </td></tr> |
465 | </table> | |
466 | <br /> | |
467 | <font size='6'>$message</font> | |
468 | </div> | |
469 | END | |
470 | ; | |
b4ad0027 JPT |
471 | |
472 | } | |
473 | ||
ac1cfefa | 474 | &Header::closebox(); |
ac1cfefa | 475 | &Header::closebigbox(); |
ac1cfefa | 476 | &Header::closepage(); |