summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2008-08-30 02:07:45 +0000
committerScott Ullrich <sullrich@pfsense.org>2008-08-30 02:07:45 +0000
commit5fec455a7c06a92ca59b0d8e1c9c807bb57b2821 (patch)
tree0a4dca7e75874dde4debd3c97f575e677408bb1b
parent5be2fc35ed9bfa0eb7189e9c6819de89e161b524 (diff)
downloadpfsense-5fec455a7c06a92ca59b0d8e1c9c807bb57b2821.zip
pfsense-5fec455a7c06a92ca59b0d8e1c9c807bb57b2821.tar.gz
* Add nohaltonerror() (default is to halt on error)
* Add sethaltonerror() * Cleanup error on text handling
-rw-r--r--etc/inc/cmd_chain.inc23
1 files changed, 16 insertions, 7 deletions
diff --git a/etc/inc/cmd_chain.inc b/etc/inc/cmd_chain.inc
index 1a64dbc..8186065 100644
--- a/etc/inc/cmd_chain.inc
+++ b/etc/inc/cmd_chain.inc
@@ -48,6 +48,7 @@ Class CmdCHAIN {
var $cmd_chain_array = array();
var $is_debugging;
+ var $halt_on_errors = true;
/* clear() erases the current cmdchain */
function clear() {
@@ -59,6 +60,16 @@ Class CmdCHAIN {
function setdebug() {
$this->is_debugging = true;
}
+
+ /* no halt execution of CmdCHAIN if there is a failure */
+ function nohaltonerror() {
+ $this->halt_on_errors = false;
+ }
+
+ /* halts execution of CmdCHAIN if there is a failure */
+ function sethaltonerror() {
+ $this->halt_on_errors = true;
+ }
/* adds a command to the CmdCHAIN */
function add($cmd_title = "", $command = "", $ignore_return_text = false) {
@@ -90,18 +101,16 @@ Class CmdCHAIN {
}
// Execute command
$status = exec($command);
- if(!$status and $this->ignore_return_text == false) {
+ if($this->ignore_return_text == true)
+ continue;
+ if(intval($status) <> 0) {
log_error("{$cmd_title} failed with return code -> {$status}. The command was {$command}");
- return("{$cmd_title} failed with return code -> {$status}");
- } else {
- if($this->is_debugging == true) {
- log_error("{$cmd_title} returned -> {$status}");
- }
+ if($this->halt_on_errors == true)
+ return("{$cmd_title} failed with return code -> {$status}. The command was {$command}");
}
}
return;
}
-
}
/*
OpenPOWER on IntegriCloud