]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/perl | |
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 | ############################################################################### | |
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 | require "/opt/pakfire/lib/functions.pl"; | |
32 | ||
33 | my %pakfiresettings=(); | |
34 | my $errormessage = ''; | |
35 | my %color = (); | |
36 | my %mainsettings = (); | |
37 | ||
38 | &Header::showhttpheaders(); | |
39 | ||
40 | $pakfiresettings{'ACTION'} = ''; | |
41 | $pakfiresettings{'VALID'} = ''; | |
42 | ||
43 | $pakfiresettings{'INSPAKS'} = ''; | |
44 | $pakfiresettings{'DELPAKS'} = ''; | |
45 | $pakfiresettings{'AUTOUPDATE'} = 'off'; | |
46 | $pakfiresettings{'AUTOUPGRADE'} = 'off'; | |
47 | $pakfiresettings{'HEALTHCHECK'} = 'on'; | |
48 | $pakfiresettings{'UUID'} = 'on'; | |
49 | ||
50 | sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='1;'>" );print "<center><img src='/images/clock.gif' alt='' /><br/><font color='red'>$Lang::tr{'pagerefresh'}</font></center>";&Header::closebox();} | |
51 | ||
52 | &Header::getcgihash(\%pakfiresettings); | |
53 | ||
54 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
55 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
56 | ||
57 | &Header::openpage($Lang::tr{'pakfire configuration'}, 1); | |
58 | &Header::openbigbox('100%', 'left', '', $errormessage); | |
59 | ||
60 | if ($pakfiresettings{'ACTION'} eq 'install'){ | |
61 | $pakfiresettings{'INSPAKS'} =~ s/\|/\ /g; | |
62 | if ("$pakfiresettings{'FORCE'}" eq "on") { | |
63 | my $command = "/usr/local/bin/pakfire install --non-interactive --no-colors $pakfiresettings{'INSPAKS'} &>/dev/null &"; | |
64 | system("$command"); | |
65 | system("/bin/sleep 1"); | |
66 | } else { | |
67 | &Header::openbox("100%", "center", $Lang::tr{'request'}); | |
68 | my @output = `/usr/local/bin/pakfire resolvedeps --no-colors $pakfiresettings{'INSPAKS'}`; | |
69 | print <<END; | |
70 | <table><tr><td colspan='2'>$Lang::tr{'pakfire install package'}.$pakfiresettings{'INSPAKS'}.$Lang::tr{'pakfire possible dependency'} | |
71 | <pre> | |
72 | END | |
73 | foreach (@output) { | |
74 | $_ =~ s/\\e\[[0-1]\;[0-9]+m//g; | |
75 | print "$_\n"; | |
76 | } | |
77 | print <<END; | |
78 | </pre> | |
79 | <tr><td colspan='2'>$Lang::tr{'pakfire accept all'} | |
80 | <tr><td colspan='2'> | |
81 | <tr><td align='right'><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
82 | <input type='hidden' name='INSPAKS' value='$pakfiresettings{'INSPAKS'}' /> | |
83 | <input type='hidden' name='FORCE' value='on' /> | |
84 | <input type='hidden' name='ACTION' value='install' /> | |
85 | <input type='image' alt='$Lang::tr{'install'}' src='/images/go-next.png' /> | |
86 | </form> | |
87 | <td align='left'> | |
88 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
89 | <input type='hidden' name='ACTION' value='' /> | |
90 | <input type='image' alt='$Lang::tr{'abort'}' src='/images/dialog-error.png' /> | |
91 | </form> | |
92 | </table> | |
93 | END | |
94 | &Header::closebox(); | |
95 | &Header::closebigbox(); | |
96 | &Header::closepage(); | |
97 | exit; | |
98 | } | |
99 | } elsif ($pakfiresettings{'ACTION'} eq 'remove') { | |
100 | ||
101 | $pakfiresettings{'DELPAKS'} =~ s/\|/\ /g; | |
102 | if ("$pakfiresettings{'FORCE'}" eq "on") { | |
103 | my $command = "/usr/local/bin/pakfire remove --non-interactive --no-colors $pakfiresettings{'DELPAKS'} &>/dev/null &"; | |
104 | system("$command"); | |
105 | system("/bin/sleep 1"); | |
106 | } else { | |
107 | &Header::openbox("100%", "center", $Lang::tr{'request'}); | |
108 | my @output = `/usr/local/bin/pakfire resolvedeps --no-colors $pakfiresettings{'DELPAKS'}`; | |
109 | print <<END; | |
110 | <table><tr><td colspan='2'>$Lang::tr{'pakfire uninstall package'}.$pakfiresettings{'DELPAKS'}.$Lang::tr{'pakfire possible dependency'} | |
111 | <pre> | |
112 | END | |
113 | foreach (@output) { | |
114 | $_ =~ s/\\e\[[0-1]\;[0-9]+m//g; | |
115 | print "$_\n"; | |
116 | } | |
117 | print <<END; | |
118 | </pre> | |
119 | <tr><td colspan='2'>$Lang::tr{'pakfire accept all'} | |
120 | <tr><td colspan='2'> | |
121 | <tr><td align='right'><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
122 | <input type='hidden' name='DELPAKS' value='$pakfiresettings{'DELPAKS'}' /> | |
123 | <input type='hidden' name='FORCE' value='on' /> | |
124 | <input type='hidden' name='ACTION' value='remove' /> | |
125 | <input type='image' alt='$Lang::tr{'uninstall'}' src='/images/go-next.png' /> | |
126 | </form> | |
127 | <td align='left'> | |
128 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
129 | <input type='hidden' name='ACTION' value='' /> | |
130 | <input type='image' alt='$Lang::tr{'abort'}' src='/images/dialog-error.png' /> | |
131 | </form> | |
132 | </table> | |
133 | END | |
134 | &Header::closebox(); | |
135 | &Header::closebigbox(); | |
136 | &Header::closepage(); | |
137 | exit; | |
138 | } | |
139 | ||
140 | } elsif ($pakfiresettings{'ACTION'} eq 'update') { | |
141 | ||
142 | system("/usr/local/bin/pakfire update --force --no-colors &>/dev/null &"); | |
143 | system("/bin/sleep 1"); | |
144 | } elsif ($pakfiresettings{'ACTION'} eq 'upgrade') { | |
145 | my $command = "/usr/local/bin/pakfire upgrade -y --no-colors &>/dev/null &"; | |
146 | system("$command"); | |
147 | system("/bin/sleep 1"); | |
148 | } elsif ($pakfiresettings{'ACTION'} eq "$Lang::tr{'save'}") { | |
149 | ||
150 | if ($pakfiresettings{'AUTOUPDATE'} eq 'on') { | |
151 | system("/usr/local/bin/pakfire enable updates >/dev/null 2>&1"); | |
152 | } else { | |
153 | system("/usr/local/bin/pakfire disable updates >/dev/null 2>&1"); | |
154 | } | |
155 | ||
156 | if ($pakfiresettings{'AUTOUPGRADE'} eq 'on') { | |
157 | system("/usr/local/bin/pakfire enable upgrades >/dev/null 2>&1"); | |
158 | } else { | |
159 | system("/usr/local/bin/pakfire disable upgrades >/dev/null 2>&1"); | |
160 | } | |
161 | ||
162 | &General::writehash("${General::swroot}/pakfire/settings", \%pakfiresettings); | |
163 | } | |
164 | ||
165 | &General::readhash("${General::swroot}/pakfire/settings", \%pakfiresettings); | |
166 | ||
167 | my %selected=(); | |
168 | my %checked=(); | |
169 | ||
170 | $checked{'AUTOUPDATE'}{'off'} = ''; | |
171 | $checked{'AUTOUPDATE'}{'on'} = ''; | |
172 | $checked{'AUTOUPDATE'}{$pakfiresettings{'AUTOUPDATE'}} = "checked='checked'"; | |
173 | $checked{'AUTOUPGRADE'}{'off'} = ''; | |
174 | $checked{'AUTOUPGRADE'}{'on'} = ''; | |
175 | $checked{'AUTOUPGRADE'}{$pakfiresettings{'AUTOUPGRADE'}} = "checked='checked'"; | |
176 | $checked{'HEALTHCHECK'}{'off'} = ''; | |
177 | $checked{'HEALTHCHECK'}{'on'} = ''; | |
178 | $checked{'HEALTHCHECK'}{$pakfiresettings{'HEALTHCHECK'}} = "checked='checked'"; | |
179 | $checked{'UUID'}{'off'} = ''; | |
180 | $checked{'UUID'}{'on'} = ''; | |
181 | $checked{'UUID'}{$pakfiresettings{'UUID'}} = "checked='checked'"; | |
182 | ||
183 | # DPC move error message to top so it is seen! | |
184 | if ($errormessage) { | |
185 | &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); | |
186 | print "<font class='base'>$errormessage </font>\n"; | |
187 | &Header::closebox(); | |
188 | } | |
189 | ||
190 | my $return = `pidof pakfire`; | |
191 | chomp($return); | |
192 | if ($return) { | |
193 | &Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='10;'>" ); | |
194 | print <<END; | |
195 | <table> | |
196 | <tr><td> | |
197 | <img src='/images/indicator.gif' alt='$Lang::tr{'aktiv'}' /> | |
198 | <td> | |
199 | $Lang::tr{'pakfire working'} | |
200 | <tr><td colspan='2' align='center'> | |
201 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
202 | <input type='image' alt='$Lang::tr{'reload'}' src='/images/view-refresh.png' /> | |
203 | </form> | |
204 | <tr><td colspan='2' align='left'><pre> | |
205 | END | |
206 | my @output = `grep pakfire /var/log/messages | tail -20`; | |
207 | foreach (@output) { | |
208 | print "$_"; | |
209 | } | |
210 | print <<END; | |
211 | </pre> | |
212 | </table> | |
213 | END | |
214 | &Header::closebox(); | |
215 | &Header::closebigbox(); | |
216 | &Header::closepage(); | |
217 | exit; | |
218 | refreshpage(); | |
219 | } | |
220 | ||
221 | my $core_release = `cat /opt/pakfire/db/core/mine 2>/dev/null`; | |
222 | chomp($core_release); | |
223 | my $core_update_age = &General::age("/opt/pakfire/db/core/mine"); | |
224 | my $corelist_update_age = &General::age("/opt/pakfire/db/lists/core-list.db"); | |
225 | my $server_update_age = &General::age("/opt/pakfire/db/lists/server-list.db"); | |
226 | my $packages_update_age = &General::age("/opt/pakfire/db/lists/packages_list.db"); | |
227 | ||
228 | &Header::openbox("100%", "center", "Pakfire"); | |
229 | ||
230 | print <<END; | |
231 | <table width='95%' cellpadding='5' > | |
232 | <tr><td width="50%" bgcolor='$color{'color20'}' align="center"><b>$Lang::tr{'pakfire system state'}:</b> | |
233 | <td width="50%"> | |
234 | <tr><td align="center">$Lang::tr{'pakfire core update level'}: $core_release<hr /> | |
235 | $Lang::tr{'pakfire last update'} $core_update_age ago<br /> | |
236 | $Lang::tr{'pakfire last serverlist update'} $server_update_age ago<br /> | |
237 | $Lang::tr{'pakfire last core list update'} $corelist_update_age ago<br /> | |
238 | $Lang::tr{'pakfire last package update'} $packages_update_age ago | |
239 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
240 | <input type='hidden' name='ACTION' value='update' /> | |
241 | <input type='submit' value='$Lang::tr{'calamaris refresh list'}' /><br /> | |
242 | </form> | |
243 | <td align="center"> | |
244 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
245 | <select name="UPDPAKS" size="5" disabled> | |
246 | END | |
247 | &Pakfire::dblist("upgrade", "forweb"); | |
248 | print <<END; | |
249 | </select> | |
250 | <br /> | |
251 | <input type='hidden' name='ACTION' value='upgrade' /> | |
252 | <input type='image' alt='$Lang::tr{'upgrade'}' src='/images/document-save.png' /> | |
253 | </form> | |
254 | ||
255 | <tr><td colspan="2"><!-- Just an empty line --> | |
256 | <tr><td bgcolor='$color{'color20'}' align="center"><b>$Lang::tr{'pakfire available addons'}</b> | |
257 | <td bgcolor='$color{'color20'}' align="center"><b>$Lang::tr{'pakfire installed addons'}</b> | |
258 | <tr><td align="center"> | |
259 | <p>$Lang::tr{'pakfire install description'}</p> | |
260 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
261 | <select name="INSPAKS" size="10" multiple> | |
262 | END | |
263 | &Pakfire::dblist("notinstalled", "forweb"); | |
264 | ||
265 | print <<END; | |
266 | </select> | |
267 | <br /> | |
268 | <input type='hidden' name='ACTION' value='install' /> | |
269 | <input type='image' alt='$Lang::tr{'install'}' src='/images/list-add.png' /> | |
270 | </form> | |
271 | ||
272 | <td align="center"> | |
273 | <p>$Lang::tr{'pakfire uninstall description'}</p> | |
274 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
275 | <select name="DELPAKS" size="10" multiple> | |
276 | END | |
277 | ||
278 | &Pakfire::dblist("installed", "forweb"); | |
279 | ||
280 | print <<END; | |
281 | </select> | |
282 | <br /> | |
283 | <input type='hidden' name='ACTION' value='remove' /> | |
284 | <input type='image' alt='$Lang::tr{'remove'}' src='/images/list-remove.png' /> | |
285 | </form> | |
286 | </table> | |
287 | END | |
288 | ||
289 | &Header::closebox(); | |
290 | &Header::openbox("100%", "center", "$Lang::tr{'settings'}"); | |
291 | ||
292 | print <<END; | |
293 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
294 | <table width='95%'> | |
295 | <tr><td colspan='2' bgcolor='$color{'color20'}'><b>$Lang::tr{'basic options'}</b></td></tr> | |
296 | <tr><td align='left' width='45%'>$Lang::tr{'pakfire update daily'}</td><td width="55%" align="left"> | |
297 | on <input type='radio' name='AUTOUPDATE' value='on' $checked{'AUTOUPDATE'}{'on'} /> | | |
298 | <input type='radio' name='AUTOUPDATE' value='off' $checked{'AUTOUPDATE'}{'off'} /> off </td></tr> | |
299 | <tr><td align='left' width='45%'>$Lang::tr{'pakfire core update auto'}</td><td align="left"> | |
300 | on <input type='radio' name='AUTOUPGRADE' value='on' $checked{'AUTOUPGRADE'}{'on'} /> | | |
301 | <input type='radio' name='AUTOUPGRADE' value='off' $checked{'AUTOUPGRADE'}{'off'} /> off </td></tr> | |
302 | <tr><td align='left' width='45%'>$Lang::tr{'pakfire health check'}</td><td align="left"> | |
303 | on <input type='radio' name='HEALTHCHECK' value='on' $checked{'HEALTHCHECK'}{'on'} /> | | |
304 | <input type='radio' name='HEALTHCHECK' value='off' $checked{'HEALTHCHECK'}{'off'} /> off </td></tr> | |
305 | <tr><td align='left' width='45%'>$Lang::tr{'pakfire register'}</td><td align="left"> | |
306 | on <input type='radio' name='UUID' value='on' $checked{'UUID'}{'on'} /> | | |
307 | <input type='radio' name='UUID' value='off' $checked{'UUID'}{'off'} /> off </td></tr> | |
308 | <tr><td colspan="2" align="center"><input type="submit" name="ACTION" value="$Lang::tr{'save'}" /></td></tr> | |
309 | </table> | |
310 | </form> | |
311 | END | |
312 | ||
313 | &Header::closebox(); | |
314 | &Header::closebigbox(); | |
315 | &Header::closepage(); |