From 196d00856dfb5b24a829b4d9555fac378b696c42 Mon Sep 17 00:00:00 2001 From: jim-p Date: Mon, 31 Oct 2011 16:25:21 -0400 Subject: Setup serial bits after upgrade on NanoBSD, too. --- etc/inc/pfsense-utils.inc | 17 +++++++++++------ etc/rc.firmware | 2 +- tmp/post_upgrade_command | 2 +- tmp/post_upgrade_command.php | 5 ++++- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 5203d68..7aeae4f 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -927,18 +927,23 @@ function auto_login() { conf_mount_ro(); } -function setup_serial_port() { +function setup_serial_port($when="save", $path="") { global $g, $config; conf_mount_rw(); + $prefix = ""; + if (($when == "upgrade") && (!empty($path)) && is_dir($path.'/boot/')) + $prefix = "/tmp/{$path}"; + $boot_config_file = "{$path}/boot.config"; + $loader_conf_file = "{$path}/boot/loader.conf"; /* serial console - write out /boot.config */ - if(file_exists("/boot.config")) - $boot_config = file_get_contents("/boot.config"); + if(file_exists($boot_config_file)) + $boot_config = file_get_contents($boot_config_file); else $boot_config = ""; if($g['platform'] <> "cdrom") { $boot_config_split = split("\n", $boot_config); - $fd = fopen("/boot.config","w"); + $fd = fopen($boot_config_file,"w"); if($fd) { foreach($boot_config_split as $bcs) { if(stristr($bcs, "-D")) { @@ -954,7 +959,7 @@ function setup_serial_port() { fclose($fd); } /* serial console - write out /boot/loader.conf */ - $boot_config = file_get_contents("/boot/loader.conf"); + $boot_config = file_get_contents($loader_conf_file); $boot_config_split = explode("\n", $boot_config); if(count($boot_config_split) > 0) { $new_boot_config = array(); @@ -977,7 +982,7 @@ function setup_serial_port() { $new_boot_config[] = 'comconsole_speed="' . $serialspeed . '"'; $new_boot_config[] = 'console="comconsole"'; } - file_put_contents("/boot/loader.conf", implode("\n", $new_boot_config) . "\n"); + file_put_contents($loader_conf_file, implode("\n", $new_boot_config) . "\n"); } } $ttys = file_get_contents("/etc/ttys"); diff --git a/etc/rc.firmware b/etc/rc.firmware index 1fb9f65..2ad1b56 100755 --- a/etc/rc.firmware +++ b/etc/rc.firmware @@ -299,7 +299,7 @@ pfSenseNanoBSDupgrade) # If /tmp/$GLABEL_SLICE/tmp/post_upgrade_command exists # after update then execute the command. if [ -f /tmp/$GLABEL_SLICE/tmp/post_upgrade_command ]; then - sh /tmp/$GLABEL_SLICE/tmp/post_upgrade_command >> /conf/upgrade_log.txt 2>&1 + sh /tmp/$GLABEL_SLICE/tmp/post_upgrade_command $GLABEL_SLICE >> /conf/upgrade_log.txt 2>&1 fi # Update fstab diff --git a/tmp/post_upgrade_command b/tmp/post_upgrade_command index 8603a53..1db2799 100755 --- a/tmp/post_upgrade_command +++ b/tmp/post_upgrade_command @@ -43,7 +43,7 @@ echo " exit" >> $CVS_CO_DIR/root/.profile echo "fi" >> $CVS_CO_DIR/root/.profile # Now turn on or off serial console as needed -/tmp/post_upgrade_command.php +/tmp/post_upgrade_command.php $1 # Remove any previous MD5 sum files rm -f /root/*.md5 diff --git a/tmp/post_upgrade_command.php b/tmp/post_upgrade_command.php index a188710..8ec4f73 100755 --- a/tmp/post_upgrade_command.php +++ b/tmp/post_upgrade_command.php @@ -18,7 +18,10 @@ write_config(); } - setup_serial_port(); + $newslicedir = ""; + if ($ARGV[1] != "") + $newslicedir = '/tmp' . $ARGV[1]; + setup_serial_port("upgrade", $newslicedir); $files_to_process = split("\n", file_get_contents("/etc/pfSense.obsoletedfiles")); foreach($files_to_process as $filename) -- cgit v1.1