summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2009-04-29 14:28:23 +0000
committerErmal Luçi <eri@pfsense.org>2009-04-29 14:28:23 +0000
commit2b4d37dedd17f67a9b617e726ae47b026716ae17 (patch)
tree5bcee1a5e6b0e102db6a7e0cae7657f3a2503684 /etc
parentfe522219c3d7f26f0cff098511a76d93324a1bea (diff)
downloadpfsense-2b4d37dedd17f67a9b617e726ae47b026716ae17.zip
pfsense-2b4d37dedd17f67a9b617e726ae47b026716ae17.tar.gz
* Shuffle functions around to reduce require_once() a little.
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/config.inc54
-rw-r--r--etc/inc/pfsense-utils.inc130
-rw-r--r--etc/inc/upgrade_config.inc3
-rw-r--r--etc/inc/util.inc172
4 files changed, 177 insertions, 182 deletions
diff --git a/etc/inc/config.inc b/etc/inc/config.inc
index 29fbc7e..a54d211 100644
--- a/etc/inc/config.inc
+++ b/etc/inc/config.inc
@@ -56,11 +56,7 @@ require_once("globals.inc");
if($g['booting']) echo ".";
require_once("util.inc");
if($g['booting']) echo ".";
-require_once("pfsense-utils.inc");
-if($g['booting']) echo ".";
require_once("xmlparse.inc");
-if($g['booting']) echo ".";
-require_once("services.inc");
/* read platform */
if($g['booting']) echo ".";
@@ -350,7 +346,6 @@ function restore_backup($file) {
conf_mount_ro();
}
config_unlock();
- reload_all();
}
/****f* config/parse_config_bootup
@@ -1076,8 +1071,11 @@ EOD;
$g['booting'] = false;
- /* resync everything */
- reload_all_sync();
+ /* XXX: ermal - disable it for now this is used during bootup at best so shouldn't be needed.
+ * For now just comment it out and later remove it completely.
+ * resync everything
+ reload_all_sync();
+ */
echo " done!\n";
@@ -1305,48 +1303,6 @@ function backup_config() {
return true;
}
-function mute_kernel_msgs() {
- return;
- exec("/sbin/conscontrol mute on");
-}
-
-function unmute_kernel_msgs() {
- exec("/sbin/conscontrol mute off");
-}
-
-function start_devd() {
- exec("/sbin/devd");
- sleep(1);
- if(file_exists("/tmp/rc.linkup"))
- unlink("/tmp/rc.linkup");
-}
-
-function is_interface_mismatch() {
- global $config, $g;
-
- /* XXX: Should we process only enabled interfaces?! */
- $do_assign = false;
- $i = 0;
- foreach ($config['interfaces'] as $ifname => $ifcfg) {
- if (preg_match("/^enc|^tun|^ppp|^pptp|^pppoe|^ovpn|^gif|^gre|^lagg|^bridge|^vlan/i", $ifcfg['if'])) {
- $i++;
- }
- else if (does_interface_exist($ifcfg['if']) == false) {
- file_notice("interfaces", "{$ifcfg['if']} is not present anymore on the system, you need to reassign interfaces or take appropriate actions.", "System", "", 2);
- $do_assign = true;
- } else
- $i++;
- }
-
- if ($g['minimum_nic_count'] > $i) {
- file_notice("interfaces", "Minimum allowed interfaces is set to {$g['minimum_nic_count']} but system has only {$i} interfaces!", "", "System", 2);
- $do_assign = true;
- } else if (file_exists("{$g['tmp_path']}/assign_complete"))
- $do_assign = false;
-
- return $do_assign;
-}
-
function set_device_perms() {
$devices = array(
'pf' => array( 'user' => 'proxy',
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index b0afac5..db65331 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -209,48 +209,6 @@ function get_dns_servers() {
return $dns_server_master;
}
-/****f* pfsense-utils/log_error
-* NAME
-* log_error - Sends a string to syslog.
-* INPUTS
-* $error - string containing the syslog message.
-* RESULT
-* null
-******/
-function log_error($error) {
- global $g;
- $page = $_SERVER['SCRIPT_NAME'];
- syslog(LOG_WARNING, "$page: $error");
- if ($g['debug'])
- syslog(LOG_WARNING, var_dump(debug_backtrace()));
- return;
-}
-
-/****f* pfsense-utils/return_dir_as_array
- * NAME
- * return_dir_as_array - Return a directory's contents as an array.
- * INPUTS
- * $dir - string containing the path to the desired directory.
- * RESULT
- * $dir_array - array containing the directory's contents. This array will be empty if the path specified is invalid.
- ******/
-function return_dir_as_array($dir) {
- $dir_array = array();
- if (is_dir($dir)) {
- if ($dh = opendir($dir)) {
- while (($file = readdir($dh)) !== false) {
- $canadd = 0;
- if($file == ".") $canadd = 1;
- if($file == "..") $canadd = 1;
- if($canadd == 0)
- array_push($dir_array, $file);
- }
- closedir($dh);
- }
- }
- return $dir_array;
-}
-
/****f* pfsense-utils/enable_hardware_offloading
* NAME
* enable_hardware_offloading - Enable a NIC's supported hardware features.
@@ -1207,62 +1165,6 @@ function rmdir_recursive($path,$follow_links=false) {
}
/*
- * get_memory()
- * returns an array listing the amount of
- * memory installed in the hardware
- * [0]real and [1]available
- */
-function get_memory() {
- if(file_exists("/var/log/dmesg.boot")) {
- $mem = `cat /var/log/dmesg.boot | grep memory`;
- $matches = "";
- if (preg_match_all("/real memory = .* \((.*) MB/", $mem, $matches))
- $real = $matches[1];
- if (preg_match_all("/avail memory = .* \((.*) MB/", $mem, $matches))
- $avail = $matches[1];
- return array($real[0],$avail[0]);
- } else {
- $mem = `dmesg -a`;
- $matches = "";
- if (preg_match_all("/real memory = .* \((.*) MB/", $mem, $matches))
- $real = $matches[1];
- if (preg_match_all("/avail memory = .* \((.*) MB/", $mem, $matches))
- $avail = $matches[1];
- return array($real[0],$avail[0]);
- }
-}
-
-/*
- * safe_mkdir($path, $mode = 0755)
- * create directory if it doesn't already exist and isn't a file!
- */
-function safe_mkdir($path, $mode=0755) {
- global $g;
-
- if (!is_file($path) && !is_dir($path)) {
- return @mkdir($path, $mode);
- } else {
- return false;
- }
-}
-
-/*
- * make_dirs($path, $mode = 0755)
- * create directory tree recursively (mkdir -p)
- */
-function make_dirs($path, $mode = 0755) {
- $base = '';
- foreach (explode('/', $path) as $dir) {
- $base .= "/$dir";
- if (!is_dir($base)) {
- if (!@mkdir($base, $mode))
- return false;
- }
- }
- return true;
-}
-
-/*
* call_pfsense_method(): Call a method exposed by the pfsense.com XMLRPC server.
*/
function call_pfsense_method($method, $params, $timeout = 0) {
@@ -1327,30 +1229,6 @@ function get_disk_info() {
// $size, $used, $avail, $cap
}
-function run_plugins($directory) {
- global $config, $g;
- /* process packager manager custom rules */
- $files = return_dir_as_array($directory);
- if($files <> "") {
- foreach ($files as $file) {
- if($file) {
- $text = file_get_contents($directory . $file);
- if($text) {
- if(stristr($file, ".sh") == true) {
- mwexec($directory . $file . " start");
- } else {
- if(!stristr($file,"CVS")) {
- if($g['booting'] == true)
- echo "\t{$file}... ";
- require_once($directory . $file);
- }
- }
- }
- }
- }
- }
-}
-
/****f* pfsense-utils/display_top_tabs
* NAME
* display_top_tabs - display tabs with rounded edges
@@ -1837,14 +1715,6 @@ function print_value_list($list, $count = 10, $separator = ",") {
return $list;
}
-
-function update_filter_reload_status($text) {
- global $g;
- $fd = fopen("{$g['varrun_path']}/filter_reload_status", "w");
- fwrite($fd, $text);
- fclose($fd);
-}
-
/* DHCP enabled on any interfaces? */
function is_dhcp_server_enabled()
{
diff --git a/etc/inc/upgrade_config.inc b/etc/inc/upgrade_config.inc
index 2918b69..a3ea728 100644
--- a/etc/inc/upgrade_config.inc
+++ b/etc/inc/upgrade_config.inc
@@ -491,9 +491,6 @@ function upgrade_025_to_026() {
$cron_item['command'] = "/usr/local/bin/checkreload.sh";
$config['cron']['item'][] = $cron_item;
-
- /* write crontab entries to file */
- configure_cron();
}
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index b1d875e..2be1f39 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -473,6 +473,23 @@ function get_interface_list($mode = "active", $keyby = "physical", $vfaces = "")
return $iflist;
}
+/****f* util/log_error
+* NAME
+* log_error - Sends a string to syslog.
+* INPUTS
+* $error - string containing the syslog message.
+* RESULT
+* null
+******/
+function log_error($error) {
+ global $g;
+ $page = $_SERVER['SCRIPT_NAME'];
+ syslog(LOG_WARNING, "$page: $error");
+ if ($g['debug'])
+ syslog(LOG_WARNING, var_dump(debug_backtrace()));
+ return;
+}
+
/* wrapper for exec() */
function mwexec($command, $mute = false) {
@@ -743,4 +760,159 @@ function format_bytes($bytes) {
}
}
+function update_filter_reload_status($text) {
+ global $g;
+
+ file_put_contents("{$g['varrun_path']}/filter_reload_status", $text);
+}
+
+/****f* util/return_dir_as_array
+ * NAME
+ * return_dir_as_array - Return a directory's contents as an array.
+ * INPUTS
+ * $dir - string containing the path to the desired directory.
+ * RESULT
+ * $dir_array - array containing the directory's contents. This array will be empty if the path specified is invalid.
+ ******/
+function return_dir_as_array($dir) {
+ $dir_array = array();
+ if (is_dir($dir)) {
+ if ($dh = opendir($dir)) {
+ while (($file = readdir($dh)) !== false) {
+ $canadd = 0;
+ if($file == ".") $canadd = 1;
+ if($file == "..") $canadd = 1;
+ if($canadd == 0)
+ array_push($dir_array, $file);
+ }
+ closedir($dh);
+ }
+ }
+ return $dir_array;
+}
+
+function run_plugins($directory) {
+ global $config, $g;
+
+ /* process packager manager custom rules */
+ $files = return_dir_as_array($directory);
+ if (is_array($files)) {
+ foreach ($files as $file) {
+ if($file) {
+ $text = file_get_contents($directory . $file);
+ if($text) {
+ if(stristr($file, ".sh") == true) {
+ mwexec($directory . $file . " start");
+ } else {
+ if(!stristr($file,"CVS")) {
+ if($g['booting'] == true)
+ echo "\t{$file}... ";
+ require_once($directory . $file);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+/*
+ * safe_mkdir($path, $mode = 0755)
+ * create directory if it doesn't already exist and isn't a file!
+ */
+function safe_mkdir($path, $mode=0755) {
+ global $g;
+
+ if (!is_file($path) && !is_dir($path)) {
+ return @mkdir($path, $mode);
+ } else {
+ return false;
+ }
+}
+
+/*
+ * make_dirs($path, $mode = 0755)
+ * create directory tree recursively (mkdir -p)
+ */
+function make_dirs($path, $mode = 0755) {
+ $base = '';
+ foreach (explode('/', $path) as $dir) {
+ $base .= "/$dir";
+ if (!is_dir($base)) {
+ if (!@mkdir($base, $mode))
+ return false;
+ }
+ }
+ return true;
+}
+
+/*
+ * get_memory()
+ * returns an array listing the amount of
+ * memory installed in the hardware
+ * [0]real and [1]available
+ */
+function get_memory() {
+ if(file_exists("/var/log/dmesg.boot")) {
+ $mem = `cat /var/log/dmesg.boot | grep memory`;
+ $matches = "";
+ if (preg_match_all("/real memory = .* \((.*) MB/", $mem, $matches))
+ $real = $matches[1];
+ if (preg_match_all("/avail memory = .* \((.*) MB/", $mem, $matches))
+ $avail = $matches[1];
+ return array($real[0],$avail[0]);
+ } else {
+ $mem = `dmesg -a`;
+ $matches = "";
+ if (preg_match_all("/real memory = .* \((.*) MB/", $mem, $matches))
+ $real = $matches[1];
+ if (preg_match_all("/avail memory = .* \((.*) MB/", $mem, $matches))
+ $avail = $matches[1];
+ return array($real[0],$avail[0]);
+ }
+}
+
+function mute_kernel_msgs() {
+ return;
+ exec("/sbin/conscontrol mute on");
+}
+
+function unmute_kernel_msgs() {
+ exec("/sbin/conscontrol mute off");
+}
+
+function start_devd() {
+ exec("/sbin/devd");
+ sleep(1);
+ if(file_exists("/tmp/rc.linkup"))
+ unlink("/tmp/rc.linkup");
+}
+
+function is_interface_mismatch() {
+ global $config, $g;
+
+ /* XXX: Should we process only enabled interfaces?! */
+ $do_assign = false;
+ $i = 0;
+ foreach ($config['interfaces'] as $ifname => $ifcfg) {
+ if (preg_match("/^enc|^tun|^ppp|^pptp|^pppoe|^ovpn|^gif|^gre|^lagg|^bridge|^vlan/i", $ifcfg['if'])) {
+ $i++;
+ }
+ else if (does_interface_exist($ifcfg['if']) == false) {
+ file_notice("interfaces", "{$ifcfg['if']} is not present anymore on the system, you need to reassign interfaces or take appropriate actions.", "System", "
+", 2);
+ $do_assign = true;
+ } else
+ $i++;
+ }
+
+ if ($g['minimum_nic_count'] > $i) {
+ file_notice("interfaces", "Minimum allowed interfaces is set to {$g['minimum_nic_count']} but system has only {$i} interfaces!", "", "System", 2);
+ $do_assign = true;
+ } else if (file_exists("{$g['tmp_path']}/assign_complete"))
+ $do_assign = false;
+
+ return $do_assign;
+}
+
?>
OpenPOWER on IntegriCloud