Revision 19fd2947
Added by Scott Ullrich over 20 years ago
usr/local/www/pkg_mgr_install.php | ||
---|---|---|
176 | 176 |
} |
177 | 177 |
} |
178 | 178 |
|
179 |
$pkg_config = parse_xml_config("{$g['tmp_path']}/pkg_config.xml", "pfsensepkgs"); |
|
179 |
$pkg_config = parse_xml_config_pkg("{$g['tmp_path']}/pkg_config.xml", "pfsensepkgs");
|
|
180 | 180 |
|
181 | 181 |
$id = $_GET['id']; |
182 | 182 |
|
... | ... | |
239 | 239 |
$pkgent['descr'] = $pkg_config['packages']['package'][$id]['descr']; |
240 | 240 |
$pkgent['category'] = $pkg_config['packages']['package'][$id]['category']; |
241 | 241 |
$pkgent['depends_on_package'] = $a_out[$id]['depends_on_package']; |
242 |
$pkgent['depends_on_package_base'] = $a_out[$id]['depends_on_package_base'];
|
|
242 |
$pkgent['depends_on_package_base_url'] = $a_out[$id]['depends_on_package_base_url'];
|
|
243 | 243 |
$pkgent['pfsense_package'] = $a_out[$id]['pfsense_package']; |
244 |
$pkgent['pfsense_package_base'] = $a_out[$id]['pfsense_package_base'];
|
|
244 |
$pkgent['pfsense_package_base_url'] = $a_out[$id]['pfsense_package_base_url'];
|
|
245 | 245 |
$pkgent['configurationfile'] = $a_out[$id]['configurationfile']; |
246 |
$a_out = &$config['packages']['package']; |
|
246 |
if($pkg_config['packages']['package'][$id]['logging']) { |
|
247 |
// logging facilities. |
|
248 |
$pkgent['logging']['facility'] = $pkg_config['packages']['package'][$id]['logging']['facility']; |
|
249 |
$pkgent['logging']['logfile_name'] = $pkg_config['packages']['package'][$id]['logging']['logfile_name']; |
|
250 |
mwexec("clog -i -s 32768 /var/log/" . $pkgent['logging']['logfile_name']); |
|
251 |
mwexec("chmod 0600 /var/log/" . $pkgent['logging']['logfile_name']); |
|
252 |
add_text_to_file("/etc/syslog.conf",$pkgent['logging']['facility'] . "\t\t\t" . $pkgent['logging']['logfile_name']); |
|
253 |
mwexec("/usr/bin/killall -HUP syslogd"); |
|
254 |
} |
|
255 |
$a_out = &$config['packages']['package']; // save item to installedpkgs |
|
247 | 256 |
|
248 | 257 |
update_progress_bar($pb_percent); |
249 | 258 |
$pb_percent += 10; |
... | ... | |
254 | 263 |
print_info_box_np("NOTICE! " . $pkgent['name'] . " is already installed! Installation will be registered."); |
255 | 264 |
} |
256 | 265 |
|
266 |
if($pkg_config['packages']['package'][$id]['config_file'] <> "") { |
|
267 |
update_status("Downloading configuration file."); |
|
268 |
fwrite($fd_log, "Downloading configuration file " . $pkg_config['packages']['package'][$id]['config_file'] . " ... \n"); |
|
269 |
update_progress_bar($pb_percent); |
|
270 |
$pb_percent += 10; |
|
271 |
mwexec("cd /usr/local/pkg/ && fetch " . $pkg_config['packages']['package'][$id]['config_file']); |
|
272 |
if(!file_exists("/usr/local/pkg/" . $pkgent['name'] . ".xml")) { |
|
273 |
update_output_window("ERROR! Could not fetch " . $pkg_config['packages']['package'][$id]['config_file'] . "\n"); |
|
274 |
} |
|
275 |
} |
|
276 |
|
|
257 | 277 |
update_status("Downloading and installing " . $pkgent['name'] . " - " . $pkgent['pfsense_package'] . " and its dependencies ... This could take a moment ..."); |
258 | 278 |
fwrite($fd_log, "Downloading and installing " . $pkgent['name'] . " ... \n"); |
259 | 279 |
|
260 | 280 |
update_progress_bar($pb_percent); |
261 | 281 |
$pb_percent += 10; |
262 | 282 |
|
263 |
$text = exec_command_and_return_text("cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['pfsense_package_base'] . "/" . $pkgent['pfsense_package']); |
|
264 |
update_output_window($text); |
|
265 |
fwrite($fd_log, "Executing: cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['pfsense_package_base'] . "/" . $pkgent['pfsense_package'] . "\n" . $text); |
|
283 |
if ($pkgent['pfsense_package_base_url'] <> "") { |
|
284 |
$text = exec_command_and_return_text("cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['pfsense_package_base_url'] . "/" . $pkgent['pfsense_package']); |
|
285 |
update_output_window($text); |
|
286 |
fwrite($fd_log, "Executing: cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['pfsense_package_base_url'] . "/" . $pkgent['pfsense_package'] . "\n" . $text); |
|
287 |
} |
|
266 | 288 |
|
267 | 289 |
update_progress_bar($pb_percent); |
268 | 290 |
$pb_percent += 10; |
269 | 291 |
|
270 |
if ($pkgent['pfsense_package_base']) {
|
|
271 |
update_status("Downloading and installing " . $pkgent['name'] . " - " . $pkgent['depends_on_package_base'] . " and its dependencies ... This could take a moment ..."); |
|
272 |
$text = exec_command_and_return_text("cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['depends_on_package_base'] . "/" . $pkgent['depends_on_package']); |
|
292 |
if ($pkgent['depends_on_package_base_url'] <> "") {
|
|
293 |
update_status("Downloading and installing " . $pkgent['name'] . " - " . $pkgent['depends_on_package_base_url'] . " and its dependencies ... This could take a moment ...");
|
|
294 |
$text = exec_command_and_return_text("cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['depends_on_package_base_url'] . "/" . $pkgent['depends_on_package']);
|
|
273 | 295 |
update_output_window($text); |
274 |
fwrite($fd_log, "cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['depends_on_package_base'] . "/" . $pkgent['depends_on_package'] . "\n" . $text);; |
|
296 |
fwrite($fd_log, "cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['depends_on_package_base_url'] . "/" . $pkgent['depends_on_package'] . "\n" . $text);;
|
|
275 | 297 |
} |
276 | 298 |
|
277 | 299 |
update_progress_bar($pb_percent); |
... | ... | |
304 | 326 |
|
305 | 327 |
// parse the config file for this package and install neededtext items. |
306 | 328 |
if(file_exists("/usr/local/pkg/" . $pkgent['name'] . ".xml")) { |
307 |
$config = parse_xml_config("/usr/local/pkg/" . $pkgent['name'] . ".xml", "packagegui"); |
|
308 |
foreach ($config['modify_system']['item'] as $ms) { |
|
309 |
update_progress_bar($pb_percent); |
|
310 |
$pb_percent += 10; |
|
311 |
if($ms['textneeded']) { |
|
312 |
fwrite($fd_log, "Adding needed text items:\n"); |
|
313 |
$filecontents = exec_command_and_return_text("cat " . $ms['modifyfilename']); |
|
314 |
$text = ereg_replace($ms['textneeded'], "", $filecontents); |
|
315 |
$text .= $ms['textneeded']; |
|
316 |
fwrite($fd_log, $ms['textneeded'] . "\n"); |
|
317 |
$fd = fopen($ms['modifyfilename'], "w"); |
|
318 |
fwrite($fd, $text . "\n"); |
|
319 |
fclose($fd); |
|
320 |
} |
|
329 |
$package_conf = parse_xml_config_pkg("/usr/local/pkg/" . $pkgent['name'] . ".xml", "packagegui"); |
|
330 |
if($package_conf['modify_system']['item'] <> "") { |
|
331 |
foreach ($package_conf['modify_system']['item'] as $ms) { |
|
332 |
update_progress_bar($pb_percent); |
|
333 |
$pb_percent += 10; |
|
334 |
if($ms['textneeded']) { |
|
335 |
add_text_to_file($ms['modifyfilename'],$ms['textneeded']); |
|
336 |
} |
|
337 |
} |
|
321 | 338 |
} |
322 | 339 |
// install menu item into the ext folder |
323 |
fwrite($fd_log, "Adding menu option to " . $config['menu']['section'] . "/" . $config['name'] . ":\n");
|
|
324 |
$fd = fopen("/usr/local/www/ext/" . $config['menu']['section'] . "/" . $config['name'] , "w");
|
|
325 |
fwrite($fd, "/usr/local/www/pkg.php?xml=" . $config['name'] . "\n");
|
|
340 |
fwrite($fd_log, "Adding menu option to " . $package_conf['menu']['section'] . "/" . $config['name'] . "\n");
|
|
341 |
$fd = fopen("/usr/local/www/ext/" . $package_conf['menu']['section'] . "/" . $package_conf['name'] , "w");
|
|
342 |
fwrite($fd, "/usr/local/www/pkg.php?xml=" . $package_conf['menu']['name'] . "\n");
|
|
326 | 343 |
fclose($fd); |
327 | 344 |
} else { |
328 | 345 |
update_output_window("WARNING! /usr/local/pkg/" . $pkgent['name'] . ".xml" . " does not exist!\n"); |
... | ... | |
357 | 374 |
// close log |
358 | 375 |
fclose($fd_log); |
359 | 376 |
|
360 |
if($pkgent['custom_php_install_command']) {
|
|
361 |
exec($pkgent['custom_php_install_command']);
|
|
377 |
if($package_conf['custom_php_install_command']) {
|
|
378 |
eval($package_conf['custom_php_install_command']);
|
|
362 | 379 |
} |
363 | 380 |
|
364 | 381 |
// reopen and read log in |
... | ... | |
376 | 393 |
echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';</script>"; |
377 | 394 |
echo "\n<script language=\"JavaScript\">document.progholder.style.visibility='hidden';</script>"; |
378 | 395 |
|
396 |
function add_text_to_file($file, $text) { |
|
397 |
fwrite($fd_log, "Adding needed text items:\n"); |
|
398 |
$filecontents = exec_command_and_return_text("cat " . $file); |
|
399 |
$text = ereg_replace($text, "", $filecontents); |
|
400 |
$text .= $text; |
|
401 |
fwrite($fd_log, $text . "\n"); |
|
402 |
$fd = fopen($file, "w"); |
|
403 |
fwrite($fd, $text . "\n"); |
|
404 |
fclose($fd); |
|
405 |
} |
|
406 |
|
|
379 | 407 |
?> |
380 | 408 |
|
381 | 409 |
|
Also available in: Unified diff
Packages continued. New log file facility added.