/* Write out configuration to create a backup prior to pkg install. */ write_config(gettext("Creating restore point before package installation.")); switch ($_POST['mode']) { case 'delete': uninstall_package($pkgid); update_status(gettext("Package deleted.")); $static_output .= "\n" . gettext("Package deleted."); update_output_window($static_output); filter_configure(); break; case 'reinstallxml': pkg_fetch_config_file($pkgid); pkg_fetch_additional_files($pkgid); break; case 'reinstallpkg': delete_package_xml($pkgid); if (install_package($pkgid) != 0) { update_status(gettext("Package reinstallation failed.")); $static_output .= "\n" . gettext("Package reinstallation failed."); update_output_window($static_output); } else { update_status(gettext("Package reinstalled.")); $static_output .= "\n" . gettext("Package reinstalled."); update_output_window($static_output); filter_configure(); } @file_put_contents("/tmp/{$pkgid}.info", $static_output); $pkgid = htmlspecialchars($pkgid); echo "<script type='text/javascript'>document.location=\"pkg_mgr_install.php?mode=installedinfo&pkg={$pkgid}\";</script>"; send_event("service restart packages"); break;
case "reinstallall": if ($config['installedpackages']['package']) { exec("rm -rf /var/db/pkg/*"); } if ($config['installedpackages']['package']) { foreach ($config['installedpackages']['package'] as $package) { $todo[] = array('name' => $package['name'], 'version' => $package['version']); } } $pkg_id = 0; foreach ($todo as $pkgtodo) { $static_output = ""; if ($pkgtodo['name']) { update_output_window($static_output); delete_package($pkgtodo['name'] . '-' . $pkgtodo['version'], $pkg_id); delete_package_xml($pkgtodo['name']); install_package($pkgtodo['name']); $pkg_id++; } } update_status("All packages reinstalled."); $static_output .= "\n\nAll packages reinstalled."; start_service(htmlspecialchars($_GET['pkg'])); update_output_window($static_output); break; default: $status = install_package(htmlspecialchars($_GET['id'])); if ($status == -1) { update_status("Installation of " . htmlspecialchars($_GET['id']) . " FAILED!"); $static_output .= "\n\nInstallation halted."; } else {
uninstall_package($_GET['pkg']); update_status(gettext("Package deleted.")); $static_output .= "\n" . gettext("Package deleted."); update_output_window($static_output); filter_configure(); break; case "showlog": $id = htmlspecialchars($_GET['pkg']); if (strpos($id, ".")) { exit; } update_output_window(file_get_contents("/tmp/pkg_mgr_{$id}.log")); break; case "reinstallxml": case "reinstallpkg": delete_package_xml(htmlspecialchars($_GET['pkg'])); if (install_package(htmlspecialchars($_GET['pkg'])) < 0) { update_status(gettext("Package reinstallation failed.")); $static_output .= "\n" . gettext("Package reinstallation failed."); update_output_window($static_output); } else { update_status(gettext("Package reinstalled.")); $static_output .= "\n" . gettext("Package reinstalled."); update_output_window($static_output); filter_configure(); } file_put_contents("/tmp/{$_GET['pkg']}.info", $static_output); echo "<script type='text/javascript'>document.location=\"pkg_mgr_install.php?mode=installedinfo&pkg={$_GET['pkg']}\";</script>"; break; case "installedinfo": if (file_exists("/tmp/{$_GET['pkg']}.info")) {