]>
Commit | Line | Data |
---|---|---|
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 | |
22 | use strict; | |
54fd0535 | 23 | use 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 | 29 | require '/var/ipfire/general-functions.pl'; |
ac1cfefa MT |
30 | require "${General::swroot}/lang.pl"; |
31 | require "${General::swroot}/header.pl"; | |
2b38ab5c | 32 | require "/opt/pakfire/lib/functions.pl"; |
ac1cfefa MT |
33 | |
34 | my %cgiparams=(); | |
35 | my %pppsettings=(); | |
36 | my %modemsettings=(); | |
37 | my %netsettings=(); | |
38 | my %ddnssettings=(); | |
39 | my $warnmessage = ''; | |
c85ec3b4 | 40 | my $refresh = ""; |
e383179b | 41 | my $ipaddr=''; |
ac1cfefa | 42 | |
337305ef | 43 | |
ac1cfefa MT |
44 | &Header::showhttpheaders(); |
45 | ||
46 | $cgiparams{'ACTION'} = ''; | |
47 | &Header::getcgihash(\%cgiparams); | |
48 | $pppsettings{'VALID'} = ''; | |
49 | $pppsettings{'PROFILENAME'} = 'None'; | |
50 | &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); | |
51 | &General::readhash("${General::swroot}/modem/settings", \%modemsettings); | |
52 | &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); | |
53 | &General::readhash("${General::swroot}/ddns/settings", \%ddnssettings); | |
54 | ||
f2fdd0c1 CS |
55 | my %color = (); |
56 | my %mainsettings = (); | |
57 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
58 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
59 | ||
ac1cfefa | 60 | my $connstate = &Header::connectionstatus(); |
56b7a3e2 | 61 | |
e85d32bb | 62 | if ( -e "/var/ipfire/main/gpl-accepted" ) { |
56b7a3e2 CS |
63 | if ($cgiparams{'ACTION'} eq $Lang::tr{'shutdown'} || $cgiparams{'ACTION'} eq $Lang::tr{'reboot'}) { |
64 | $refresh = "<meta http-equiv='refresh' content='300;'>"; | |
8a5898e7 | 65 | } elsif ($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 |
72 | if ($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 | ||
107 | if ($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;} |
110 | elsif ($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 |
114 | my $c; |
115 | my $maxprofiles = 5; | |
116 | my @profilenames = (); | |
117 | ||
118 | for ($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 | } | |
125 | my %selected; | |
126 | for ($c = 1; $c <= $maxprofiles; $c++) { | |
127 | $selected{'PROFILE'}{$c} = ''; | |
128 | } | |
129 | $selected{'PROFILE'}{$pppsettings{'PROFILE'}} = "selected='selected'"; | |
130 | my $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 | 137 | if ($cgiparams{'ACTION'} eq $Lang::tr{'yes'} && $cgiparams{'gpl_accepted'} eq '1') { |
7fa7c7dd JPT |
138 | system('touch /var/ipfire/main/gpl_accepted') |
139 | } | |
f341a168 | 140 | if ( -e "/var/ipfire/main/gpl_accepted" ) { |
7fa7c7dd | 141 | &Header::openbox('100%', 'center', &Header::cleanhtml(`/bin/uname -n`,"y")); |
3489ebac MT |
142 | |
143 | ||
a08a5f33 | 144 | if ( ( $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 | ||
3489ebac MT |
161 | #if ( $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) { |
162 | # $ipaddr = $netsettings{'RED_ADDRESS'}; | |
163 | #} | |
e383179b | 164 | |
a56b5be4 CS |
165 | my $death = 0; |
166 | my $rebirth = 0; | |
167 | ||
168 | if ($cgiparams{'ACTION'} eq $Lang::tr{'shutdown'}) { | |
169 | $death = 1; | |
170 | &General::log($Lang::tr{'shutting down ipfire'}); | |
171 | system '/usr/local/bin/ipfirereboot down'; | |
172 | } elsif ($cgiparams{'ACTION'} eq $Lang::tr{'reboot'}) { | |
173 | $rebirth = 1; | |
174 | &General::log($Lang::tr{'rebooting ipfire'}); | |
175 | system '/usr/local/bin/ipfirereboot boot'; | |
176 | } | |
177 | ||
178 | if ($death == 0 && $rebirth == 0) { | |
0ab4385a JPT |
179 | |
180 | if ($mainsettings{'REBOOTQUESTION'} eq "off") { | |
181 | print <<END | |
182 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
183 | <table width='100%'> | |
184 | <tr> | |
185 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'reboot'}' /></td> | |
186 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}' /></td> | |
187 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'shutdown'}' /></td> | |
188 | </tr> | |
189 | </table> | |
190 | </form> | |
c853dcce JPT |
191 | END |
192 | ; | |
0ab4385a JPT |
193 | } else { |
194 | if ($cgiparams{'ACTION'} eq $Lang::tr{'reboot ask'}) { | |
195 | print <<END | |
196 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
197 | <table width='100%'> | |
198 | <tr> | |
199 | <td colspan="3" align='left'><font color="red">$Lang::tr{'reboot sure'}</font></td> | |
200 | </tr> | |
201 | <tr> | |
202 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'reboot'}' /></td> | |
203 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}' /></td> | |
204 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'shutdown ask'}' /></td> | |
205 | </tr> | |
206 | </table> | |
207 | </form> | |
b4ad0027 JPT |
208 | END |
209 | ; | |
0ab4385a | 210 | } elsif ($cgiparams{'ACTION'} eq $Lang::tr{'shutdown ask'}) { |
a56b5be4 | 211 | print <<END |
0ab4385a JPT |
212 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> |
213 | <table width='100%'> | |
214 | <tr> | |
215 | <td colspan="3" align='right'><font color="red">$Lang::tr{'shutdown sure'}</font></td> | |
216 | </tr> | |
217 | <tr> | |
218 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'reboot ask'}' /></td> | |
219 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}' /></td> | |
220 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'shutdown'}' /></td> | |
221 | </tr> | |
222 | </table> | |
223 | </form> | |
a56b5be4 CS |
224 | END |
225 | ; | |
0ab4385a JPT |
226 | } else { |
227 | print <<END | |
228 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
229 | <table width='100%'> | |
230 | <tr> | |
231 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'reboot ask'}' /></td> | |
232 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}' /></td> | |
233 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'shutdown ask'}' /></td> | |
234 | </tr> | |
235 | </table> | |
236 | </form> | |
237 | END | |
238 | ; | |
239 | } | |
b4ad0027 | 240 | } |
a56b5be4 | 241 | print <<END; |
e383179b | 242 | |
0ab4385a | 243 | |
e5d406ab | 244 | |
e383179b MT |
245 | <!-- Table of networks --> |
246 | <table border='0' width=80%> | |
e5d406ab EK |
247 | <tr> <th bgcolor='$color{'color20'}'>$Lang::tr{'network'}</th> |
248 | <th bgcolor='$color{'color20'}'>IP</th> | |
249 | <th bgcolor='$color{'color20'}'>$Lang::tr{'status'}</th></tr> | |
250 | <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> | |
251 | <td width='30%' align='center'>$ipaddr </td> | |
252 | <td width='45%' align='center'>$connstate | |
f3bbb213 | 253 | END |
c85ec3b4 | 254 | if ( $netsettings{'RED_TYPE'} ne "STATIC" && $netsettings{'RED_TYPE'} ne "DHCP" ){ |
f3bbb213 MT |
255 | print `/usr/local/bin/dialctrl.pl show`; |
256 | print <<END; | |
e5d406ab EK |
257 | </td></tr> |
258 | <tr><td colspan='2'> | |
259 | ||
957363eb | 260 | <form method='post' action='$ENV{'SCRIPT_NAME'}'>$Lang::tr{'profile'}: |
e383179b MT |
261 | <select name='PROFILE'> |
262 | END | |
263 | for ($c = 1; $c <= $maxprofiles; $c++) | |
264 | { | |
265 | if ($profilenames[$c] ne '') { | |
266 | $dialButtonDisabled = ""; | |
267 | print "\t<option value='$c' $selected{'PROFILE'}{$c}>$c. $profilenames[$c]</option>\n"; | |
268 | } | |
269 | } | |
c6aa4ac1 | 270 | $dialButtonDisabled = "disabled='disabled'" if (-e '/var/run/ppp-ipfire.pid' || -e "${General::swroot}/red/active"); |
a08a5f33 | 271 | if ( ( $pppsettings{'VALID'} eq 'yes' ) || ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) ) { |
e383179b MT |
272 | print <<END; |
273 | </select> | |
274 | <input type='submit' name='ACTION' value='$Lang::tr{'dial profile'}' $dialButtonDisabled /> | |
275 | </form> | |
276 | <td align='center'> | |
277 | <table width='100%' border='0'> | |
278 | <tr> | |
957363eb | 279 | <td width='50%' align='right'> <form method='post' action='$ENV{'SCRIPT_NAME'}'> |
e383179b MT |
280 | <input type='submit' name='ACTION' value='$Lang::tr{'dial'}'> |
281 | </form> | |
957363eb | 282 | <td width='50%' align='left'> <form method='post' action='$ENV{'SCRIPT_NAME'}'> |
e383179b MT |
283 | <input type='submit' name='ACTION' value='$Lang::tr{'hangup'}'> |
284 | </form> | |
285 | </table> | |
286 | END | |
287 | } else { | |
288 | print "$Lang::tr{'profile has errors'}\n </b></font>\n"; | |
289 | } | |
c85ec3b4 | 290 | } |
786f2c8a MT |
291 | my $HOSTNAME = (gethostbyaddr(pack("C4", split(/\./, $ipaddr)), 2))[0]; |
292 | if ( "$HOSTNAME" ne "" ) { | |
293 | print <<END; | |
c85ec3b4 | 294 | <tr><td><b>Hostname:</b><td align='center'>$HOSTNAME<td> |
786f2c8a MT |
295 | END |
296 | } | |
297 | ||
298 | if ( -e "/var/ipfire/red/remote-ipaddress" ) { | |
299 | my $GATEWAY = `cat /var/ipfire/red/remote-ipaddress`; | |
300 | chomp($GATEWAY); | |
301 | print <<END; | |
c85ec3b4 | 302 | <tr><td><b>Gateway:</b><td align='center'>$GATEWAY<td> |
786f2c8a MT |
303 | END |
304 | } | |
305 | ||
c6aa4ac1 MT |
306 | my $DNS1 = `cat /var/ipfire/red/dns1`; |
307 | my $DNS2 = `cat /var/ipfire/red/dns2`; | |
308 | chomp($DNS1); | |
309 | chomp($DNS1); | |
310 | ||
311 | if ( $DNS1 ) { print <<END; | |
c85ec3b4 | 312 | <tr><td><b>DNS-Server:</b><td align='center'>$DNS1 |
c6aa4ac1 MT |
313 | END |
314 | } | |
315 | if ( $DNS2 ) { print <<END; | |
c85ec3b4 | 316 | <td align='center'>$DNS2 |
c6aa4ac1 MT |
317 | END |
318 | } else { print <<END; | |
319 | <td> | |
320 | END | |
321 | } | |
322 | ||
072cd997 | 323 | if ( $netsettings{'GREEN_DEV'} ) { print <<END; |
33e1f48c | 324 | <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 |
325 | <td width='30%' align='center'>$netsettings{'GREEN_ADDRESS'} |
326 | <td width='45%' align='center'> | |
e383179b | 327 | END |
072cd997 | 328 | if ( `cat /var/ipfire/proxy/advanced/settings | grep ^ENABLE=on` ) { |
ef482d53 | 329 | print $Lang::tr{'advproxy on'}; |
072cd997 | 330 | if ( `cat /var/ipfire/proxy/advanced/settings | grep ^TRANSPARENT=on` ) { print " (transparent)"; } |
ef482d53 | 331 | } else { print $Lang::tr{'advproxy off'}; } |
072cd997 MT |
332 | } |
333 | if ( $netsettings{'BLUE_DEV'} ) { print <<END; | |
33e1f48c | 334 | <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 |
335 | <td width='30%' align='center'>$netsettings{'BLUE_ADDRESS'} |
336 | <td width='45%' align='center'> | |
e383179b | 337 | END |
072cd997 | 338 | if ( `cat /var/ipfire/proxy/advanced/settings | grep ^ENABLE_BLUE=on` ) { |
ef482d53 | 339 | print $Lang::tr{'advproxy on'}; |
072cd997 | 340 | if ( `cat /var/ipfire/proxy/advanced/settings | grep ^TRANSPARENT_BLUE=on` ) { print " (transparent)"; } |
ef482d53 | 341 | } else { print $Lang::tr{'advproxy off'}; } |
072cd997 | 342 | } |
39a7cc11 | 343 | if ( $netsettings{'ORANGE_DEV'} ) { print <<END; |
33e1f48c | 344 | <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 |
345 | <td width='30%' align='center'>$netsettings{'ORANGE_ADDRESS'} |
346 | <td width='45%' align='center'><font color=$Header::colourgreen>Online</font> | |
e383179b | 347 | END |
072cd997 | 348 | } |
39a7cc11 MT |
349 | if ( `cat /var/ipfire/vpn/settings | grep ^ENABLED=on` || |
350 | `cat /var/ipfire/vpn/settings | grep ^ENABLED_BLUE=on` ) { | |
072cd997 | 351 | my $ipsecip = `cat /var/ipfire/vpn/settings | grep ^VPN_IP= | cut -c 8-`; |
db073a10 | 352 | my @status = `/usr/local/bin/ipsecctrl I`; |
e455cafe MT |
353 | my %confighash = (); |
354 | &General::readhasharray("${General::swroot}/vpn/config", \%confighash); | |
072cd997 | 355 | print <<END; |
33e1f48c | 356 | <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 |
357 | <td width='30%' align='center'>$ipsecip |
358 | <td width='45%' align='center'><font color=$Header::colourgreen>Online</font> | |
e383179b | 359 | END |
e455cafe MT |
360 | my $id = 0; |
361 | my $gif; | |
542b31d6 | 362 | foreach my $key (sort { uc($confighash{$a}[1]) cmp uc($confighash{$b}[1]) } keys %confighash) { |
e455cafe MT |
363 | if ($confighash{$key}[0] eq 'on') { $gif = 'on.gif'; } else { $gif = 'off.gif'; } |
364 | ||
365 | if ($id % 2) { | |
9a2a723e | 366 | 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 | 367 | } else { |
9a2a723e | 368 | 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 | 369 | } |
fe6cda92 | 370 | |
e455cafe MT |
371 | 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>"; |
372 | if ($confighash{$key}[0] eq 'off') { | |
373 | $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>"; | |
374 | } else { | |
375 | foreach my $line (@status) { | |
4b4b8959 | 376 | if (($line =~ /\"$confighash{$key}[1]\".*IPsec SA established/) || |
264c0195 | 377 | ($line =~/$confighash{$key}[1]\{.*INSTALLED/ )) |
4b4b8959 | 378 | { |
f2fdd0c1 | 379 | $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 |
380 | } |
381 | } | |
382 | } | |
383 | print "<td align='center'>$active</td>"; | |
384 | } | |
072cd997 | 385 | } |
4715ddb3 SS |
386 | |
387 | ### | |
388 | # Check if there is any OpenVPN connection configured. | |
389 | ### | |
390 | ||
391 | if ( -s "${General::swroot}/ovpn/ovpnconfig") | |
392 | { | |
393 | print <<END; | |
394 | ||
395 | <tr> | |
396 | <td align='center' bgcolor='$Header::colourovpn' width='25%'> | |
397 | <a href="/cgi-bin/ovpnmain.cgi"><font size='2' color='white'><b>OpenVPN</b></font></a><br> | |
398 | </td> | |
399 | END | |
400 | # Check if the OpenVPN server for Road Warrior Connections is running and display status information. | |
401 | my %confighash=(); | |
402 | ||
403 | &General::readhash("${General::swroot}/ovpn/settings", \%confighash); | |
404 | ||
405 | if (($confighash{'ENABLED'} eq "on") || | |
406 | ($confighash{'ENABLED_BLUE'} eq "on") || | |
407 | ($confighash{'ENABLED_ORANGE'} eq "on")) { | |
408 | ||
409 | my $ovpnip = $confighash{'DOVPN_SUBNET'}; | |
072cd997 | 410 | print <<END; |
c85ec3b4 | 411 | <td width='30%' align='center'>$ovpnip |
4715ddb3 | 412 | <td width='45%' align='center'><font color=$Header::colourgreen>Online</font> |
072cd997 | 413 | END |
54fd0535 | 414 | |
072cd997 | 415 | } |
ac1cfefa | 416 | |
4715ddb3 SS |
417 | # Print the OpenVPN N2N connection status. |
418 | if ( -d "${General::swroot}/ovpn/n2nconf") { | |
419 | my %confighash=(); | |
420 | ||
421 | &General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%confighash); | |
422 | foreach my $dkey (keys %confighash) { | |
423 | if (($confighash{$dkey}[3] eq 'net') && (-e "/var/run/$confighash{$dkey}[1]n2n.pid")) { | |
424 | my $tport = $confighash{$dkey}[22]; | |
425 | next if ($tport eq ''); | |
426 | ||
427 | my $tnet = new Net::Telnet ( Timeout=>5, Errmode=>'return', Port=>$tport); | |
428 | $tnet->open('127.0.0.1'); | |
429 | my @output = $tnet->cmd(String => 'state', Prompt => '/(END.*\n|ERROR:.*\n)/'); | |
430 | my @tustate = split(/\,/, $output[1]); | |
431 | ||
432 | my $display; | |
433 | my $display_colour = $Header::colourred; | |
434 | if ( $tustate[1] eq 'CONNECTED') { | |
435 | $display_colour = $Header::colourgreen; | |
436 | $display = $Lang::tr{'capsopen'}; | |
437 | } else { | |
438 | $display = $tustate[1]; | |
439 | } | |
54fd0535 | 440 | |
4715ddb3 SS |
441 | print <<END; |
442 | <tr> | |
443 | <td align='left' nowrap='nowrap' bgcolor='$color{'color22'}'> | |
444 | $confighash{$dkey}[1] | |
445 | </td> | |
446 | <td align='center'> | |
447 | $confighash{$dkey}[11] | |
448 | </td> | |
449 | <td align='center' bgcolor='$display_colour'> | |
450 | <b> | |
451 | <font color='#FFFFFF'> | |
452 | $display | |
453 | </font> | |
454 | </b> | |
455 | </td> | |
456 | </tr> | |
54fd0535 | 457 | END |
4715ddb3 | 458 | } |
acb305f5 MT |
459 | } |
460 | } | |
54fd0535 MT |
461 | } |
462 | ||
579a39d0 MT |
463 | # Fireinfo |
464 | if ( ! -e "/var/ipfire/main/send_profile") { | |
465 | $warnmessage .= "<li><a style='color: white;' href='fireinfo.cgi'>$Lang::tr{'fireinfo please enable'}</a></li>"; | |
466 | } | |
467 | ||
ac1cfefa MT |
468 | # Memory usage warning |
469 | my @free = `/usr/bin/free`; | |
470 | $free[1] =~ m/(\d+)/; | |
471 | my $mem = $1; | |
472 | $free[2] =~ m/(\d+)/; | |
473 | my $used = $1; | |
474 | my $pct = int 100 * ($mem - $used) / $mem; | |
475 | if ($used / $mem > 90) { | |
476 | $warnmessage .= "<li> $Lang::tr{'high memory usage'}: $pct% !</li>\n"; | |
477 | } | |
478 | ||
479 | # Diskspace usage warning | |
480 | my @temp=(); | |
481 | my $temp2=(); | |
8955b5a7 | 482 | my @df = `/bin/df -B M -P -x rootfs`; |
ac1cfefa MT |
483 | foreach my $line (@df) { |
484 | next if $line =~ m/^Filesystem/; | |
485 | if ($line =~ m/root/ ) { | |
486 | $line =~ m/^.* (\d+)M.*$/; | |
487 | @temp = split(/ +/,$line); | |
488 | if ($1<5) { | |
489 | # available:plain value in MB, and not %used as 10% is too much to waste on small disk | |
490 | # and root size should not vary during time | |
62f1526a | 491 | $warnmessage .= "<li> $Lang::tr{'filesystem full'}: $temp[0] <b>$Lang::tr{'free'}=$1M</b> !</li>\n"; |
ac1cfefa MT |
492 | } |
493 | ||
494 | } else { | |
495 | # $line =~ m/^.* (\d+)m.*$/; | |
496 | $line =~ m/^.* (\d+)\%.*$/; | |
497 | if ($1>90) { | |
498 | @temp = split(/ /,$line); | |
499 | $temp2=int(100-$1); | |
62f1526a | 500 | $warnmessage .= "<li> $Lang::tr{'filesystem full'}: $temp[0] <b>$Lang::tr{'free'}=$temp2%</b> !</li>\n"; |
ac1cfefa MT |
501 | } |
502 | } | |
503 | } | |
504 | ||
c1712013 | 505 | # S.M.A.R.T. health warning |
73c7eff8 | 506 | my @files = `/bin/ls /var/run/smartctl_out_hddtemp-* 2>/dev/null`; |
c1712013 AF |
507 | foreach my $file (@files) { |
508 | chomp ($file); | |
509 | my $disk=`echo $file | cut -d"-" -f2`; | |
510 | chomp ($disk); | |
511 | if (`/bin/grep "SAVE ALL DATA" $file`) { | |
62f1526a | 512 | $warnmessage .= "<li> $Lang::tr{'smartwarn1'} /dev/$disk $Lang::tr{'smartwarn2'} !</li>\n\n"; |
c1712013 AF |
513 | } |
514 | } | |
515 | ||
b81b96d2 AF |
516 | # Reiser4 warning |
517 | my @files = `mount | grep " reiser4 (" 2>/dev/null`; | |
518 | foreach my $disk (@files) { | |
519 | chomp ($disk); | |
520 | $warnmessage .= "<li>$disk - $Lang::tr{'deprecated fs warn'}</li>\n\n"; | |
521 | } | |
522 | ||
523 | ||
ac1cfefa | 524 | if ($warnmessage) { |
02dc0a76 | 525 | print "<tr><td align='center' bgcolor=$Header::colourred colspan='3'><font color='white'>$warnmessage</font></table>"; |
ac1cfefa | 526 | } |
02dc0a76 MT |
527 | print <<END; |
528 | </table> | |
2b38ab5c JPT |
529 | END |
530 | ; | |
531 | &Pakfire::dblist("upgrade", "notice"); | |
532 | print <<END; | |
02dc0a76 | 533 | END |
f341a168 | 534 | if ( -e "/var/run/need_reboot" ) { |
7274a673 | 535 | print "<br /><br /><font color='red'>$Lang::tr{'needreboot'}!</font>"; |
337305ef | 536 | } |
8de160ff MT |
537 | } else { |
538 | my $message=''; | |
539 | if ($death) { | |
540 | $message = $Lang::tr{'ipfire has now shutdown'}; | |
541 | } else { | |
542 | $message = $Lang::tr{'ipfire has now rebooted'}; | |
543 | } | |
544 | print <<END | |
545 | <div align='center'> | |
546 | <table width='100%' bgcolor='#ffffff'> | |
547 | <tr><td align='center'> | |
94ec137d | 548 | <br /><br /><img src='/images/IPFire.png' /><br /><br /><br /> |
8de160ff MT |
549 | </td></tr> |
550 | </table> | |
551 | <br /> | |
552 | <font size='6'>$message</font> | |
553 | </div> | |
554 | END | |
555 | ; | |
b4ad0027 JPT |
556 | |
557 | } | |
558 | ||
ac1cfefa | 559 | &Header::closebox(); |
7fa7c7dd JPT |
560 | } |
561 | ||
562 | else { | |
563 | &Header::openbox('100%', 'left', $Lang::tr{'gpl license agreement'}); | |
564 | print <<END; | |
7fa7c7dd JPT |
565 | $Lang::tr{'gpl please read carefully the general public license and accept it below'}. |
566 | <br /><br /> | |
7274a673 JPT |
567 | END |
568 | ; | |
f341a168 | 569 | if ( -e "/usr/share/doc/licenses/GPLv3" ) { |
7274a673 JPT |
570 | print '<textarea rows=\'25\' cols=\'75\' readonly=\'true\'>'; |
571 | print `cat /usr/share/doc/licenses/GPLv3`; | |
92209271 | 572 | print '</textarea>'; |
7274a673 JPT |
573 | } |
574 | else { | |
92209271 | 575 | print '<br /><a href=\'http://www.gnu.org/licenses/gpl-3.0.txt\' target=\'_blank\'>GNU GENERAL PUBLIC LICENSE</a><br />'; |
7274a673 JPT |
576 | } |
577 | print <<END; | |
7fa7c7dd JPT |
578 | <p> |
579 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
580 | <input type='checkbox' name='gpl_accepted' value='1'/> $Lang::tr{'gpl i accept these terms and conditions'}. | |
581 | <br/ > | |
582 | <input type='submit' name='ACTION' value=$Lang::tr{'yes'} /> | |
583 | </form> | |
584 | </p> | |
7274a673 | 585 | <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 |
586 | |
587 | END | |
588 | ||
589 | &Header::closebox(); | |
590 | } | |
591 | ||
ac1cfefa | 592 | &Header::closebigbox(); |
ac1cfefa | 593 | &Header::closepage(); |