]>
Commit | Line | Data |
---|---|---|
043cfbc0 | 1 | #!/usr/bin/perl |
e64a5b4f LAH |
2 | ############################################################################### |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2021 IPFire Development Team # | |
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 | ############################################################################### | |
043cfbc0 AM |
21 | |
22 | use strict; | |
23 | ||
24 | # enable only the following on debugging purpose | |
25 | #use warnings; | |
26 | #use CGI::Carp 'fatalsToBrowser'; | |
27 | ||
28 | require '/var/ipfire/general-functions.pl'; | |
29 | require "${General::swroot}/lang.pl"; | |
30 | require "${General::swroot}/header.pl"; | |
31 | ||
e64a5b4f LAH |
32 | ###--- HTML HEAD ---### |
33 | my $extraHead = <<END | |
34 | <style> | |
35 | table#controls { | |
36 | width: 100%; | |
37 | border: none; | |
38 | table-layout: fixed; | |
39 | } | |
40 | #controls td { | |
41 | text-align: center; | |
42 | } | |
43 | #controls button { | |
44 | font-weight: bold; | |
45 | padding: 0.7em; | |
46 | min-width: 65%; | |
47 | } | |
48 | </style> | |
49 | END | |
50 | ; | |
51 | ###--- END HTML HEAD ---### | |
52 | ||
043cfbc0 AM |
53 | my %cgiparams=(); |
54 | my $death = 0; | |
55 | my $rebirth = 0; | |
56 | ||
57 | &Header::showhttpheaders(); | |
58 | ||
59 | $cgiparams{'ACTION'} = ''; | |
60 | &Header::getcgihash(\%cgiparams); | |
61 | ||
e64a5b4f | 62 | if ($cgiparams{'ACTION'} eq "SHUTDOWN") { |
043cfbc0 AM |
63 | $death = 1; |
64 | &General::log($Lang::tr{'shutting down ipfire'}); | |
66d63924 | 65 | &General::system('/usr/local/bin/ipfirereboot', 'down'); |
e64a5b4f | 66 | } elsif ($cgiparams{'ACTION'} eq "REBOOT") { |
043cfbc0 AM |
67 | $rebirth = 1; |
68 | &General::log($Lang::tr{'rebooting ipfire'}); | |
66d63924 | 69 | &General::system('/usr/local/bin/ipfirereboot', 'boot'); |
e64a5b4f LAH |
70 | } elsif ($cgiparams{'ACTION'} eq "REBOOT_FSCK") { |
71 | $rebirth = 1; | |
72 | &General::log($Lang::tr{'rebooting ipfire fsck'}); | |
73 | &General::system('/usr/local/bin/ipfirereboot', 'bootfs'); | |
043cfbc0 | 74 | } |
e64a5b4f | 75 | |
043cfbc0 AM |
76 | if ($death == 0 && $rebirth == 0) { |
77 | ||
e64a5b4f | 78 | &Header::openpage($Lang::tr{'shutdown control'}, 1, $extraHead); |
043cfbc0 AM |
79 | |
80 | &Header::openbigbox('100%', 'left'); | |
e64a5b4f | 81 | &Header::openbox('100%', 'left'); |
043cfbc0 | 82 | |
043cfbc0 | 83 | print <<END |
e64a5b4f LAH |
84 | <form method="post" action="$ENV{'SCRIPT_NAME'}"> |
85 | <table id="controls"> | |
86 | <tr> | |
87 | <td><button type="submit" name="ACTION" value="SHUTDOWN">$Lang::tr{'shutdown'}</button></td> | |
88 | <td><button type="submit" name="ACTION" value="REBOOT">$Lang::tr{'reboot'}</button></td> | |
89 | <td><button type="submit" name="ACTION" value="REBOOT_FSCK">$Lang::tr{'reboot fsck'}</button></td> | |
90 | </tr> | |
91 | </table> | |
92 | </form> | |
043cfbc0 | 93 | END |
e64a5b4f | 94 | ; |
043cfbc0 AM |
95 | &Header::closebox(); |
96 | ||
97 | } else { | |
98 | my $message=''; | |
99 | my $title=''; | |
100 | my $refresh = "<meta http-equiv='refresh' content='5; URL=/cgi-bin/index.cgi' />"; | |
101 | if ($death) { | |
102 | $title = $Lang::tr{'shutting down'}; | |
103 | $message = $Lang::tr{'ipfire has now shutdown'}; | |
104 | } else { | |
105 | $title = $Lang::tr{'rebooting'}; | |
106 | $message = $Lang::tr{'ipfire has now rebooted'}; | |
107 | } | |
108 | &Header::openpage($title, 0, $refresh); | |
109 | ||
110 | &Header::openbigbox('100%', 'center'); | |
111 | print <<END | |
112 | <div align='center'> | |
113 | <table width='100%' bgcolor='#ffffff'> | |
114 | <tr><td align='center'> | |
f74ea481 | 115 | <br /><br /><img src='/images/IPFire.png' /><br /><br /><br /> |
043cfbc0 AM |
116 | </td></tr> |
117 | </table> | |
118 | <br /> | |
119 | <font size='6'>$message</font> | |
120 | </div> | |
121 | END | |
122 | ; | |
123 | } | |
124 | ||
125 | &Header::closebigbox(); | |
126 | &Header::closepage(); | |
127 |