summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2010-11-29 18:49:51 -0500
committerjim-p <jimp@pfsense.org>2010-11-29 18:49:51 -0500
commit5f36c6581a3a9c1f797a607d3f1d794ea7749421 (patch)
treebda58bfba159fa36b6276c2b17a9fa3adae59077
parent16926fdccc339db15311fd351274f453cc35df35 (diff)
downloadpfsense-5f36c6581a3a9c1f797a607d3f1d794ea7749421.zip
pfsense-5f36c6581a3a9c1f797a607d3f1d794ea7749421.tar.gz
Rework this loader.conf changing code a bit. Might help with ticket #560
-rw-r--r--etc/inc/pfsense-utils.inc27
1 files changed, 12 insertions, 15 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index 45cd2b9..135dfd0 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -978,21 +978,18 @@ function setup_serial_port() {
}
/* serial console - write out /boot/loader.conf */
$boot_config = file_get_contents("/boot/loader.conf");
- $boot_config_split = split("\n", $boot_config);
- $fd = fopen("/boot/loader.conf","w");
- if($fd) {
- foreach($boot_config_split as $bcs) {
- if(stristr($bcs, "console")) {
- /* DONT WRITE OUT, WE'LL DO IT LATER */
- } else {
- if($bcs <> "")
- fwrite($fd, "{$bcs}\n");
- }
- }
- if(isset($config['system']['enableserial'])) {
- fwrite($fd, "console=\"comconsole\"\n");
- }
- fclose($fd);
+ $boot_config_split = explode("\n", $boot_config);
+ if(count($boot_config_split) > 0) {
+ $new_boot_config = array();
+ // Loop through and only add lines that are not empty, and which
+ // do not contain a console directive.
+ foreach($boot_config_split as $bcs)
+ if(!empty($bcs) && (stripos($bcs, "console") === false))
+ $new_boot_config[] = $bcs;
+
+ if(isset($config['system']['enableserial']))
+ $new_boot_config[] = 'console="comconsole"');
+ file_put_contents("/boot/loader.conf", implode("\n", $new_boot_config));
}
}
$ttys = file_get_contents("/etc/ttys");
OpenPOWER on IntegriCloud