[PC-BSD Commits] r4800 - pcbsd/trunk/pc-sysinstall/backend

svn at pcbsd.org svn at pcbsd.org
Wed Oct 28 18:48:40 PST 2009


Author: kris
Date: 2009-10-28 19:48:40 -0700 (Wed, 28 Oct 2009)
New Revision: 4800

Modified:
   pcbsd/trunk/pc-sysinstall/backend/functions-newfs.sh
   pcbsd/trunk/pc-sysinstall/backend/functions.sh
Log:

Updated the geli support, fixed a missing flag needed to
load the geli provider at boot

Added new functions for keeping logs of what the commands
are doing



Modified: pcbsd/trunk/pc-sysinstall/backend/functions-newfs.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions-newfs.sh	2009-10-28 22:57:47 UTC (rev 4799)
+++ pcbsd/trunk/pc-sysinstall/backend/functions-newfs.sh	2009-10-29 02:48:40 UTC (rev 4800)
@@ -10,19 +10,18 @@
   PARTMNT="$3"
   EXT="$4"
   ROOTSLICE="`echo ${PART} | rev | cut -b 2- | rev`"
-  zpool create -f ${PART} ${PART}${EXT}  >>${LOGOUT} 2>>${LOGOUT}
+  rc_halt "zpool create -f ${PART} ${PART}${EXT}"
 
   # Check if we ended up with needing a zfs bootable partition
   if [ "${PARTMNT}" = "/" -o "${PARTMNT}" = "/boot" ]
   then
     # Lets stamp the proper ZFS boot loader
-    echo "Setting up ZFS boot loader support" 
-    echo "Setting up ZFS boot loader support" >>${LOGOUT}
-    zpool set bootfs=${PART} ${PART} >>${LOGOUT} 2>>${LOGOUT}
-    zpool export ${PART} >>${LOGOUT} 2>>${LOGOUT}
-    dd if=/boot/zfsboot of=/dev/${ROOTSLICE} count=1 >>${LOGOUT} 2>>${LOGOUT} 
-    dd if=/boot/zfsboot of=/dev/${PART}${EXT} skip=1 seek=1024 >>${LOGOUT} 2>>${LOGOUT}
-    zpool import ${PART} >>${LOGOUT} 2>>${LOGOUT}
+    echo_log "Setting up ZFS boot loader support" 
+    rc_halt "zpool set bootfs=${PART} ${PART}"
+    rc_halt "zpool export ${PART}"
+    rc_halt "dd if=/boot/zfsboot of=/dev/${ROOTSLICE} count=1"
+    rc_halt "dd if=/boot/zfsboot of=/dev/${PART}${EXT} skip=1 seek=1024"
+    rc_halt "zpool import ${PART}"
   fi
 
   # Unmount this pool, don't need it auto-mounted by ZFS
@@ -53,19 +52,17 @@
      # Make sure journaling isn't enabled on this device
      if [ -e "/dev/${PART}.journal" ]
      then
-       gjournal stop -f ${PART}.journal >/dev/null 2>/dev/null
-       gjournal clear ${PART} >/dev/null 2>/dev/null
+       rc_nohalt "gjournal stop -f ${PART}.journal"
+       rc_nohalt "gjournal clear ${PART}"
      fi
 
      # Setup encryption if necessary
      if [ "${PARTENC}" = "ON" -a "${PARTFS}" != "SWAP" ]
      then
-       echo "Creating geli provider for ${PART}. This may take a while..."
-       echo "Creating geli provider for ${PART}" >>${LOGOUT}
-       dd if=/dev/random of=${GELIKEYDIR}/${PART}.key bs=64 count=1 >>${LOGOUT} 2>>${LOGOUT}
-       geli init -s 4096 -P -K ${GELIKEYDIR}/${PART}.key /dev/${PART} >>${LOGOUT} 2>>${LOGOUT}
-       geli attach -p -k ${GELIKEYDIR}/${PART}.key /dev/${PART} >>${LOGOUT} 2>>${LOGOUT}
-       dd if=/dev/random of=/dev/${PART}.eli bs=1m >>${LOGOUT} 2>>${LOGOUT}
+       echo_log "Creating geli provider for ${PART}"
+       rc_halt "dd if=/dev/random of=${GELIKEYDIR}/${PART}.key bs=64 count=1"
+       rc_halt "geli init -b -s 4096 -P -K ${GELIKEYDIR}/${PART}.key /dev/${PART}"
+       rc_halt "geli attach -p -k ${GELIKEYDIR}/${PART}.key /dev/${PART}"
        EXT=".eli"
      else
        # No Encryption
