Permalink
Browse files

Fix some issues creating jail templates on UFS.

Also fallback to pulling from FreeBSD mirrors if the PC-BSD mirrors
do not have the dist files we want
  • Loading branch information...
kmoore134 committed Oct 8, 2013
1 parent 228303d commit b5dbe14a3c5fa36a1d152f4984e9b5412a687767
Showing with 23 additions and 4 deletions.
  1. +11 −1 src-sh/warden/scripts/backend/createjail.sh
  2. +12 −3 src-sh/warden/scripts/backend/createtemplate.sh
@@ -116,7 +116,17 @@ if [ -z "$TEMPLATE" -a -z "$ARCHIVEFILE" ] ; then
fi
warden template create ${FLAGS}
if [ $? -ne 0 ] ; then
- exit_err "Failed create default template"
+ # If we failed, lets try again with FreeBSD dist files
+ FLAGS="-arch $ARCH -nick $DEFTEMPLATE"
+ FLAGS="-fbsd `uname -r | cut -d '-' -f 1-2` $FLAGS" ; export FLAGS
+
+ if [ "${PLUGINJAIL}" = "YES" ] ; then
+ FLAGS="$FLAGS -pluginjail"
+ fi
+ warden template create ${FLAGS}
+ if [ $? -ne 0 ] ; then
+ exit_err "Failed create default template"
+ fi
fi
fi
WORLDCHROOT="${TDIR}"
@@ -120,6 +120,7 @@ create_template()
else
# Sigh, still on UFS??
if [ -d "${JDIR}/.templatedir" ]; then
+ chflags -R noschg ${JDIR}/.templatedir
rm -rf ${JDIR}/.templatedir
fi
@@ -131,6 +132,7 @@ create_template()
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?
@@ -141,6 +143,7 @@ create_template()
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
@@ -150,7 +153,7 @@ create_template()
tar xvpf ${JDIR}/.download/$f -C ${JDIR}/.templatedir 2>/dev/null
if [ $? -ne 0 ] ; then
rm -rf ${JDIR}/.templatedir
- exit_err "Failed extracting ZFS template environment"
+ exit_err "Failed extracting template environment"
fi
rm ${JDIR}/.download/${f}
done
@@ -162,10 +165,16 @@ create_template()
fi
echo "Creating template archive..."
- tar cvjf ${TDIR} -C ${JDIR}/.templatedir 2>/dev/null
+ 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
+ fi # End of UFS section
rm -rf ${JDIR}/.download
echo "Created jail template: $TNICK"

0 comments on commit b5dbe14

Please sign in to comment.