From 2b5f276f8766b7085d8b6ec54b21b6db7554a355 Mon Sep 17 00:00:00 2001 From: jim-p Date: Fri, 23 Apr 2010 12:19:36 -0400 Subject: Improve NanoBSD slice updating/changing a bit, add some error checking. Resolves #534. --- etc/inc/pfsense-utils.inc | 58 +++++++++++++++++++++++++++------------- etc/rc.nanobsd_switch_boot_slice | 27 +++++++++++++++++++ usr/local/www/diag_nanobsd.php | 19 ++++--------- 3 files changed, 72 insertions(+), 32 deletions(-) create mode 100644 etc/rc.nanobsd_switch_boot_slice diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 6364d37..c6b897c 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -1933,12 +1933,18 @@ function nanobsd_get_active_slice() { function nanobsd_get_size() { return strtoupper(file_get_contents("/etc/nanosize.txt")); } -function nanobsd_set_boot_slice($slice) { +function nanobsd_switch_boot_slice() { global $SLICE, $OLDSLICE, $TOFLASH, $COMPLETE_PATH, $COMPLETE_BOOT_PATH; global $GLABEL_SLICE, $UFS_ID, $OLD_UFS_ID, $BOOTFLASH; global $BOOT_DEVICE, $REAL_BOOT_DEVICE, $BOOT_DRIVE, $ACTIVE_SLICE; nanobsd_detect_slice_info(); + if ($BOOTFLASH == $ACTIVE_SLICE) { + $slice = $TOFLASH; + } else { + $slice = $BOOTFLASH; + } + for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); } ob_implicit_flush(1); if(strstr($slice, "s2")) { @@ -1961,20 +1967,15 @@ function nanobsd_set_boot_slice($slice) { exec("sysctl kern.geom.debugflags=16"); exec("gpart set -a active -i {$ASLICE} {$BOOT_DRIVE}"); exec("/usr/sbin/boot0cfg -s {$ASLICE} -v /dev/{$BOOT_DRIVE}"); - exec("/sbin/tunefs -L ${AGLABEL_SLICE} /dev/$ACOMPLETE_PATH"); - exec("/bin/mkdir /tmp/{$AGLABEL_SLICE}"); - exec("/sbin/fsck_ufs -y /dev/{$ACOMPLETE_PATH}"); - exec("/sbin/mount /dev/ufs/{$AGLABEL_SLICE} /tmp/{$AGLABEL_SLICE}"); - $fstab = << \ No newline at end of file diff --git a/usr/local/www/diag_nanobsd.php b/usr/local/www/diag_nanobsd.php index fee325e..3e9bed1 100755 --- a/usr/local/www/diag_nanobsd.php +++ b/usr/local/www/diag_nanobsd.php @@ -74,7 +74,7 @@ if($_POST['bootslice']) {

  EOF; - nanobsd_set_boot_slice($_POST['bootslice']); + nanobsd_switch_boot_slice(); $savemsg = "The boot slice has been set to " . nanobsd_get_active_slice(); // Survey slice info nanobsd_detect_slice_info(); @@ -133,23 +133,14 @@ if ($savemsg) Bootup

- Bootup slice: - + Bootup slice is currently: +

This will switch the bootup slice to the alternate slice.
- This will set the bootup slice. + +
-  
- -   -- cgit v1.1