@@ -73,18 +70,18 @@
      fi
 
      case ${PARTFS} in
-         UFS) echo "NEWFS: /dev/${PART} - ${PARTFS}"
-              newfs /dev/${PART}${EXT} >>${LOGOUT} 2>>${LOGOUT}
+         UFS) echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
+              rc_halt "newfs /dev/${PART}${EXT}"
               ;;
-       UFS+S) echo "NEWFS: /dev/${PART} - ${PARTFS}"
-              newfs -U /dev/${PART}${EXT}  >>${LOGOUT} 2>>${LOGOUT}
+       UFS+S) echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
+              rc_halt "newfs -U /dev/${PART}${EXT}"
               ;;
-       UFS+J) echo "NEWFS: /dev/${PART} - ${PARTFS}"
-              newfs /dev/${PART}${EXT}  >>${LOGOUT} 2>>${LOGOUT}
-              gjournal label -f /dev/${PART}${EXT} >>${LOGOUT} 2>>${LOGOUT}
-              newfs -O 2 -J /dev/${PART}${EXT}.journal >>${LOGOUT} 2>>${LOGOUT}
+       UFS+J) echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
+              rc_halt "newfs /dev/${PART}${EXT}"
+              rc_halt "gjournal label -f /dev/${PART}${EXT}"
+              rc_halt "newfs -O 2 -J /dev/${PART}${EXT}.journal"
               ;;
-         ZFS) echo "NEWFS: /dev/${PART} - ${PARTFS}" 
+         ZFS) echo_log "NEWFS: /dev/${PART} - ${PARTFS}" 
               setup_zfs_filesystem "${PART}" "${PARTFS}" "${PARTMNT}" "${EXT}"
               ;;
         SWAP) ;;

Modified: pcbsd/trunk/pc-sysinstall/backend/functions.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend/functions.sh	2009-10-28 22:57:47 UTC (rev 4799)
+++ pcbsd/trunk/pc-sysinstall/backend/functions.sh	2009-10-29 02:48:40 UTC (rev 4800)
@@ -73,3 +73,83 @@
 
    exit 1
 };
+
+# Run-command, don't halt if command exits with non-0
+rc_nohalt()
+{
+  CMD="$1"
+
+  if [ -z "${CMD}" ]
+  then
+    exit_err "Error: missing argument in rc_nohalt()"
+  fi
+
+  echo "Running: ${CMD}" >>${LOGOUT}
+  ${CMD} >>${LOGOUT} 2>>${LOGOUT}
+
+};
+
+# Run-command, halt if command exits with non-0
+rc_halt()
+{
+  CMD="$1"
+
+  if [ -z "${CMD}" ]
+  then
+    exit_err "Error: missing argument in rc_halt()"
+  fi
+
+  echo "Running: ${CMD}" >>${LOGOUT}
+  ${CMD} >>${LOGOUT} 2>>${LOGOUT}
+  if [ "$?" != "0" ]
+  then
+    exit_err "Error $?"
+  fi
+};
+
+# Run-command w/echo to screen, halt if command exits with non-0
+rc_halt_echo()
+{
+  CMD="$1"
+
+  if [ -z "${CMD}" ]
+  then
+    exit_err "Error: missing argument in rc_halt_echo()"
+  fi
+
+  echo "Running: ${CMD}" >>${LOGOUT}
+  ${CMD} 2>&1 | tee -a ${LOGOUT} 
+  if [ "$?" != "0" ]
+  then
+    exit_err "Error $?: $CMD"
+  fi
+
+};
+
+# Run-command w/echo, don't halt if command exits with non-0
+rc_nohalt_echo()
+{
+  CMD="$1"
+
+  if [ -z "${CMD}" ]
+  then
+    exit_err "Error: missing argument in rc_nohalt_echo()"
+  fi
+
+  echo "Running: ${CMD}" >>${LOGOUT}
+  ${CMD} 2>&1 | tee -a ${LOGOUT} 
+
+};
+
+# Echo to the screen and to the log
+echo_log()
+{
+  STR="$1"
+
+  if [ -z "${STR}" ]
+  then
+    exit_err "Error: missing argument in echo_log()"
+  fi
+
+  echo "${STR}" | tee -a ${LOGOUT} 
+};



More information about the Commits mailing list