Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 4905ba92e4b4be6ac9c9601d348b86921abb3fbc 1 parent 75b0622
@kmoore134 kmoore134 authored
View
3  src-sh/warden/bin/warden
@@ -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
View
59 src-sh/warden/scripts/backend/createjail.sh
@@ -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
View
141 src-sh/warden/scripts/backend/createtemplate.sh
@@ -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!"
View
154 src-sh/warden/scripts/backend/functions.sh
@@ -87,31 +87,24 @@ downloadpluginjail() {
[ "$(sha256 -q ${PJAIL})" != "$(cat ${PJAILSHA256})" ] &&
printerror "Error in download data, checksum mismatch. Please try again later."
- # Creating ZFS dataset?
- isDirZFS "${JDIR}"
- if [ $? -eq 0 ] ; then
- local zfsp=`getZFSRelativePath "${WORLDCHROOT}"`
-
- # Use ZFS base for cloning
- echo "Creating ZFS ${WORLDCHROOT} dataset..."
- tank=`getZFSTank "${JDIR}"`
- isDirZFS "${WORLDCHROOT}" "1"
- if [ $? -ne 0 ] ; then
- zfs create -o mountpoint=/${tank}${zfsp} -p ${tank}${zfsp}
- if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS base dataset"; fi
- mkdir -p "${WORLDCHROOT}/.plugins" >/dev/null 2>&1
- fi
+ local zfsp=`getZFSRelativePath "${WORLDCHROOT}"`
- pbi_add -e --no-checksig -p ${WORLDCHROOT} ${PJAIL}
- if [ $? -ne 0 ] ; then exit_err "Failed extracting ZFS chroot environment"; fi
-
- zfs snapshot ${tank}${zfsp}@clean
- if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base snapshot"; fi
- rm ${PJAIL}
- else
- # Save the chroot tarball
- mv ${PJAIL} ${WORLDCHROOT}
+ # Use ZFS base for cloning
+ echo "Creating ZFS ${WORLDCHROOT} dataset..."
+ tank=`getZFSTank "${JDIR}"`
+ isDirZFS "${WORLDCHROOT}" "1"
+ if [ $? -ne 0 ] ; then
+ zfs create -o mountpoint=/${tank}${zfsp} -p ${tank}${zfsp}
+ if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS base dataset"; fi
+ mkdir -p "${WORLDCHROOT}/.plugins" >/dev/null 2>&1
fi
+
+ pbi_add -e --no-checksig -p ${WORLDCHROOT} ${PJAIL}
+ if [ $? -ne 0 ] ; then exit_err "Failed extracting ZFS chroot environment"; fi
+
+ zfs snapshot ${tank}${zfsp}@clean
+ if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base snapshot"; fi
+ rm ${PJAIL}
rm ${PJAILSHA256}
};
@@ -149,30 +142,23 @@ downloadchroot() {
[ "$(md5 -q ${FBSD_TARBALL})" != "$(cat ${FBSD_TARBALL_CKSUM})" ] &&
printerror "Error in download data, checksum mismatch. Please try again later."
- # Creating ZFS dataset?
- isDirZFS "${JDIR}"
- if [ $? -eq 0 ] ; then
- local zfsp=`getZFSRelativePath "${CHROOT}"`
-
- # Use ZFS base for cloning
- echo "Creating ZFS ${CHROOT} dataset..."
- tank=`getZFSTank "${JDIR}"`
- isDirZFS "${CHROOT}" "1"
- if [ $? -ne 0 ] ; then
- zfs create -o mountpoint=/${tank}${zfsp} -p ${tank}${zfsp}
- if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS base dataset"; fi
- fi
+ local zfsp=`getZFSRelativePath "${CHROOT}"`
- tar xvpf ${FBSD_TARBALL} -C ${CHROOT} 2>/dev/null
- if [ $? -ne 0 ] ; then exit_err "Failed extracting ZFS chroot environment"; fi
-
- zfs snapshot ${tank}${zfsp}@clean
- if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base snapshot"; fi
- rm ${FBSD_TARBALL}
- else
- # Save the chroot tarball
- mv ${FBSD_TARBALL} ${CHROOT}
+ # Use ZFS base for cloning
+ echo "Creating ZFS ${CHROOT} dataset..."
+ tank=`getZFSTank "${JDIR}"`
+ isDirZFS "${CHROOT}" "1"
+ if [ $? -ne 0 ] ; then
+ zfs create -o mountpoint=/${tank}${zfsp} -p ${tank}${zfsp}
+ if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS base dataset"; fi
fi
+
+ tar xvpf ${FBSD_TARBALL} -C ${CHROOT} 2>/dev/null
+ if [ $? -ne 0 ] ; then exit_err "Failed extracting ZFS chroot environment"; fi
+
+ zfs snapshot ${tank}${zfsp}@clean
+ if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS base snapshot"; fi
+ rm ${FBSD_TARBALL}
rm ${FBSD_TARBALL_CKSUM}
};
@@ -1114,53 +1100,39 @@ list_templates()
{
echo "Jail Templates:"
echo "------------------------------"
- isDirZFS "${JDIR}"
- if [ $? -eq 0 ] ; then
- for i in `ls -d ${JDIR}/.warden-template* 2>/dev/null`
- do
- if [ ! -e "$i/bin/sh" ] ; then continue ; fi
- NICK=`echo "$i" | sed "s|${JDIR}/.warden-template-||g"`
- file "$i/bin/sh" 2>/dev/null | grep -q "64-bit"
- if [ $? -eq 0 ] ; then
- ARCH="amd64"
- else
- ARCH="i386"
- fi
- VER=`file "$i/bin/sh" | cut -d ',' -f 5 | awk '{print $3}'`
- if [ -e "$i/etc/rc.conf.pcbsd" ] ; then
- TYPE="TrueOS"
- else
- TYPE="FreeBSD"
- fi
- echo -e "${NICK} - $TYPE $VER ($ARCH)"
- done
- else
- # UFS, no details for U!
- ls ${JDIR}/.warden-template*.tbz | sed "s|${JDIR}/.warden-template-||g" | sed "s|.tbz||g"
- fi
- exit 0
+ for i in `ls -d ${JDIR}/.warden-template* 2>/dev/null`
+ do
+ if [ ! -e "$i/bin/sh" ] ; then continue ; fi
+ NICK=`echo "$i" | sed "s|${JDIR}/.warden-template-||g"`
+ file "$i/bin/sh" 2>/dev/null | grep -q "64-bit"
+ if [ $? -eq 0 ] ; then
+ ARCH="amd64"
+ else
+ ARCH="i386"
+ fi
+ VER=`file "$i/bin/sh" | cut -d ',' -f 5 | awk '{print $3}'`
+ if [ -e "$i/etc/rc.conf.pcbsd" ] ; then
+ TYPE="TrueOS"
+ else
+ TYPE="FreeBSD"
+ fi
+ echo -e "${NICK} - $TYPE $VER ($ARCH)"
+ done
+ exit 0
}
delete_template()
{
tDir="${JDIR}/.warden-template-${1}"
- isDirZFS "${JDIR}"
- if [ $? -eq 0 ] ; then
- isDirZFS "${tDir}" "1"
- if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${tDir}" ; fi
- tank=`getZFSTank "$tDir"`
- rp=`getZFSRelativePath "$tDir"`
- zfs destroy -r $tank${rp}
- if [ $? -ne 0 ] ; then
- exit_err "Could not remove template, perhaps you have jails still using it?"
- fi
- rmdir ${tDir}
- else
- if [ ! -e "${tDir}.tbz" ] ; then
- exit_err "No such template: ${1}"
- fi
- rm ${tDir}.tbz
+ isDirZFS "${tDir}" "1"
+ if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${tDir}" ; fi
+ tank=`getZFSTank "$tDir"`
+ rp=`getZFSRelativePath "$tDir"`
+ zfs destroy -r $tank${rp}
+ if [ $? -ne 0 ] ; then
+ exit_err "Could not remove template, perhaps you have jails still using it?"
fi
+ rmdir ${tDir}
echo "DONE"
exit 0
@@ -1225,3 +1197,13 @@ get_ip_host_flags()
done
}
+
+zfs_prog_check() {
+
+ isDirZFS "${JDIR}"
+ if [ $? -ne 0 ] ; then
+ echo "WARNING: JDIR is NOT set to a ZFS managed dataset.."
+ echo "Please change JDIR in /usr/local/etc/warden.conf to a ZFS dataset!"
+ fi
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.