diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2005-01-28 22:56:55 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2005-01-28 22:56:55 +0000 |
commit | 8ccc8f1a84373d06475dacb53e7079212e616710 (patch) | |
tree | bd7378e3037e2402db7708d3cac9ab249bce6f7c /usr | |
parent | 5ba188972546226daf9285d95ea9fe0cdede10ef (diff) | |
download | pfsense-8ccc8f1a84373d06475dacb53e7079212e616710.zip pfsense-8ccc8f1a84373d06475dacb53e7079212e616710.tar.gz |
Add package reinstallation button to Backup/Restore area. The script will basically reinstall any packages needed by your configuration after a restore ;)
Diffstat (limited to 'usr')
-rwxr-xr-x | usr/local/www/diag_backup.php | 62 | ||||
-rwxr-xr-x | usr/local/www/pkg_mgr_install.php | 432 |
2 files changed, 275 insertions, 219 deletions
diff --git a/usr/local/www/diag_backup.php b/usr/local/www/diag_backup.php index ef40607..de8917a 100755 --- a/usr/local/www/diag_backup.php +++ b/usr/local/www/diag_backup.php @@ -1,22 +1,22 @@ #!/usr/local/bin/php -<?php +<?php /* diag_backup.php part of m0n0wall (http://m0n0.ch/wall) - + Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>. All rights reserved. - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -31,26 +31,28 @@ /* omit no-cache headers because it confuses IE with file downloads */ $omit_nocacheheaders = true; -require("guiconfig.inc"); +require("guiconfig.inc"); if ($_POST) { unset($input_errors); - + if (stristr($_POST['Submit'], "Restore")) $mode = "restore"; + else if (stristr($_POST['Submit'], "Reinstall")) + $mode = "reinstallpackages"; else if (stristr($_POST['Submit'], "Download")) $mode = "download"; - + if ($mode) { if ($mode == "download") { config_lock(); - - $fn = "config-" . $config['system']['hostname'] . "." . + + $fn = "config-" . $config['system']['hostname'] . "." . $config['system']['domain'] . "-" . date("YmdHis") . ".xml"; - + $fs = filesize($g['conf_path'] . "/config.xml"); - header("Content-Type: application/octet-stream"); + header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=$fn"); header("Content-Length: $fs"); readfile($g['conf_path'] . "/config.xml"); @@ -67,6 +69,9 @@ if ($_POST) { } else { $input_errors[] = "The configuration could not be restored (file upload error)."; } + } else if ($mode == "reinstallpackages") { + header("Location: pkg_mgr_install.php?mode=reinstallall"); + exit; } } } @@ -86,27 +91,27 @@ if ($_POST) { <?php if ($input_errors) print_input_errors($input_errors); ?> <?php if ($savemsg) print_info_box($savemsg); ?> <table width="100%" border="0" cellspacing="0" cellpadding="6"> - <tr> + <tr> <td colspan="2" class="listtopic">Backup configuration</td> </tr> - <tr> + <tr> <td width="22%" valign="baseline" class="vncell"> </td> - <td width="78%" class="vtable"> - <p> Click this button to download the system configuration + <td width="78%" class="vtable"> + <p> Click this button to download the system configuration in XML format.<br> <br> <input name="Submit" type="submit" class="formbtn" id="download" value="Download configuration"></td> </tr> - <tr> + <tr> <td colspan="2" class="list" height="12"></td> </tr> - <tr> + <tr> <td colspan="2" class="listtopic">Restore configuration</td> </tr> - <tr> + <tr> <td width="22%" valign="baseline" class="vncell"> </td> - <td width="78%" class="vtable"> - Open a pfSense configuration XML file and click the button + <td width="78%" class="vtable"> + Open a pfSense configuration XML file and click the button below to restore the configuration.<br> <br> <strong><span class="red">Note:</span></strong><br> @@ -118,6 +123,19 @@ if ($_POST) { <input name="Submit" type="submit" class="formbtn" id="restore" value="Restore configuration"> </td> </tr> + <tr> + <td colspan="2"> </td> + </tr> + <tr> + <td colspan="2" class="listtopic">Reinstall packages</td> + </tr> + <tr> + <td width="22%" valign="baseline" class="vncell"> </td> + <td width="78%" class="vtable"> + <p> Click this button to reinstall all system packages. This may wake a while.<br> + <br> + <input name="Submit" type="submit" class="formbtn" id="reinstallpackages" value="Reinstall packages"></td> + </tr> </table> </form> <?php include("fend.inc"); ?> diff --git a/usr/local/www/pkg_mgr_install.php b/usr/local/www/pkg_mgr_install.php index 9d5980f..2445dc9 100755 --- a/usr/local/www/pkg_mgr_install.php +++ b/usr/local/www/pkg_mgr_install.php @@ -133,6 +133,8 @@ function update_progress_bar($percent) { $a_out = &$pkg_config['packages']; +$packages_to_install = Array(); + ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> @@ -163,11 +165,9 @@ if(!file_exists("/tmp/pkg_config.xml")) { $pkg_config = parse_xml_config_pkg("{$g['tmp_path']}/pkg_config.xml", "pfsensepkgs"); -$id = $_GET['id']; +if(!$pkg_config['packages']) + print_info_box_np("Could not find any packages in pkg_config.xml"); -if(!$pkg_config['packages']) { - print_info_box_np("Could not find any packages in pkg_config.xml"); -} ?> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td> <ul id="tabnav"> @@ -202,240 +202,279 @@ if(!$pkg_config['packages']) { <?php -update_progress_bar($pb_percent); -$pb_percent += 10; +if($_GET['mode'] == "reinstallall") { + /* + * Loop through installed packages and if name matches + * push the package id onto array to reinstall + */ + $counter = 0; + foreach($pkg_config['packages']['package'] as $available_package) { + foreach($config['installedpackages']['package'] as $package) { + if($package['name'] == $available_package['name']) { + array_push($packages_to_install, $counter); + update_status("Adding package " . $package['name']); + fwrite($fd_log, "Adding (" . $counter . ") " . $package['name'] . " to package installation array.\n" . $status); + } + } + $counter++; + } +} else { + /* + * Push the desired package id onto the install packages array + */ + array_push($packages_to_install, $_GET['id']); +} /* - * install the package -*/ + * Loop through packages_to_install, installing needed packages + */ +foreach ($packages_to_install as $id) { -// Ensure directories are in place for pkg_add. -mwexec("mkdir /usr/local/www/ext/Services >/dev/null 2>&1"); -mwexec("mkdir /usr/local/www/ext/System >/dev/null 2>&1"); -mwexec("mkdir /usr/local/www/ext/Interfaces >/dev/null 2>&1"); -mwexec("mkdir /usr/local/www/ext/Firewall >/dev/null 2>&1"); -mwexec("mkdir /usr/local/www/ext/VPN >/dev/null 2>&1"); -mwexec("mkdir /usr/local/www/ext/Status >/dev/null 2>&1"); -mwexec("mkdir /usr/local/www/ext/Diagnostics >/dev/null 2>&1"); -mwexec("mkdir /usr/local/pkg >/dev/null 2>&1"); - -update_progress_bar($pb_percent); -$pb_percent += 10; - -$a_out = &$pkg_config['packages']['package']; -$pkgent = array(); -$pkgent['name'] = $pkg_config['packages']['package'][$id]['name']; -$pkgent['descr'] = $pkg_config['packages']['package'][$id]['descr']; -$pkgent['category'] = $pkg_config['packages']['package'][$id]['category']; - -$pkgent['version'] = $pkg_config['packages']['package'][$id]['version']; - -$pkgent['depends_on_package'] = $a_out[$id]['depends_on_package']; -$pkgent['depends_on_package_base_url'] = $a_out[$id]['depends_on_package_base_url']; -$pkgent['pfsense_package'] = $a_out[$id]['pfsense_package']; -$pkgent['pfsense_package_base_url'] = $a_out[$id]['pfsense_package_base_url']; -$pkgent['configurationfile'] = $a_out[$id]['configurationfile']; -if($pkg_config['packages']['package'][$id]['logging']) { - // logging facilities. - $pkgent['logging']['facility'] = $pkg_config['packages']['package'][$id]['logging']['facility']; - $pkgent['logging']['logfile_name'] = $pkg_config['packages']['package'][$id]['logging']['logfile_name']; - mwexec("/usr/sbin/clog -i -s 32768 /var/log/" . $pkgent['logging']['logfile_name']); - mwexec("chmod 0600 /var/log/" . $pkgent['logging']['logfile_name']); - add_text_to_file("/etc/syslog.conf", $pkgent['logging']['facilityname'] . "\t\t\t" . $pkgent['logging']['logfilename']); - mwexec("/usr/bin/killall -HUP syslogd"); -} -$a_out = &$config['packages']['package']; // save item to installedpkgs + $pkg_config = parse_xml_config_pkg("{$g['tmp_path']}/pkg_config.xml", "pfsensepkgs"); + + update_progress_bar($pb_percent); + $pb_percent += 10; -update_progress_bar($pb_percent); -$pb_percent += 10; + /* + * install the package + */ -fwrite($fd_log, "ls /var/db/pkg | grep " . $pkgent['name'] . "\n" . $status); -if($status <> "") { - // package is already installed!? - print_info_box_np("NOTICE! " . $pkgent['name'] . " is already installed! Installation will be registered."); -} + // Ensure directories are in place for pkg_add. + mwexec("mkdir /usr/local/www/ext/Services >/dev/null 2>&1"); + mwexec("mkdir /usr/local/www/ext/System >/dev/null 2>&1"); + mwexec("mkdir /usr/local/www/ext/Interfaces >/dev/null 2>&1"); + mwexec("mkdir /usr/local/www/ext/Firewall >/dev/null 2>&1"); + mwexec("mkdir /usr/local/www/ext/VPN >/dev/null 2>&1"); + mwexec("mkdir /usr/local/www/ext/Status >/dev/null 2>&1"); + mwexec("mkdir /usr/local/www/ext/Diagnostics >/dev/null 2>&1"); + mwexec("mkdir /usr/local/pkg >/dev/null 2>&1"); -if($pkg_config['packages']['package'][$id]['config_file'] <> "") { - update_status("Downloading configuration file."); - fwrite($fd_log, "Downloading configuration file " . $pkg_config['packages']['package'][$id]['config_file'] . " ... \n"); update_progress_bar($pb_percent); $pb_percent += 10; - mwexec("cd /usr/local/pkg/ && fetch " . $pkg_config['packages']['package'][$id]['config_file']); - if(!file_exists("/usr/local/pkg/" . $pkgent['name'] . ".xml")) { - update_output_window("ERROR! Could not fetch " . $pkg_config['packages']['package'][$id]['config_file'] . "\n"); - exit; + + $a_out = &$pkg_config['packages']['package']; + $pkgent = array(); + $pkgent['name'] = $pkg_config['packages']['package'][$id]['name']; + $pkgent['descr'] = $pkg_config['packages']['package'][$id]['descr']; + $pkgent['category'] = $pkg_config['packages']['package'][$id]['category']; + + $pkgent['version'] = $pkg_config['packages']['package'][$id]['version']; + + $pkgent['depends_on_package'] = $a_out[$id]['depends_on_package']; + $pkgent['depends_on_package_base_url'] = $a_out[$id]['depends_on_package_base_url']; + $pkgent['pfsense_package'] = $a_out[$id]['pfsense_package']; + $pkgent['pfsense_package_base_url'] = $a_out[$id]['pfsense_package_base_url']; + $pkgent['configurationfile'] = $a_out[$id]['configurationfile']; + if($pkg_config['packages']['package'][$id]['logging']) { + // logging facilities. + $pkgent['logging']['facility'] = $pkg_config['packages']['package'][$id]['logging']['facility']; + $pkgent['logging']['logfile_name'] = $pkg_config['packages']['package'][$id]['logging']['logfile_name']; + mwexec("/usr/sbin/clog -i -s 32768 /var/log/" . $pkgent['logging']['logfile_name']); + mwexec("chmod 0600 /var/log/" . $pkgent['logging']['logfile_name']); + add_text_to_file("/etc/syslog.conf", $pkgent['logging']['facilityname'] . "\t\t\t" . $pkgent['logging']['logfilename']); + mwexec("/usr/bin/killall -HUP syslogd"); } -} + $a_out = &$config['packages']['package']; // save item to installedpkgs -update_status("Downloading and installing " . $pkgent['name'] . " - " . $pkgent['pfsense_package'] . " and its dependencies ... This could take a moment ..."); -fwrite($fd_log, "Downloading and installing " . $pkgent['name'] . " ... \n"); + fwrite($fd_log, "Begining (" . $id. ") " . $pkgent['name'] . " package installation.\n" . $status); -update_progress_bar($pb_percent); -$pb_percent += 10; + update_progress_bar($pb_percent); + $pb_percent += 10; -if ($pkgent['pfsense_package_base_url'] <> "") { - $text = exec_command_and_return_text("cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['pfsense_package_base_url'] . "/" . $pkgent['pfsense_package']); - update_output_window($text); - fwrite($fd_log, "Executing: cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['pfsense_package_base_url'] . "/" . $pkgent['pfsense_package'] . "\n" . $text); -} + fwrite($fd_log, "ls /var/db/pkg | grep " . $pkgent['name'] . "\n" . $status); + if($status <> "") { + // package is already installed!? + if(!$_GET['mode'] == "reinstallall") + print_info_box_np("NOTICE! " . $pkgent['name'] . " is already installed! Installation will be registered."); + } -update_progress_bar($pb_percent); -$pb_percent += 10; + if($pkg_config['packages']['package'][$id]['config_file'] <> "") { + update_status("Downloading configuration file."); + fwrite($fd_log, "Downloading configuration file " . $pkg_config['packages']['package'][$id]['config_file'] . " ... \n"); + update_progress_bar($pb_percent); + $pb_percent += 10; + mwexec("cd /usr/local/pkg/ && fetch " . $pkg_config['packages']['package'][$id]['config_file']); + if(!file_exists("/usr/local/pkg/" . $pkgent['name'] . ".xml")) { + update_output_window("ERROR! Could not fetch " . $pkg_config['packages']['package'][$id]['config_file'] . "\n"); + exit; + } + } -if ($pkgent['depends_on_package_base_url'] <> "") { - update_status("Downloading and installing " . $pkgent['name'] . " and its dependencies ... This could take a moment ..."); - $text = exec_command_and_return_text("cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['depends_on_package_base_url'] . "/" . $pkgent['depends_on_package']); - update_output_window($text); - fwrite($fd_log, "cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['depends_on_package_base_url'] . "/" . $pkgent['depends_on_package'] . "\n" . $text);; -} + update_status("Downloading and installing " . $pkgent['name'] . " - " . $pkgent['pfsense_package'] . " and its dependencies ... This could take a moment ..."); + fwrite($fd_log, "Downloading and installing " . $pkgent['name'] . " ... \n"); -if ($pkgent['depends_on_package_base_url'] <> "" or $pkgent['pfsense_package_base_url'] <> "") { - $status = exec_command_and_return_text("ls /var/db/pkg | grep " . $pkgent['name']); - fwrite($fd_log, "ls /var/db/pkg | grep " . $pkgent['name'] . "\n" . $status); - if($status <> "") { - update_status("Package installed. Lets finish up."); - fwrite($fd_log, "Package installed. Lets finish up.\n"); - } else { - fwrite($fd_log, "Package WAS NOT installed properly.\n"); - fclose($fd_log); - $filecontents = exec_command_and_return_text("cat " . $file); - update_progress_bar(100); - echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';</script>"; - echo "\n<script language=\"JavaScript\">document.progholder.style.visibility='hidden';</script>"; - update_status("Package WAS NOT installed properly...Something went wrong..\n" . $filecontents); - update_output_window("Error during package installation."); - sleep(1); - die; + update_progress_bar($pb_percent); + $pb_percent += 10; + + if ($pkgent['pfsense_package_base_url'] <> "") { + $text = exec_command_and_return_text("cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['pfsense_package_base_url'] . "/" . $pkgent['pfsense_package']); + update_output_window($text); + fwrite($fd_log, "Executing: cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['pfsense_package_base_url'] . "/" . $pkgent['pfsense_package'] . "\n" . $text); } -} -update_progress_bar($pb_percent); -$pb_percent += 10; + update_progress_bar($pb_percent); + $pb_percent += 10; + + if ($pkgent['depends_on_package_base_url'] <> "") { + update_status("Downloading and installing " . $pkgent['name'] . " and its dependencies ... This could take a moment ..."); + $text = exec_command_and_return_text("cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['depends_on_package_base_url'] . "/" . $pkgent['depends_on_package']); + update_output_window($text); + fwrite($fd_log, "cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['depends_on_package_base_url'] . "/" . $pkgent['depends_on_package'] . "\n" . $text);; + } + + if ($pkgent['depends_on_package_base_url'] <> "" or $pkgent['pfsense_package_base_url'] <> "") { + $status = exec_command_and_return_text("ls /var/db/pkg | grep " . $pkgent['name']); + fwrite($fd_log, "ls /var/db/pkg | grep " . $pkgent['name'] . "\n" . $status); + if($status <> "") { + update_status("Package installed. Lets finish up."); + fwrite($fd_log, "Package installed. Lets finish up.\n"); + } else { + fwrite($fd_log, "Package WAS NOT installed properly.\n"); + fclose($fd_log); + $filecontents = exec_command_and_return_text("cat " . $file); + update_progress_bar(100); + echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';</script>"; + echo "\n<script language=\"JavaScript\">document.progholder.style.visibility='hidden';</script>"; + update_status("Package WAS NOT installed properly...Something went wrong..\n" . $filecontents); + update_output_window("Error during package installation."); + sleep(1); + die; + } + } -$config = parse_xml_config("{$g['conf_path']}/config.xml", $g['xml_rootobj']); + update_progress_bar($pb_percent); + $pb_percent += 10; -update_progress_bar($pb_percent); -$pb_percent += 10; + $config = parse_xml_config("{$g['conf_path']}/config.xml", $g['xml_rootobj']); + + update_progress_bar($pb_percent); + $pb_percent += 10; -$config['installedpackages']['package'][] = $pkgent; + $config['installedpackages']['package'][] = $pkgent; -if (isset($id) && $a_out[$id]) - $a_out[$id] = $pkgent; -else - $a_out[] = $pkgent; + if (isset($id) && $a_out[$id]) + $a_out[$id] = $pkgent; + else + $a_out[] = $pkgent; -update_progress_bar($pb_percent); -$pb_percent += 10; + update_progress_bar($pb_percent); + $pb_percent += 10; -write_config(); + if(!$_GET['mode'] == "reinstallall") + write_config(); -update_progress_bar($pb_percent); -$pb_percent += 10; + update_progress_bar($pb_percent); + $pb_percent += 10; -$name = $pkgent['name']; + $name = $pkgent['name']; -update_progress_bar($pb_percent); -$pb_percent++; + update_progress_bar($pb_percent); + $pb_percent++; -/* - * parse the config file for this package and install neededtext items. - * -*/ -if(file_exists("/usr/local/pkg/" . $pkgent['name'] . ".xml")) { - $package_conf = parse_xml_config_pkg("/usr/local/pkg/" . $pkgent['name'] . ".xml", "packagegui"); - if($package_conf['modify_system']['item'] <> "") { - foreach ($package_conf['modify_system']['item'] as $ms) { - update_progress_bar($pb_percent); - $pb_percent += 10; - if($ms['textneeded']) { - add_text_to_file($ms['modifyfilename'],$ms['textneeded']); + /* + * parse the config file for this package and install neededtext items. + * + */ + if(file_exists("/usr/local/pkg/" . $pkgent['name'] . ".xml")) { + $package_conf = parse_xml_config_pkg("/usr/local/pkg/" . $pkgent['name'] . ".xml", "packagegui"); + if($package_conf['modify_system']['item'] <> "") { + foreach ($package_conf['modify_system']['item'] as $ms) { + update_progress_bar($pb_percent); + $pb_percent += 10; + if($ms['textneeded']) { + add_text_to_file($ms['modifyfilename'],$ms['textneeded']); + } } } - } - /* - * fetch additional files needed for package if defined - * and uncompress if needed. - */ - if ($package_conf['additional_files_needed'] <> "") { - foreach($package_conf['additional_files_needed']['item'] as $afn) { - update_progress_bar($pb_percent); - $pb_percent += 10; - $filename = get_filename_from_url($afn); - update_status("Downloading additional files needed for package " . $filename . " ..."); - system("cd /usr/local/pkg && /usr/bin/fetch " . $afn . " 2>/dev/null"); - if(stristr($filename, '.tgz') <> "") - system("cd /usr/local/pkg && tar xzvf " . $filename . " -C / >/dev/null 2>&1"); - } - } - - /* - * loop through menu installation items - * installing multiple items if need be. - */ - if(is_array($package_conf['menu'])) - foreach ($package_conf['menu'] as $menu) { - // install menu item into the ext folder - fwrite($fd_log, "Adding menu option to " . $menu['section'] . "/" . $menu['name'] . "\n"); - $fd = fopen("/usr/local/www/ext/" . $menu['section'] . "/" . $menu['name'] , "w"); - if($menu['url'] <> "") { - // override $myurl for script. - $toeval = "\$myurl = \"" . getenv("HTTP_HOST") . "\"; \n"; - eval($toeval); - // eval url so that above $myurl item can be processed if need be. - $urltmp = $menu['url']; - $toeval = "\$url = \"" . $urltmp . "\"; \n"; - eval($toeval); - fwrite($fd, $url . "\n"); - } else { - $xml = ""; - if(stristr($menu['configfile'],".xml") == "") $xml = ".xml"; - fwrite($fd, "/pkg.php?xml=" . $menu['configfile'] . $xml . "\n"); + /* + * fetch additional files needed for package if defined + * and uncompress if needed. + */ + if ($package_conf['additional_files_needed'] <> "") { + foreach($package_conf['additional_files_needed']['item'] as $afn) { + update_progress_bar($pb_percent); + $pb_percent += 10; + $filename = get_filename_from_url($afn); + update_status("Downloading additional files needed for package " . $filename . " ..."); + system("cd /usr/local/pkg && /usr/bin/fetch " . $afn . " 2>/dev/null"); + if(stristr($filename, '.tgz') <> "") + system("cd /usr/local/pkg && tar xzvf " . $filename . " -C / >/dev/null 2>&1"); } - fclose($fd); - } -} else { - update_output_window("WARNING! /usr/local/pkg/" . $pkgent['name'] . ".xml" . " does not exist!\n"); - fwrite($fd_log, "WARNING! /usr/local/pkg/" . $pkgent['name'] . ".xml" . " does not exist!\n"); -} -fwrite($fd_log, "End of Package Manager installation session.\n"); + } + + /* + * loop through menu installation items + * installing multiple items if need be. + */ + if(is_array($package_conf['menu'])) + foreach ($package_conf['menu'] as $menu) { + // install menu item into the ext folder + fwrite($fd_log, "Adding menu option to " . $menu['section'] . "/" . $menu['name'] . "\n"); + $fd = fopen("/usr/local/www/ext/" . $menu['section'] . "/" . $menu['name'] , "w"); + if($menu['url'] <> "") { + // override $myurl for script. + $toeval = "\$myurl = \"" . getenv("HTTP_HOST") . "\"; \n"; + eval($toeval); + // eval url so that above $myurl item can be processed if need be. + $urltmp = $menu['url']; + $toeval = "\$url = \"" . $urltmp . "\"; \n"; + eval($toeval); + fwrite($fd, $url . "\n"); + } else { + $xml = ""; + if(stristr($menu['configfile'],".xml") == "") $xml = ".xml"; + fwrite($fd, "/pkg.php?xml=" . $menu['configfile'] . $xml . "\n"); + } + fclose($fd); + } + } else { + update_output_window("WARNING! /usr/local/pkg/" . $pkgent['name'] . ".xml" . " does not exist!\n"); + fwrite($fd_log, "WARNING! /usr/local/pkg/" . $pkgent['name'] . ".xml" . " does not exist!\n"); + } + fwrite($fd_log, "End of Package Manager installation session.\n"); -update_progress_bar($pb_percent); -$pb_percent += 10; + update_progress_bar($pb_percent); + $pb_percent += 10; -// return dependency list to output later. -$command = "TODELETE=`ls /var/db/pkg | grep " . $name . "` && /usr/sbin/pkg_info -r \$TODELETE | grep Dependency: | cut -d\" \" -f2"; -$dependencies = exec_command_and_return_text($command); -fwrite($fd_log, "Installed " . $name . " and the following dependencies:\n" . $dependencies); + // return dependency list to output later. + $command = "TODELETE=`ls /var/db/pkg | grep " . $name . "` && /usr/sbin/pkg_info -r \$TODELETE | grep Dependency: | cut -d\" \" -f2"; + $dependencies = exec_command_and_return_text($command); + fwrite($fd_log, "Installed " . $name . " and the following dependencies:\n" . $dependencies); -update_progress_bar($pb_percent); -$pb_percent += 10; + update_progress_bar($pb_percent); + $pb_percent += 10; -if ($pkgent['depends_on_package_base_url'] <> "" or $pkgent['pfsense_package_base_url'] <> "") { - $status = exec_command_and_return_text("ls /var/db/pkg | grep " . $pkgent['name']); - fwrite($fd_log, "ls /var/db/pkg | grep " . $pkgent['name'] . "\n" . $status); - if($status <> "") { - update_status("Package installation completed."); - fwrite($fd_log, "Package installation completed.\n"); + if ($pkgent['depends_on_package_base_url'] <> "" or $pkgent['pfsense_package_base_url'] <> "") { + $status = exec_command_and_return_text("ls /var/db/pkg | grep " . $pkgent['name']); + fwrite($fd_log, "ls /var/db/pkg | grep " . $pkgent['name'] . "\n" . $status); + if($status <> "") { + update_status("Package installation completed."); + fwrite($fd_log, "Package installation completed.\n"); + } else { + update_status("Package WAS NOT installed properly."); + fwrite($fd_log, "Package WAS NOT installed properly.\n"); + } } else { - update_status("Package WAS NOT installed properly."); - fwrite($fd_log, "Package WAS NOT installed properly.\n"); + update_status("Package installation completed."); + fwrite($fd_log, "Package installation completed.\n"); } -} else { - update_status("Package installation completed."); - fwrite($fd_log, "Package installation completed.\n"); -} -update_progress_bar($pb_percent); -$pb_percent += 10; + update_progress_bar($pb_percent); + $pb_percent += 10; -// close log -fclose($fd_log); -if($package_conf['custom_php_install_command']) { - eval($package_conf['custom_php_install_command']); + if($package_conf['custom_php_install_command']) { + eval($package_conf['custom_php_install_command']); + } + + update_progress_bar(100); + } +// close log +fclose($fd_log); + // reopen and read log in $fd_log = fopen("/tmp/pkg_mgr.log", "r"); $tmp = ""; @@ -446,7 +485,6 @@ fclose($fd_log); $log = ereg_replace("\n", "\\n", $tmp); //echo "\n<script language=\"JavaScript\">this.document.forms[0].output.value = \"" . $log . "\";</script>"; -update_progress_bar(100); echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';</script>"; echo "\n<script language=\"JavaScript\">document.progholder.style.visibility='hidden';</script>"; |