1
|
#!/usr/local/bin/php
|
2
|
<?php
|
3
|
/* $Id$ */
|
4
|
/*
|
5
|
pkg_mgr_install.php
|
6
|
part of pfSense (http://www.pfSense.com)
|
7
|
Copyright (C) 2005 Scott Ullrich and Colin Smith
|
8
|
All rights reserved.
|
9
|
|
10
|
Redistribution and use in source and binary forms, with or without
|
11
|
modification, are permitted provided that the following conditions are met:
|
12
|
|
13
|
1. Redistributions of source code must retain the above copyright notice,
|
14
|
this list of conditions and the following disclaimer.
|
15
|
|
16
|
2. Redistributions in binary form must reproduce the above copyright
|
17
|
notice, this list of conditions and the following disclaimer in the
|
18
|
documentation and/or other materials provided with the distribution.
|
19
|
|
20
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
POSSIBILITY OF SUCH DAMAGE.
|
30
|
*/
|
31
|
|
32
|
require("guiconfig.inc");
|
33
|
require("xmlparse_pkg.inc");
|
34
|
|
35
|
conf_mount_rw();
|
36
|
|
37
|
if(!file_exists("/var/db/pkg"))
|
38
|
mkdir("/var/db/pkg");
|
39
|
|
40
|
/* /usr/local/pkg/ is where xml package files are stored. */
|
41
|
make_dirs("/usr/local/pkg");
|
42
|
/* /usr/local/pkg/pf is where custom php hook packages live to alter the rules when needed */
|
43
|
make_dirs("/usr/local/pkg/pf");
|
44
|
/* /usr/local/www/ext is where package links live for the left hand pane */
|
45
|
make_dirs("/usr/local/www/ext");
|
46
|
|
47
|
$a_out = &$pkg_config['packages'];
|
48
|
$packages_to_install = Array();
|
49
|
$static_output = "";
|
50
|
$static_status = "";
|
51
|
$sendto = "output";
|
52
|
|
53
|
?>
|
54
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
55
|
<html>
|
56
|
<head>
|
57
|
<title><?=gentitle("System: Package Manager: Install Package");?></title>
|
58
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
59
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
60
|
</head>
|
61
|
|
62
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
63
|
<?php
|
64
|
include("fbegin.inc");
|
65
|
?>
|
66
|
<p class="pgtitle">System: Package Manager: Install Package</p>
|
67
|
<form action="pkg_mgr_install.php" method="post">
|
68
|
|
69
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
70
|
<?php
|
71
|
|
72
|
if($_GET['showlog'] <> "") {
|
73
|
echo "<table>";
|
74
|
echo "<tr><td>";
|
75
|
echo "<pre>";
|
76
|
// reopen and read log in
|
77
|
$fd = fopen("{$g['tmp_path']}/pkg_mgr.log", "r");
|
78
|
$tmp = "";
|
79
|
while(!feof($fd)) {
|
80
|
$tmp .= fread($fd,49);
|
81
|
}
|
82
|
fclose($fd);
|
83
|
echo $tmp;
|
84
|
echo "</pre>";
|
85
|
echo "</td></tr>";
|
86
|
echo "</table>";
|
87
|
exit;
|
88
|
}
|
89
|
|
90
|
/*
|
91
|
* open logging facility
|
92
|
*/
|
93
|
$fd_log = fopen("{$g['tmp_path']}/pkg_mgr.log", "w");
|
94
|
if(!$fd_log) log_error("Warning, could not open {$g['tmp_path']}/pkg_mgr.log for writing");
|
95
|
fwrite($fd_log, "Begin of Package Manager installation session.\n");
|
96
|
|
97
|
fetch_latest_pkg_config();
|
98
|
|
99
|
$pkg_config = parse_xml_config_pkg("{$g['tmp_path']}/pkg_config.xml", "pfsensepkgs");
|
100
|
|
101
|
if(!$pkg_config['packages'])
|
102
|
print_info_box_np("Could not find any packages in pkg_config.xml");
|
103
|
|
104
|
?>
|
105
|
<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td>
|
106
|
<ul id="tabnav">
|
107
|
<li class="tabinact"><a href="pkg_mgr.php">Available Packages</a></li>
|
108
|
<li class="tabact">Installed Packages</a></li>
|
109
|
</ul>
|
110
|
</td></tr>
|
111
|
<tr>
|
112
|
<td class="tabcont">
|
113
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
114
|
<tr>
|
115
|
<td>
|
116
|
<!-- progress bar -->
|
117
|
<center>
|
118
|
|
119
|
<table height='15' width='420' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
|
120
|
<tr>
|
121
|
|
122
|
<td background="bar_left.gif" height='15' width='5'>
|
123
|
</td>
|
124
|
<td>
|
125
|
<table id="progholder" name="progholder" height='15' width='410' border='0' colspacing='0' cellpadding='0' cellspacing='0'><td background="bar_gray.gif" valign="top" align="left"><img src='bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'></td></table>
|
126
|
</td>
|
127
|
<td background="bar_right.gif" height='15' width='5'>
|
128
|
</td>
|
129
|
</tr>
|
130
|
</table>
|
131
|
|
132
|
|
133
|
<br>
|
134
|
<!-- status box -->
|
135
|
<textarea cols="60" rows="1" name="status" id="status" wrap="hard">Beginning package installation.</textarea>
|
136
|
<!-- command output box -->
|
137
|
<textarea cols="60" rows="25" name="output" id="output" wrap="hard"></textarea>
|
138
|
</center>
|
139
|
</td>
|
140
|
</tr>
|
141
|
</table>
|
142
|
</td>
|
143
|
</tr>
|
144
|
</table>
|
145
|
</form>
|
146
|
<?php include("fend.inc"); ?>
|
147
|
</body>
|
148
|
</html>
|
149
|
|
150
|
<?php
|
151
|
|
152
|
|
153
|
|
154
|
if($_GET['mode'] == "reinstallall") {
|
155
|
/*
|
156
|
* Loop through installed packages and if name matches
|
157
|
* push the package id onto array to reinstall
|
158
|
*/
|
159
|
$instpkgs = array();
|
160
|
$output_static = "";
|
161
|
$counter = 0;
|
162
|
if(is_array($pkg_config['packages']['package']))
|
163
|
if(!is_string($instpkgs[0])) foreach($config['installedpackages']['package'] as $index => $instpkg) $instpkgs[] = $instpkg['name'];
|
164
|
foreach($pkg_config['packages']['package'] as $index => $available_package) {
|
165
|
if(in_array($available_package['name'], $instpkgs)) {
|
166
|
$packages_to_install[] = $index;
|
167
|
$output_static .= "Adding " . $package['name'] . " to installation array.\n";
|
168
|
update_output_window($output_static);
|
169
|
fwrite($fd_log, "Adding (" . $counter . ") " . $package['name'] . " to package installation array.\n" . $status);
|
170
|
}
|
171
|
}
|
172
|
} else {
|
173
|
/*
|
174
|
* Push the desired package id onto the install packages array
|
175
|
*/
|
176
|
fwrite($fd_log, "Single package installation started.\n");
|
177
|
$packages_to_install[] = $_GET['id'];
|
178
|
}
|
179
|
|
180
|
/*
|
181
|
* Loop through packages_to_install, installing needed packages
|
182
|
*/
|
183
|
foreach ($packages_to_install as $id) {
|
184
|
|
185
|
fwrite($fd_log, "Begin package ${id}\n");
|
186
|
|
187
|
$pkg_config = parse_xml_config_pkg("{$g['tmp_path']}/pkg_config.xml", "pfsensepkgs");
|
188
|
|
189
|
/*
|
190
|
* install the package
|
191
|
*/
|
192
|
|
193
|
// Ensure directories are in place for pkg_add.
|
194
|
safe_mkdir("{$g['www_path']}/ext/Services", 0755);
|
195
|
safe_mkdir("{$g['www_path']}/ext/System", 0755);
|
196
|
safe_mkdir("{$g['www_path']}/ext/Interfaces", 0755);
|
197
|
safe_mkdir("{$g['www_path']}/ext/Firewall", 0755);
|
198
|
safe_mkdir("{$g['www_path']}/ext/VPN", 0755);
|
199
|
safe_mkdir("{$g['www_path']}/ext/Status", 0755);
|
200
|
safe_mkdir("{$g['www_path']}/ext/Diagnostics", 0755);
|
201
|
safe_mkdir("/usr/local/pkg", 0755);
|
202
|
|
203
|
$a_out = &$pkg_config['packages']['package'];
|
204
|
|
205
|
if($pkg_config['packages']['package'][$id]['verifyinstalledpkg'] <> "")
|
206
|
$package_to_verify = $pkg_config['packages']['package'][$id]['verifyinstalledpkg'];
|
207
|
else
|
208
|
$package_to_verify = $pkg_config['packages']['package'][$id]['name'];
|
209
|
|
210
|
$pkgent = array();
|
211
|
$pkgent['name'] = $pkg_config['packages']['package'][$id]['name'];
|
212
|
$pkgent['descr'] = $pkg_config['packages']['package'][$id]['descr'];
|
213
|
$pkgent['category'] = $pkg_config['packages']['package'][$id]['category'];
|
214
|
|
215
|
$pkgent['version'] = $pkg_config['packages']['package'][$id]['version'];
|
216
|
|
217
|
$pkgent['depends_on_package'] = $a_out[$id]['depends_on_package'];
|
218
|
$pkgent['depends_on_package_base_url'] = $a_out[$id]['depends_on_package_base_url'];
|
219
|
$pkgent['pfsense_package'] = $a_out[$id]['pfsense_package'];
|
220
|
$pkgent['pfsense_package_base_url'] = $a_out[$id]['pfsense_package_base_url'];
|
221
|
$pkgent['configurationfile'] = $a_out[$id]['configurationfile'];
|
222
|
$pkgent['exclude_dependency'] = $a_out[$id]['exclude_dependency'];
|
223
|
if($pkg_config['packages']['package'][$id]['logging']) {
|
224
|
// logging facilities.
|
225
|
$pkgent['logging']['facility'] = $pkg_config['packages']['package'][$id]['logging']['facility'];
|
226
|
$pkgent['logging']['logfile_name'] = $pkg_config['packages']['package'][$id]['logging']['logfile_name'];
|
227
|
mwexec("/usr/sbin/clog -i -s 32768 {$g['varlog_path']}" . $pkgent['logging']['logfile_name']);
|
228
|
chmod($g['varlog_path'] . $pkgent['logging']['logfile_name'], 0600);
|
229
|
fwrite($fd_log, "Adding text to file /etc/syslog.conf\n");
|
230
|
add_text_to_file("/etc/syslog.conf", $pkgent['logging']['facilityname'] . "\t\t\t" . $pkgent['logging']['logfilename']);
|
231
|
mwexec("/usr/bin/killall -HUP syslogd");
|
232
|
}
|
233
|
$a_out = &$config['packages']['package']; // save item to installedpkgs
|
234
|
fwrite($fd_log, "Begining (" . $id. ") " . $pkgent['name'] . " package installation.\n" . $status);
|
235
|
|
236
|
log_error("Begining (" . $id. ") " . $pkgent['name'] . " package installation.");
|
237
|
$static_status = "Beginning package installation for " . $pkgent['name'] . "...";
|
238
|
update_status($static_status);
|
239
|
|
240
|
if($pkg_config['packages']['package'][$id]['config_file'] <> "") {
|
241
|
$static_output .= "Downloading package configuration file... ";
|
242
|
download_file_with_progress_bar($pkg_config['packages']['package'][$id]['config_file'], "/usr/local/pkg/" . substr(strrchr($pkg_config['packages']['package'][$id]['config_file'], '/'), 1));
|
243
|
fwrite($fd_log, "Downloading configuration file " . $pkg_config['packages']['package'][$id]['config_file'] . "...\n");
|
244
|
if(!file_exists("/usr/local/pkg/" . substr(strrchr($pkg_config['packages']['package'][$id]['config_file'], '/'), 1))) {
|
245
|
fwrite($fd_log, "ERROR! Could not fetch " . $pkg_config['packages']['package'][$id]['config_file']);
|
246
|
$static_output .= "failed!\n\nInstallation aborted.";
|
247
|
update_output_window($static_output);
|
248
|
echo "<br>Show <a href=\"pkg_mgr_install.php?showlog=true\">install log</a></center>";
|
249
|
exit;
|
250
|
}
|
251
|
$static_output .= "done.\n";
|
252
|
update_output_window($static_output);
|
253
|
}
|
254
|
|
255
|
update_status("Downloading and installing " . $pkgent['name'] . " and its dependencies.");
|
256
|
fwrite($fd_log, "Downloading and installing " . $pkgent['name'] . " - " . $pkgent['pfsense_package'] . "...\n");
|
257
|
|
258
|
/*
|
259
|
* Open a /tmp/y file which will basically tell the
|
260
|
* pkg_delete script to delete users and such if it asks.
|
261
|
*/
|
262
|
$fd = fopen("{$g['tmp_path']}/y", "w");
|
263
|
fwrite($fd, "y\n");
|
264
|
fwrite($fd, "y\n");
|
265
|
fwrite($fd, "y\n");
|
266
|
fwrite($fd, "y\n");
|
267
|
fwrite($fd, "y\n");
|
268
|
fwrite($fd, "y\n");
|
269
|
fwrite($fd, "y\n");
|
270
|
fwrite($fd, "y\n");
|
271
|
fwrite($fd, "y\n");
|
272
|
fwrite($fd, "y\n");
|
273
|
fwrite($fd, "y\n");
|
274
|
fwrite($fd, "y\n");
|
275
|
fwrite($fd, "y\n");
|
276
|
fwrite($fd, "y\n");
|
277
|
fwrite($fd, "y\n");
|
278
|
fclose($fd);
|
279
|
|
280
|
/* This directive is not yet used.
|
281
|
if ($pkgent['pfsense_package_base_url'] <> "") {
|
282
|
fwrite($fd_log, "Executing: cd {$g['tmp_path']}/ && /usr/sbin/pkg_add -r " . $pkgent['pfsense_package_base_url'] . "/" . $pkgent['pfsense_package'] . "\n" . $text);
|
283
|
$text = exec_command_and_return_text("cd {$g['tmp_path']}/ && cat {$g['tmp_path']}/y | /usr/sbin/pkg_add -r " . $pkgent['pfsense_package_base_url'] . "/" . $pkgent['pfsense_package']);
|
284
|
update_output_window($text);
|
285
|
}
|
286
|
*/
|
287
|
|
288
|
if ($pkgent['depends_on_package_base_url'] <> "") {
|
289
|
update_status("Installing " . $pkgent['name'] . " and its dependencies.");
|
290
|
$static_output .= "Downloading " . $pkgent['name'] . " and its dependencies... ";
|
291
|
$static_orig = $static_output;
|
292
|
$static_output .= "\n";
|
293
|
update_output_window($static_output);
|
294
|
exec("ls /var/db/pkg", $is_installed);
|
295
|
$pkg_installed = false;
|
296
|
if(isset($pkg_config['packages']['package'][$id]['skip_install_checks'])) $pkg_installed = true;
|
297
|
foreach($is_installed as $is_inst) {
|
298
|
if($is_inst == $pkgent['name'] . '-' . $pkgent['version']) {
|
299
|
$pkg_installed = true;
|
300
|
break;
|
301
|
}
|
302
|
}
|
303
|
if($pkg_installed == false) pkg_fetch_recursive($pkgent['name'] . "-" . $pkgent['version'], $pkgent['depends_on_package'], 0, $pkgent['depends_on_package_base_url']);
|
304
|
$static_output = $static_orig . "done.\n";
|
305
|
update_output_window($static_output);
|
306
|
}
|
307
|
|
308
|
if ($pkgent['depends_on_package_base_url'] <> "" or $pkgent['pfsense_package_base_url'] <> "") {
|
309
|
$static_output .= "Checking for successful package installation... ";
|
310
|
update_output_window($static_output);
|
311
|
if($pkg_installed == false) {
|
312
|
exec("ls /var/db/pkg", $is_installed);
|
313
|
foreach($is_installed as $is_inst) {
|
314
|
if($is_inst == $pkgent['name'] . '-' . $pkgent['version']) {
|
315
|
$pkg_installed = true;
|
316
|
break;
|
317
|
}
|
318
|
}
|
319
|
}
|
320
|
fwrite($fd_log, $is_installed[0] . "\n");
|
321
|
if($pkg_installed == true) {
|
322
|
$static_output .= "done.\n";
|
323
|
update_output_window($static_output);
|
324
|
fwrite($fd_log, "pkg_add successfully completed.\n");
|
325
|
} else {
|
326
|
$static_output .= "failed!\n\nInstallation aborted.";
|
327
|
update_output_window($static_output);
|
328
|
fwrite($fd_log, "Package WAS NOT installed properly.\n");
|
329
|
fclose($fd_log);
|
330
|
/*
|
331
|
* keep progressbar visible
|
332
|
|
333
|
echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';</script>";
|
334
|
echo "\n<script language=\"JavaScript\">document.progholder.style.visibility='hidden';</script>";
|
335
|
*/
|
336
|
sleep(1);
|
337
|
die;
|
338
|
}
|
339
|
}
|
340
|
|
341
|
$config = parse_xml_config("{$g['conf_path']}/config.xml", $g['xml_rootobj']);
|
342
|
|
343
|
$pkgid = get_pkg_id($pkgent['name']);
|
344
|
|
345
|
if(!$_GET['mode'] == "reinstallall") {
|
346
|
$static_output .= "Saving updated package information... ";
|
347
|
update_output_window($static_output);
|
348
|
if($pkgid == -1) {
|
349
|
$config['installedpackages']['package'][] = $pkgent;
|
350
|
$changedesc = "Installed {$pkgent['name']} package.";
|
351
|
$to_output = "done.\n";
|
352
|
} else {
|
353
|
$config['installedpackages']['package'][$pkgid] = $pkgent;
|
354
|
$changedesc = "Overwrote previous installation of {$pkgent['name']}.";
|
355
|
$to_output = "overwrite!\n";
|
356
|
}
|
357
|
write_config($changedesc);
|
358
|
conf_mount_rw();
|
359
|
$static_output .= $to_output;
|
360
|
update_output_window($static_output);
|
361
|
}
|
362
|
|
363
|
$name = $pkgent['name'];
|
364
|
|
365
|
update_status("Finishing package installation...");
|
366
|
|
367
|
/*
|
368
|
* parse the config file for this package and install neededtext items.
|
369
|
*
|
370
|
*/
|
371
|
if(file_exists("/usr/local/pkg/" . $pkgent['name'] . ".xml")) {
|
372
|
$package_conf = parse_xml_config_pkg("/usr/local/pkg/" . $pkgent['name'] . ".xml", "packagegui");
|
373
|
if($package_conf['modify_system']['item'] <> "") {
|
374
|
$static_output .= "Modifying system files... ";
|
375
|
update_output_window($static_output);
|
376
|
foreach ($package_conf['modify_system']['item'] as $ms) {
|
377
|
if($ms['textneeded']) {
|
378
|
add_text_to_file($ms['modifyfilename'],$ms['textneeded']);
|
379
|
}
|
380
|
}
|
381
|
$static_output .= "done.\n";
|
382
|
update_output_window($static_output);
|
383
|
}
|
384
|
|
385
|
/*
|
386
|
* fetch additional files needed for package if defined
|
387
|
* and uncompress if needed.
|
388
|
*/
|
389
|
if ($package_conf['additional_files_needed'] <> "") {
|
390
|
$static_output .= "Downloading additional files needed for " . $pkgent['name'] . "... ";
|
391
|
update_output_window($static_output);
|
392
|
$i = 0;
|
393
|
$afn_count = count($package_conf['additional_files_needed']) -1;
|
394
|
foreach($package_conf['additional_files_needed'] as $afn) {
|
395
|
$filename = get_filename_from_url($afn['item'][0]);
|
396
|
fwrite($fd_log, "Downloading additional files needed for package " . $filename . "...\n");
|
397
|
if ($i == $afn_count) {
|
398
|
$static_orig = $static_output . $filename . ".\n";
|
399
|
} else {
|
400
|
$static_orig = $static_output . $filename . ", ";
|
401
|
}
|
402
|
$static_output .= $filename . " ";
|
403
|
update_output_window($static_output);
|
404
|
$prefix = "/usr/local/pkg/";
|
405
|
$pkg_chmod = "";
|
406
|
if($afn['chmod'] <> "")
|
407
|
$pkg_chmod = $afn['chmod'];
|
408
|
if($afn['prefix'] <> "")
|
409
|
$prefix = $afn['prefix'];
|
410
|
download_file_with_progress_bar($afn['item'][0], $prefix . $filename);
|
411
|
$static_output = $static_orig;
|
412
|
update_output_window($static_output);
|
413
|
if(stristr($filename, ".tgz") <> "") {
|
414
|
update_status("Extracting tgz archive to -C for " . $filename);
|
415
|
fwrite($fd_log, "Extracting tgz archive to -C for " . $filename . " ...\n");
|
416
|
system("/usr/bin/tar xzvf " . $prefix . $filename . " -C / >/dev/null 2>&1");
|
417
|
}
|
418
|
if($pkg_chmod <> "") {
|
419
|
fwrite($fd_log, "Changing file mode for {$pkg_chmod} {$prefix}{$filename}\n");
|
420
|
chmod($prefix . $filename, $pkg_chmod);
|
421
|
system("/bin/chmod {$pkg_chmod} {$prefix}{$filename}");
|
422
|
}
|
423
|
$i++;
|
424
|
}
|
425
|
}
|
426
|
|
427
|
/*
|
428
|
* loop through menu installation items
|
429
|
* installing multiple items if need be.
|
430
|
*/
|
431
|
if(is_array($package_conf['menu'])) {
|
432
|
$static_output .= "Installing menu items... ";
|
433
|
update_output_window($static_output);
|
434
|
foreach ($package_conf['menu'] as $menu) {
|
435
|
// install menu item into the ext folder
|
436
|
fwrite($fd_log, "Adding menu option to " . $menu['section'] . "/" . $menu['name'] . "\n");
|
437
|
$fd = fopen("{$g['www_path']}/ext/" . $menu['section'] . "/" . $menu['name'] , "w");
|
438
|
if($menu['url'] <> "") {
|
439
|
// override $myurl for script.
|
440
|
$toeval = "\$myurl = \"" . getenv("HTTP_HOST") . "\"; \n";
|
441
|
$error_message = "";
|
442
|
if(php_check_syntax($toeval, $error_message) == false)
|
443
|
eval($toeval);
|
444
|
// eval url so that above $myurl item can be processed if need be.
|
445
|
$urltmp = $menu['url'];
|
446
|
$toeval = "\$url = \"" . $urltmp . "\"; \n";
|
447
|
if(php_check_syntax($toeval, $error_message) == false)
|
448
|
eval($toeval);
|
449
|
fwrite($fd, $url . "\n");
|
450
|
} else {
|
451
|
$xml = "";
|
452
|
if(stristr($menu['configfile'],".xml") == "") $xml = ".xml";
|
453
|
fwrite($fd, "/pkg.php?xml=" . $menu['configfile'] . $xml . "\n");
|
454
|
}
|
455
|
fclose($fd);
|
456
|
}
|
457
|
$static_output .= "done.\n";
|
458
|
update_output_window($static_output);
|
459
|
}
|
460
|
} else {
|
461
|
update_output_window("WARNING! /usr/local/pkg/" . $pkgent['name'] . ".xml" . " does not exist!\n");
|
462
|
fwrite($fd_log, "WARNING! /usr/local/pkg/" . $pkgent['name'] . ".xml" . " does not exist!\n");
|
463
|
}
|
464
|
fwrite($fd_log, "End of Package Manager installation session.\n");
|
465
|
|
466
|
/* return dependency list to output later.
|
467
|
$command = "TODELETE=`ls /var/db/pkg | grep " . $name . "` && /usr/sbin/pkg_info -r \$TODELETE | grep Dependency: | cut -d\" \" -f2";
|
468
|
$dependencies = exec_command_and_return_text($command);
|
469
|
if($dependencies == "")
|
470
|
fwrite($fd_log, "Installed package " . $name);
|
471
|
else
|
472
|
fwrite($fd_log, "Installed package " . $name . " and the following dependencies:\n" . $dependencies);
|
473
|
*/
|
474
|
|
475
|
if($package_conf['custom_php_install_command'] <> "") {
|
476
|
$static_output .= "Executing post install commands... ";
|
477
|
update_output_window($static_output);
|
478
|
if($package_conf['custom_php_global_functions'] <> "")
|
479
|
if(php_check_syntax($package_conf['custom_php_global_functions'], $error_message) == false)
|
480
|
eval($package_conf['custom_php_global_functions']);
|
481
|
fwrite($fd_log, "Executing post install commands...\n");
|
482
|
$error_message = "";
|
483
|
if($package_conf['custom_php_command_before_form'] <> "")
|
484
|
if(php_check_syntax($package_conf['custom_php_command_before_form'], $error_message) == false)
|
485
|
eval($package_conf['custom_php_command_before_form']);
|
486
|
if(php_check_syntax($package_conf['custom_php_install_command'], $error_message) == false)
|
487
|
eval($package_conf['custom_php_install_command']);
|
488
|
$static_output .= "done.\n";
|
489
|
update_output_window($static_output);
|
490
|
}
|
491
|
update_status("Package installation completed.");
|
492
|
$static_output .= "\nPackage installation successful.\n";
|
493
|
update_output_window($static_output);
|
494
|
fwrite($fd_log, "Package installation completed.\n");
|
495
|
log_error("Package " . $pkgent['name'] . " installation completed successfully.\n");
|
496
|
fwrite($fd_log, "Status window output:\n" . $static_output);
|
497
|
}
|
498
|
|
499
|
// Delete all temporary package tarballs and staging areas.
|
500
|
unlink_if_exists("/tmp/apkg_*");
|
501
|
rmdir_recursive("/var/tmp/instmp*");
|
502
|
|
503
|
|
504
|
// close log
|
505
|
fclose($fd_log);
|
506
|
|
507
|
echo "<p><center>Installation completed. Show <a href=\"pkg_mgr_install.php?showlog=true\">install log</a></center>";
|
508
|
|
509
|
/*
|
510
|
* keep progressbar visible
|
511
|
echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';</script>";
|
512
|
*/
|
513
|
conf_mount_ro();
|
514
|
|
515
|
?>
|