Permalink
Browse files

Remove much of the legacy UFS cruft which was still present in Warden

It will *require* ZFS going forward, which has been the default on PC-BSD for
a while now
  • Loading branch information...
1 parent 75b0622 commit 4905ba92e4b4be6ac9c9601d348b86921abb3fbc @kmoore134 kmoore134 committed Jun 26, 2014
View
@@ -577,6 +577,9 @@ Example:
# Fix old style meta-data, can be removed after 9.1
fix_old_meta
+# This checks if we have JDIR on a valid ZFS dataset
+zfs_prog_check
+
# Check what the user wants to do
case "$1" in
@@ -99,12 +99,7 @@ if [ -z "$TEMPLATE" -a -z "$ARCHIVEFILE" ] ; then
fi
# See if we need to create a new template for this system
- isDirZFS "${JDIR}"
- if [ $? -eq 0 ] ; then
- TDIR="${JDIR}/.warden-template-$DEFTEMPLATE"
- else
- TDIR="${JDIR}/.warden-template-$DEFTEMPLATE.tbz"
- fi
+ TDIR="${JDIR}/.warden-template-$DEFTEMPLATE"
if [ ! -e "$TDIR" ] ; then
FLAGS="-arch $ARCH -nick $DEFTEMPLATE"
@@ -132,10 +127,6 @@ if [ -z "$TEMPLATE" -a -z "$ARCHIVEFILE" ] ; then
elif [ -z "$ARCHIVEFILE" ] ; then
# Set WORLDCHROOT to the dir we will clone / file to extract
WORLDCHROOT="${JDIR}/.warden-template-$TEMPLATE"
- isDirZFS "${JDIR}"
- if [ $? -ne 0 ] ; then
- WORLDCHROOT="${WORLDCHROOT}.tbz"
- fi
else
# See if we are overriding the default archive file
WORLDCHROOT="$ARCHIVEFILE"
@@ -192,49 +183,25 @@ done
# If we are setting up a linux jail, lets do it now
if [ "$LINUXJAIL" = "YES" ] ; then
- isDirZFS "${JDIR}"
- if [ $? -eq 0 ] ; then
- # Create ZFS mount
- tank=`getZFSTank "$JDIR"`
- if [ -z "$tank" ] ; then
- exit_err "Failed getting ZFS dataset for $JDIR..";
- fi
- zfs create -o mountpoint=${JAILDIR} -p ${tank}${JAILDIR}
- if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS dataset"; fi
- else
- mkdir -p "${JAILDIR}"
+ # Create ZFS mount
+ tank=`getZFSTank "$JDIR"`
+ if [ -z "$tank" ] ; then
+ exit_err "Failed getting ZFS dataset for $JDIR..";
fi
+ zfs create -o mountpoint=${JAILDIR} -p ${tank}${JAILDIR}
+ if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS dataset"; fi
setup_linux_jail
exit 0
fi
echo "Building new Jail... Please wait..."
-isDirZFS "${JDIR}"
-if [ $? -eq 0 ] ; then
- # Create ZFS CLONE
- tank=`getZFSTank "$JDIR"`
- zfsp=`getZFSRelativePath "${WORLDCHROOT}"`
- jailp=`getZFSRelativePath "${JAILDIR}"`
- zfs clone ${tank}${zfsp}@clean ${tank}${jailp}
- if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base clone"; fi
-else
- # Running on UFS
- mkdir -p "${JAILDIR}"
- echo "Installing world..."
- if [ -d "${WORLDCHROOT}" ] ; then
- tar cvf - -C ${WORLDCHROOT} . 2>/dev/null | tar xpvf - -C "${JAILDIR}" 2>/dev/null
- else
- tar xvf ${WORLDCHROOT} -C "${JAILDIR}" 2>/dev/null
- fi
-
- # If this is a pluginjail on UFS :-( Do things the hard way.
- if [ "${PLUGINJAIL}" = "YES" ] ; then
- bootstrap_pkgng "${pjdir}" "pluginjail"
- fi
-
- echo "Done"
-fi
+# Create ZFS CLONE
+tank=`getZFSTank "$JDIR"`
+zfsp=`getZFSRelativePath "${WORLDCHROOT}"`
+jailp=`getZFSRelativePath "${JAILDIR}"`
+zfs clone ${tank}${zfsp}@clean ${tank}${jailp}
+if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base clone"; fi
mkdir ${JMETADIR}
echo "${HOST}" > ${JMETADIR}/host
@@ -77,104 +77,43 @@ download_template_files() {
create_template()
{
- # Creating ZFS dataset?
- isDirZFS "${JDIR}"
- if [ $? -eq 0 ] ; then
- local zfsp=`getZFSRelativePath "${TDIR}"`
-
- # Use ZFS base for cloning
- tank=`getZFSTank "${JDIR}"`
- isDirZFS "${TDIR}" "1"
- if [ $? -ne 0 ] ; then
- echo "Creating ZFS ${TDIR} dataset..."
- zfs create -o mountpoint=${TDIR} -p ${tank}${zfsp}
- if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS base dataset"; fi
- fi
-
- # Using a supplied tar file?
- if [ -n "$FBSDTAR" ] ; then
- tar xvpf $FBSDTAR -C ${TDIR} 2>/dev/null
- if [ $? -ne 0 ] ; then exit_err "Failed extracting: $FBSDTAR"; fi
- elif [ "$oldFBSD" = "YES" ] ; then
- cd ${JDIR}/.download/
- cat ${oldStr}.?? | tar --unlink -xpzf - -C ${TDIR} 2>/dev/null
- cd ${JDIR}
- else
- # Extract the dist files
- for f in $DFILES
- do
- tar xvpf ${JDIR}/.download/$f -C ${TDIR} 2>/dev/null
- if [ $? -ne 0 ] ; then exit_err "Failed extracting ZFS template environment"; fi
- rm ${JDIR}/.download/${f}
- done
- fi
-
- # Creating a plugin jail?
- if [ "$TPLUGJAIL" = "YES" ] ; then
- cp /etc/resolv.conf ${TDIR}/etc/resolv.conf
- bootstrap_pkgng "${TDIR}" "pluginjail"
- fi
-
- zfs snapshot ${tank}${zfsp}@clean
- if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base snapshot"; fi
+ local zfsp=`getZFSRelativePath "${TDIR}"`
+
+ # Use ZFS base for cloning
+ tank=`getZFSTank "${JDIR}"`
+ isDirZFS "${TDIR}" "1"
+ if [ $? -ne 0 ] ; then
+ echo "Creating ZFS ${TDIR} dataset..."
+ zfs create -o mountpoint=${TDIR} -p ${tank}${zfsp}
+ if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS base dataset"; fi
+ fi
+
+ # Using a supplied tar file?
+ if [ -n "$FBSDTAR" ] ; then
+ tar xvpf $FBSDTAR -C ${TDIR} 2>/dev/null
+ if [ $? -ne 0 ] ; then exit_err "Failed extracting: $FBSDTAR"; fi
+ elif [ "$oldFBSD" = "YES" ] ; then
+ cd ${JDIR}/.download/
+ cat ${oldStr}.?? | tar --unlink -xpzf - -C ${TDIR} 2>/dev/null
+ cd ${JDIR}
else
- # Sigh, still on UFS??
- if [ -d "${JDIR}/.templatedir" ]; then
- chflags -R noschg ${JDIR}/.templatedir
- rm -rf ${JDIR}/.templatedir
- fi
-
- if [ -n "$FBSDTAR" ] ; then
- # User-supplied tar file
- cp $FBSDTAR ${TDIR}
- elif [ "$oldFBSD" = "YES" ] ; then
- mkdir ${JDIR}/.templatedir
- cd ${JDIR}/.download/
- echo "Extrating FreeBSD..."
- cat ${oldStr}.?? | tar --unlink -xpzf - -C ${JDIR}/.templatedir 2>/dev/null
- if [ $? -ne 0 ] ; then exit_err "Failed to extract FreeBSD" ; fi
- cd ${JDIR}
-
- # Creating a plugin jail?
- if [ "$TPLUGJAIL" = "YES" ] ; then
- cp /etc/resolv.conf ${JDIR}/.templatedir/etc/resolv.conf
- bootstrap_pkgng "${JDIR}/.templatedir/" "pluginjail"
- fi
-
- echo "Creating template archive..."
- tar cvjf ${TDIR} -C ${JDIR}/.templatedir 2>/dev/null
- chflags -R noschg ${JDIR}/.templatedir
- rm -rf ${JDIR}/.templatedir
- else
- # Extract the dist files
- mkdir ${JDIR}/.templatedir
- for f in $DFILES
- do
- tar xvpf ${JDIR}/.download/$f -C ${JDIR}/.templatedir 2>/dev/null
- if [ $? -ne 0 ] ; then
- rm -rf ${JDIR}/.templatedir
- exit_err "Failed extracting template environment"
- fi
- rm ${JDIR}/.download/${f}
- done
-
- # Creating a plugin jail?
- if [ "$TPLUGJAIL" = "YES" ] ; then
- cp /etc/resolv.conf ${JDIR}/.templatedir/etc/resolv.conf
- bootstrap_pkgng "${JDIR}/.templatedir/" "pluginjail"
- fi
-
- echo "Creating template archive..."
- tar cvjf ${TDIR} -C ${JDIR}/.templatedir . 2>/dev/null
- if [ $? -ne 0 ] ; then
- chflags -R noschg ${JDIR}/.templatedir
- rm -rf ${JDIR}/.templatedir
- exit_err "Failed creating template environment"
- fi
- chflags -R noschg ${JDIR}/.templatedir
- rm -rf ${JDIR}/.templatedir
- fi
- fi # End of UFS section
+ # Extract the dist files
+ for f in $DFILES
+ do
+ tar xvpf ${JDIR}/.download/$f -C ${TDIR} 2>/dev/null
+ if [ $? -ne 0 ] ; then exit_err "Failed extracting ZFS template environment"; fi
+ rm ${JDIR}/.download/${f}
+ done
+ fi
+
+ # Creating a plugin jail?
+ if [ "$TPLUGJAIL" = "YES" ] ; then
+ cp /etc/resolv.conf ${TDIR}/etc/resolv.conf
+ bootstrap_pkgng "${TDIR}" "pluginjail"
+ fi
+
+ zfs snapshot ${tank}${zfsp}@clean
+ if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base snapshot"; fi
rm -rf ${JDIR}/.download
echo "Created jail template: $TNICK"
@@ -195,14 +134,6 @@ fi
# Set the template directory
TDIR="${JDIR}/.warden-template-$TNICK"
-# Set the name based upon if using ZFS or UFS
-isDirZFS "${JDIR}"
-if [ $? -eq 0 ] ; then
- TDIR="${TDIR}"
-else
- TDIR="${TDIR}.tbz"
-fi
-
# Make sure this template is available
if [ -e "${TDIR}" ] ; then
exit_err "A template with this nickname already exists!"
Oops, something went wrong.

0 comments on commit 4905ba9

Please sign in to comment.