[PC-BSD Commits] r19830 - in pcbsd/current/src-sh/warden: bin scripts/backend

svn at pcbsd.org svn at pcbsd.org
Sun Oct 21 09:16:28 PDT 2012


Author: kris
Date: 2012-10-21 16:16:27 +0000 (Sun, 21 Oct 2012)
New Revision: 19830

Modified:
   pcbsd/current/src-sh/warden/bin/warden
   pcbsd/current/src-sh/warden/scripts/backend/createjail.sh
   pcbsd/current/src-sh/warden/scripts/backend/exportjail.sh
Log:

Fix a bug exporting jails which left some files over

Add --linuxarchive flag, which can be used to specify we are creating a linux
jail from the target archive, instead of BSD jail



Modified: pcbsd/current/src-sh/warden/bin/warden
===================================================================
--- pcbsd/current/src-sh/warden/bin/warden	2012-10-21 09:18:27 UTC (rev 19829)
+++ pcbsd/current/src-sh/warden/bin/warden	2012-10-21 16:16:27 UTC (rev 19830)
@@ -507,12 +507,13 @@
 Creates a new jail, with options for system source, ports and autostarting.
 
 Available Flags:
-  --src       		      (Includes /usr/src system source)
-  --ports     		      (Includes the ports tree)
-  --startauto 		      (Start this jail at system boot)
-  --portjail  		      (Make this a portjail)
-  --linuxjail <installscript> (Make this a linux jail and use supplied script for installation)
-  --archive <tar archive>     (Use specified tar file for jail creation - BSD jails only!)
+  --src       		       (Includes /usr/src system source)
+  --ports     		       (Includes the ports tree)
+  --startauto 		       (Start this jail at system boot)
+  --portjail  		       (Make this a portjail)
+  --linuxjail <script>         (Make this a linux jail and use supplied script for installation)
+  --archive <tar>              (Use specified tar file for BSD jail creation)
+  --linuxarchive <tar>         (Use specified tar file for Linux jail creation)
 
 Usage:
 
@@ -859,14 +860,27 @@
              --linuxjail) LINUXJAIL="YES" ; shift
 			  if [ -z "$1" ] ; then exit_err "No linux setup script specified!"; fi
 			  LINUX_JAIL_SCRIPT="$1" ; export LINUX_JAIL_SCRIPT
+			  if [ -n "$LINUXARCHIVE_FILE" ] ; then 
+			     exit_err "--linuxjail and --linuxarchive are mutually exclusive!"
+			  fi
 			  ;;
              --archive) shift
 			  if [ -z "$1" ] ; then exit_err "No archive file specified!"; fi
-			  ARCHIVE_FILE="$1"
+			  ARCHIVE_FILE="$1" ; export ARCHIVE_FILE
 			  if [ ! -e "$ARCHIVE_FILE" ] ; then
 			     exit_err "No such file: $ARCHIVE_FILE"
 			  fi
 			  ;;
+             --linuxarchive) LINUXJAIL="YES" ; shift
+			  if [ -z "$1" ] ; then exit_err "No archive file specified!"; fi
+			  LINUXARCHIVE_FILE="$1" ; export LINUXARCHIVE_FILE
+			  if [ ! -e "$LINUXARCHIVE_FILE" ] ; then
+			     exit_err "No such file: $LINUXARCHIVE_FILE"
+			  fi
+			  if [ -n "$LINUX_JAIL_SCRIPT" ] ; then 
+			     exit_err "--linuxjail and --linuxarchive are mutually exclusive!"
+			  fi
+			  ;;
            esac
            shift
          done

Modified: pcbsd/current/src-sh/warden/scripts/backend/createjail.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/createjail.sh	2012-10-21 09:18:27 UTC (rev 19829)
+++ pcbsd/current/src-sh/warden/scripts/backend/createjail.sh	2012-10-21 16:16:27 UTC (rev 19830)
@@ -14,15 +14,26 @@
   fi
   touch "${JMETADIR}/jail-linux"
 
-  sh ${LINUX_JAIL_SCRIPT} "${JDIR}/${IP}" "${IP}" "${JMETADIR}"
-  if [ $? -ne 0 ] ; then
-     echo "Failed running ${LINUX_JAIL_SCRIPT}"
-     exit 1
+  if [ -n "$LINUXARCHIVE_FILE" ] ; then
+    echo "Extracting ${LINUXARCHIVE_FILE}..."
+    tar xvf ${LINUXARCHIVE_FILE} -C "${JDIR}/${IP}" 2>/dev/null
+    if [ $? -ne 0 ] ; then
+       echo "Failed Extracting ${LINUXARCHIVE_FILE}"
+       warden delete --confirm ${IP} 2>/dev/null
+       exit 1
+    fi
+  else
+    sh ${LINUX_JAIL_SCRIPT} "${JDIR}/${IP}" "${IP}" "${JMETADIR}"
+    if [ $? -ne 0 ] ; then
+       echo "Failed running ${LINUX_JAIL_SCRIPT}"
+       warden delete --confirm ${IP} 2>/dev/null
+       exit 1
+    fi
   fi
   
   # Create the master.passwd
   echo "root::0:0::0:0:Charlie &:/root:/bin/bash" > ${JDIR}/${IP}/etc/master.passwd
-  pwd_mkdb -d ${JDIR}/${IP}/tmp -p ${JDIR}/${IP}/etc/master.passwd
+  pwd_mkdb -d ${JDIR}/${IP}/tmp -p ${JDIR}/${IP}/etc/master.passwd 2>/dev/null
   mv ${JDIR}/${IP}/tmp/master.passwd ${JDIR}/${IP}/etc/
   mv ${JDIR}/${IP}/tmp/pwd.db ${JDIR}/${IP}/etc/
   mv ${JDIR}/${IP}/tmp/spwd.db ${JDIR}/${IP}/etc/

Modified: pcbsd/current/src-sh/warden/scripts/backend/exportjail.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/exportjail.sh	2012-10-21 09:18:27 UTC (rev 19829)
+++ pcbsd/current/src-sh/warden/scripts/backend/exportjail.sh	2012-10-21 16:16:27 UTC (rev 19830)
@@ -83,6 +83,12 @@
 rm .spacer
 rm ${IP}.header.tgz
 
+# Remove any extra jail meta-files from WTMP
+for i in `ls ${JMETADIR}/jail-* 2>/dev/null`
+do
+  mFile=`basename $i`
+  rm $mFile
+done
 
 if [ ! -z "${OUTDIR}" ]
 then



More information about the Commits mailing list