Packages continued. New log file facility added.

This commit is contained in:
Scott Ullrich 2004-12-16 18:17:06 +00:00
parent 6483da5d98
commit 19fd294739
3 changed files with 91 additions and 33 deletions

View File

@ -40,6 +40,7 @@ function gentitle_pkg($pgname) {
// XXX: Make this input safe.
$xml = $_GET['xml'];
if($_POST['xml']) $xml = $_POST['xml'];
if($xml == "") {
$xml = "not_defined";
@ -52,10 +53,10 @@ if($xml == "") {
$package_name = $pkg['menu']['name'];
$section = $pkg['menu']['section'];
$config_path = $pkg['configpath'];
$title = $section . ": Edit " . $package_name
$title = $section . ": Edit " . $package_name;
if ($_POST) {
if($_GET['act'] == "del") {
if($_POST['act'] == "del") {
if($pkg['custom_delete_php_command']) {
eval($pkg['custom_delete_php_command']);
}
@ -63,6 +64,7 @@ if ($_POST) {
} else {
if($pkg['custom_add_php_command']) {
eval($pkg['custom_add_php_command']);
$savemsg = "User has been added.";
}
// XXX: add the xml value to config
}
@ -85,7 +87,8 @@ include("fbegin.inc");
$config = $config_tmp;
?>
<p class="pgtitle"><?=$title?></p>
<form action="firewall_nat_out_load_balancing.php" method="post">
<form action="pkg_edit.php" method="post">
<input type="hidden" name="xml" value="<?= $xml ?>">
<?php if ($savemsg) print_info_box($savemsg); ?>
<table width="100%" border="0" cellpadding="6" cellspacing="0">

View File

@ -176,7 +176,7 @@ if(!file_exists("/tmp/pkg_config.xml")) {
}
}
$pkg_config = parse_xml_config("{$g['tmp_path']}/pkg_config.xml", "pfsensepkgs");
$pkg_config = parse_xml_config_pkg("{$g['tmp_path']}/pkg_config.xml", "pfsensepkgs");
$id = $_GET['id'];
@ -239,11 +239,20 @@ $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['depends_on_package'] = $a_out[$id]['depends_on_package'];
$pkgent['depends_on_package_base'] = $a_out[$id]['depends_on_package_base'];
$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'] = $a_out[$id]['pfsense_package_base'];
$pkgent['pfsense_package_base_url'] = $a_out[$id]['pfsense_package_base_url'];
$pkgent['configurationfile'] = $a_out[$id]['configurationfile'];
$a_out = &$config['packages']['package'];
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("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']['facility'] . "\t\t\t" . $pkgent['logging']['logfile_name']);
mwexec("/usr/bin/killall -HUP syslogd");
}
$a_out = &$config['packages']['package']; // save item to installedpkgs
update_progress_bar($pb_percent);
$pb_percent += 10;
@ -254,24 +263,37 @@ if($status <> "") {
print_info_box_np("NOTICE! " . $pkgent['name'] . " is already installed! Installation will be registered.");
}
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");
}
}
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");
update_progress_bar($pb_percent);
$pb_percent += 10;
$text = exec_command_and_return_text("cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['pfsense_package_base'] . "/" . $pkgent['pfsense_package']);
update_output_window($text);
fwrite($fd_log, "Executing: cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['pfsense_package_base'] . "/" . $pkgent['pfsense_package'] . "\n" . $text);
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;
if ($pkgent['pfsense_package_base']) {
update_status("Downloading and installing " . $pkgent['name'] . " - " . $pkgent['depends_on_package_base'] . " 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'] . "/" . $pkgent['depends_on_package']);
if ($pkgent['depends_on_package_base_url'] <> "") {
update_status("Downloading and installing " . $pkgent['name'] . " - " . $pkgent['depends_on_package_base_url'] . " 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'] . "/" . $pkgent['depends_on_package'] . "\n" . $text);;
fwrite($fd_log, "cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['depends_on_package_base_url'] . "/" . $pkgent['depends_on_package'] . "\n" . $text);;
}
update_progress_bar($pb_percent);
@ -304,25 +326,20 @@ $pb_percent++;
// parse the config file for this package and install neededtext items.
if(file_exists("/usr/local/pkg/" . $pkgent['name'] . ".xml")) {
$config = parse_xml_config("/usr/local/pkg/" . $pkgent['name'] . ".xml", "packagegui");
foreach ($config['modify_system']['item'] as $ms) {
update_progress_bar($pb_percent);
$pb_percent += 10;
if($ms['textneeded']) {
fwrite($fd_log, "Adding needed text items:\n");
$filecontents = exec_command_and_return_text("cat " . $ms['modifyfilename']);
$text = ereg_replace($ms['textneeded'], "", $filecontents);
$text .= $ms['textneeded'];
fwrite($fd_log, $ms['textneeded'] . "\n");
$fd = fopen($ms['modifyfilename'], "w");
fwrite($fd, $text . "\n");
fclose($fd);
}
$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']);
}
}
}
// install menu item into the ext folder
fwrite($fd_log, "Adding menu option to " . $config['menu']['section'] . "/" . $config['name'] . ":\n");
$fd = fopen("/usr/local/www/ext/" . $config['menu']['section'] . "/" . $config['name'] , "w");
fwrite($fd, "/usr/local/www/pkg.php?xml=" . $config['name'] . "\n");
fwrite($fd_log, "Adding menu option to " . $package_conf['menu']['section'] . "/" . $config['name'] . "\n");
$fd = fopen("/usr/local/www/ext/" . $package_conf['menu']['section'] . "/" . $package_conf['name'] , "w");
fwrite($fd, "/usr/local/www/pkg.php?xml=" . $package_conf['menu']['name'] . "\n");
fclose($fd);
} else {
update_output_window("WARNING! /usr/local/pkg/" . $pkgent['name'] . ".xml" . " does not exist!\n");
@ -357,8 +374,8 @@ $pb_percent += 10;
// close log
fclose($fd_log);
if($pkgent['custom_php_install_command']) {
exec($pkgent['custom_php_install_command']);
if($package_conf['custom_php_install_command']) {
eval($package_conf['custom_php_install_command']);
}
// reopen and read log in
@ -376,6 +393,17 @@ 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>";
function add_text_to_file($file, $text) {
fwrite($fd_log, "Adding needed text items:\n");
$filecontents = exec_command_and_return_text("cat " . $file);
$text = ereg_replace($text, "", $filecontents);
$text .= $text;
fwrite($fd_log, $text . "\n");
$fd = fopen($file, "w");
fwrite($fd, $text . "\n");
fclose($fd);
}
?>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<pfSenseWizard>
<totalsteps>2</totalsteps>
<step>
<id>1</id>
<title>pfSense Setup Wizard</title>
<description>This wizard will guide you through installing pfSense initially.</description>
<fields>
<name>Next</name>
<type>submit</type>
</fields>
</step>
<step>
<id>2</id>
<title>Time and Date</title>
<description>Please enter the time, date and time zone.</description>
<fields>
<field>
<name></name>
<description></description>
<type></type>
</field>
</fields>
<step_submit_php_action>
</step_submit_php_action>
</step>
</pfSenseWizard>