[PC-BSD Commits] r22317 - in pcbsd/current: build-files/src-patches src-qt4/warden-gui src-sh/port-files src-sh/warden src-sh/warden/bin src-sh/warden/conf src-sh/warden/scripts/backend

svn at pcbsd.org svn at pcbsd.org
Tue Apr 16 09:18:24 PDT 2013


Author: kris
Date: 2013-04-16 09:18:23 -0700 (Tue, 16 Apr 2013)
New Revision: 22317

Added:
   pcbsd/current/build-files/src-patches/3-GENERIC-VIMAGE
   pcbsd/current/src-sh/warden/pluginjail-packages
   pcbsd/current/src-sh/warden/scripts/backend/listpbis.sh
Modified:
   pcbsd/current/src-qt4/warden-gui/dialogEditIP.cpp
   pcbsd/current/src-qt4/warden-gui/dialogEditIP.h
   pcbsd/current/src-qt4/warden-gui/dialogEditIP.ui
   pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp
   pcbsd/current/src-qt4/warden-gui/dialogwarden.h
   pcbsd/current/src-qt4/warden-gui/dialogwarden.ui
   pcbsd/current/src-qt4/warden-gui/wizardNewJail.cpp
   pcbsd/current/src-qt4/warden-gui/wizardNewJail.h
   pcbsd/current/src-qt4/warden-gui/wizardNewJail.ui
   pcbsd/current/src-sh/port-files/pkg-plist
   pcbsd/current/src-sh/warden/LICENSE
   pcbsd/current/src-sh/warden/bin/warden
   pcbsd/current/src-sh/warden/conf/warden.conf
   pcbsd/current/src-sh/warden/scripts/backend/checkstatus.sh
   pcbsd/current/src-sh/warden/scripts/backend/checkupdates.sh
   pcbsd/current/src-sh/warden/scripts/backend/chrootjail.sh
   pcbsd/current/src-sh/warden/scripts/backend/createjail.sh
   pcbsd/current/src-sh/warden/scripts/backend/cronsnap.sh
   pcbsd/current/src-sh/warden/scripts/backend/deletejail.sh
   pcbsd/current/src-sh/warden/scripts/backend/details.sh
   pcbsd/current/src-sh/warden/scripts/backend/exportjail.sh
   pcbsd/current/src-sh/warden/scripts/backend/functions.sh
   pcbsd/current/src-sh/warden/scripts/backend/importjail.sh
   pcbsd/current/src-sh/warden/scripts/backend/listjails.sh
   pcbsd/current/src-sh/warden/scripts/backend/listpkgs.sh
   pcbsd/current/src-sh/warden/scripts/backend/setupusers.sh
   pcbsd/current/src-sh/warden/scripts/backend/startjail.sh
   pcbsd/current/src-sh/warden/scripts/backend/stopjail.sh
   pcbsd/current/src-sh/warden/scripts/backend/zfsclonesnap.sh
   pcbsd/current/src-sh/warden/scripts/backend/zfscronsnap.sh
   pcbsd/current/src-sh/warden/scripts/backend/zfslistclone.sh
   pcbsd/current/src-sh/warden/scripts/backend/zfslistsnap.sh
   pcbsd/current/src-sh/warden/scripts/backend/zfsmksnap.sh
   pcbsd/current/src-sh/warden/scripts/backend/zfsrevertsnap.sh
   pcbsd/current/src-sh/warden/scripts/backend/zfsrmclone.sh
   pcbsd/current/src-sh/warden/scripts/backend/zfsrmsnap.sh
Log:

Import the latest batch of Warden improvements from github

This includes the new ability to create jails by name, instead of IP. 

Now IP addresses can be changed on the fly, multiple ones added, etc.

The warden backend will also be using "vnet" for networking, allowing
a greater variety of services to run in a jail

Fixed the GUI to also take advantage of these features.



Modified: pcbsd/current/src-qt4/warden-gui/dialogEditIP.cpp
===================================================================
--- pcbsd/current/src-qt4/warden-gui/dialogEditIP.cpp	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-qt4/warden-gui/dialogEditIP.cpp	2013-04-16 16:18:23 UTC (rev 22317)
@@ -13,6 +13,7 @@
 #include <QInputDialog>
 #include <QProcess>
 #include <QString>
+#include <QFile>
 #include <QFileDialog>
 #include <QMessageBox>
 #include <QDebug>
@@ -21,21 +22,155 @@
 // Local Includes
 #include "dialogEditIP.h"
 
-void dialogEditIP::programInit(QString jIP, QStringList IPs)
+void dialogEditIP::programInit(QString name)
 {
-  wardenIP = jIP;
-  listIP->clear();
-  for ( int i=0; i<IPs.count() ; i++)
-     if ( ! IPs.at(i).isEmpty() )
-	listIP->addItem(IPs.at(i));
+  JailDir = pcbsd::Utils::getValFromPCConf("/usr/local/etc/warden.conf", "JDIR");
+  jailName = name;
+  QString tmp;
 
+  // Lets start loading IP addresses
+  QFile file( JailDir + "/." + jailName + ".meta/ipv4" );
+  if ( file.exists() && file.open( QIODevice::ReadOnly ) ) {
+     QTextStream stream( &file ); tmp=""; tmp = stream.readLine();
+     lineIP->setText(tmp);
+     if ( ! tmp.isEmpty() )
+        checkIPv4->setChecked(true);
+     file.close();
+  }
+
+  file.setFileName( JailDir + "/." + jailName + ".meta/bridge-ipv4" );
+  if ( file.exists() && file.open( QIODevice::ReadOnly ) ) {
+     QTextStream stream( &file ); tmp=""; tmp = stream.readLine();
+     lineIPBridge->setText(tmp);
+     if ( ! tmp.isEmpty() )
+        checkIPv4Bridge->setChecked(true);
+     file.close();
+  }
+
+  file.setFileName( JailDir + "/." + jailName + ".meta/defaultrouter-ipv4" );
+  if ( file.exists() && file.open( QIODevice::ReadOnly ) ) {
+     QTextStream stream( &file ); tmp=""; tmp = stream.readLine();
+     lineIPRouter->setText(tmp);
+     if ( ! tmp.isEmpty() )
+        checkIPv4Router->setChecked(true);
+     file.close();
+  }
+
+  file.setFileName( JailDir + "/." + jailName + ".meta/ipv6" );
+  if ( file.exists() && file.open( QIODevice::ReadOnly ) ) {
+     QTextStream stream( &file ); tmp=""; tmp = stream.readLine();
+     lineIP6->setText(tmp);
+     if ( ! tmp.isEmpty() )
+        checkIPv6->setChecked(true);
+     file.close();
+  }
+
+  file.setFileName( JailDir + "/." + jailName + ".meta/bridge-ipv6" );
+  if ( file.exists() && file.open( QIODevice::ReadOnly ) ) {
+     QTextStream stream( &file ); tmp=""; tmp = stream.readLine();
+     lineIP6Bridge->setText(tmp);
+     if ( ! tmp.isEmpty() )
+        checkIPv6Bridge->setChecked(true);
+     file.close();
+  }
+
+  file.setFileName( JailDir + "/." + jailName + ".meta/defaultrouter-ipv6" );
+  if ( file.exists() && file.open( QIODevice::ReadOnly ) ) {
+     QTextStream stream( &file ); tmp=""; tmp = stream.readLine();
+     lineIP6Router->setText(tmp);
+     if ( ! tmp.isEmpty() )
+        checkIPv6Router->setChecked(true);
+     file.close();
+  }
+
+  file.setFileName( JailDir + "/." + jailName + ".meta/alias-ipv4" );
+  if ( file.exists() && file.open( QIODevice::ReadOnly ) ) {
+     QTextStream stream( &file ); 
+     while ( ! file.atEnd() )
+       IPv4Alias << stream.readLine();
+     file.close();
+  }
+
+  file.setFileName( JailDir + "/." + jailName + ".meta/alias-bridge-ipv4" );
+  if ( file.exists() && file.open( QIODevice::ReadOnly ) ) {
+     QTextStream stream( &file ); 
+     while ( ! file.atEnd() )
+       IPv4AliasBridge << stream.readLine();
+     file.close();
+  }
+
+  file.setFileName( JailDir + "/." + jailName + ".meta/alias-ipv6" );
+  if ( file.exists() && file.open( QIODevice::ReadOnly ) ) {
+     QTextStream stream( &file ); 
+     while ( ! file.atEnd() )
+       IPv6Alias << stream.readLine();
+     file.close();
+  }
+
+  file.setFileName( JailDir + "/." + jailName + ".meta/alias-bridge-ipv6" );
+  if ( file.exists() && file.open( QIODevice::ReadOnly ) ) {
+     QTextStream stream( &file ); 
+     while ( ! file.atEnd() )
+       IPv6AliasBridge << stream.readLine();
+     file.close();
+  }
+
   // Our buttons / slots
+  connect( checkIPv4, SIGNAL( clicked() ), this, SLOT( slotCheckChecks() ) );
+  connect( checkIPv4Bridge, SIGNAL( clicked() ), this, SLOT( slotCheckChecks() ) );
+  connect( checkIPv4Router, SIGNAL( clicked() ), this, SLOT( slotCheckChecks() ) );
+  connect( checkIPv6, SIGNAL( clicked() ), this, SLOT( slotCheckChecks() ) );
+  connect( checkIPv6Bridge, SIGNAL( clicked() ), this, SLOT( slotCheckChecks() ) );
+  connect( checkIPv6Router, SIGNAL( clicked() ), this, SLOT( slotCheckChecks() ) );
+
+  connect( comboIPType, SIGNAL( currentIndexChanged(int) ), this, SLOT( slotComboIPChanged() ) );
+
   connect( pushSave, SIGNAL( clicked() ), this, SLOT( slotSaveClicked() ) );
   connect( pushCancel, SIGNAL( clicked() ), this, SLOT( slotCancelClicked() ) );
   connect( pushAdd, SIGNAL( clicked() ), this, SLOT( slotAddClicked() ) );
   connect( pushRemove, SIGNAL( clicked() ), this, SLOT( slotRemClicked() ) );
+
+  slotCheckChecks();
+  slotComboIPChanged();
 }
 
+void dialogEditIP::slotComboIPChanged()
+{
+   QStringList curList;
+
+   // IPv4 Aliases
+   if ( comboIPType->currentIndex() == 0 )
+      curList = IPv4Alias;
+
+   // IPv4 Bridge Aliases
+   if ( comboIPType->currentIndex() == 1 )
+      curList = IPv4AliasBridge;
+
+   // IPv6 Aliases
+   if ( comboIPType->currentIndex() == 2 )
+      curList = IPv6Alias;
+
+   // IPv6 Bridge Aliases
+   if ( comboIPType->currentIndex() == 3 )
+      curList = IPv6AliasBridge;
+
+   listIP->clear();
+   for (int i = 0; i < curList.size(); ++i)
+          listIP->addItem(curList.at(i));
+
+}
+
+void dialogEditIP::slotCheckChecks()
+{
+  lineIP->setEnabled(checkIPv4->isChecked());
+  lineIPBridge->setEnabled(checkIPv4Bridge->isChecked());
+  lineIPRouter->setEnabled(checkIPv4Router->isChecked());
+  lineIP6->setEnabled(checkIPv6->isChecked());
+  lineIP6Bridge->setEnabled(checkIPv6Bridge->isChecked());
+  lineIP6Router->setEnabled(checkIPv6Router->isChecked());
+
+}
+
 void dialogEditIP::slotCancelClicked()
 {
    close();
@@ -43,6 +178,31 @@
 
 bool dialogEditIP::sanityCheckSettings()
 {
+  if ( checkIPv4->isChecked() && ! checkValidBlock(lineIP->text(), QString("IPv4")) ) {
+        QMessageBox::critical(this, tr("Warden"), tr("Invalid IPv4 address!"), QMessageBox::Ok, QMessageBox::Ok);
+        return false;
+  }
+  if ( checkIPv4Bridge->isChecked() && ! checkValidBlock(lineIPBridge->text(), QString("IPv4")) ) {
+        QMessageBox::critical(this, tr("Warden"), tr("Invalid IPv4 bridge address!"), QMessageBox::Ok, QMessageBox::Ok);
+        return false;
+  }
+  if ( checkIPv4Router->isChecked() && ! checkValidBlock(lineIPRouter->text(), QString("IPv4")) ) {
+        QMessageBox::critical(this, tr("Warden"), tr("Invalid IPv4 router address!"), QMessageBox::Ok, QMessageBox::Ok);
+        return false;
+  }
+  if ( checkIPv6->isChecked() && ! checkValidBlock(lineIP6->text(), QString("IPv6")) ) {
+        QMessageBox::critical(this, tr("Warden"), tr("Invalid IPv6 address!"), QMessageBox::Ok, QMessageBox::Ok);
+        return false;
+  }
+  if ( checkIPv6Bridge->isChecked() && ! checkValidBlock(lineIP6Bridge->text(), QString("IPv6")) ) {
+        QMessageBox::critical(this, tr("Warden"), tr("Invalid IPv6 bridge address!"), QMessageBox::Ok, QMessageBox::Ok);
+        return false;
+  }
+  if ( checkIPv6Router->isChecked() && ! checkValidBlock(lineIP6Router->text(), QString("IPv6")) ) {
+        QMessageBox::critical(this, tr("Warden"), tr("Invalid IPv6 router address!"), QMessageBox::Ok, QMessageBox::Ok);
+        return false;
+  }
+
   return true;
 }
 
@@ -58,6 +218,137 @@
 
 void dialogEditIP::saveSettings()
 {
+  QString tmp;
+  QFile file;
+
+  // Start saving settings
+  file.setFileName( JailDir + "/." + jailName + ".meta/alias-ipv4" );
+  if ( ! IPv4Alias.isEmpty() ) {
+    if ( file.open( QIODevice::WriteOnly ) ) {
+       QTextStream stream( &file );
+       for (int i = 0; i < IPv4Alias.size(); ++i)
+         stream << IPv4Alias.at(i);
+       file.close();
+    }
+  } else {
+    file.remove();
+  }
+
+  file.setFileName( JailDir + "/." + jailName + ".meta/alias-bridge-ipv4" );
+  if ( ! IPv4AliasBridge.isEmpty() ) {
+    if ( file.open( QIODevice::WriteOnly ) ) {
+       QTextStream stream( &file );
+       for (int i = 0; i < IPv4AliasBridge.size(); ++i)
+         stream << IPv4AliasBridge.at(i);
+       file.close();
+    }
+  } else {
+    file.remove();
+  }
+
+  file.setFileName( JailDir + "/." + jailName + ".meta/alias-ipv6" );
+  if ( ! IPv6Alias.isEmpty() ) {
+    if ( file.open( QIODevice::WriteOnly ) ) {
+       QTextStream stream( &file );
+       for (int i = 0; i < IPv6Alias.size(); ++i)
+         stream << IPv6Alias.at(i);
+       file.close();
+    }
+  } else {
+    file.remove();
+  }
+
+  file.setFileName( JailDir + "/." + jailName + ".meta/alias-bridge-ipv6" );
+  if ( ! IPv6AliasBridge.isEmpty() ) {
+    if ( file.open( QIODevice::WriteOnly ) ) {
+       QTextStream stream( &file );
+       for (int i = 0; i < IPv6AliasBridge.size(); ++i)
+         stream << IPv6AliasBridge.at(i);
+       file.close();
+    }
+  } else {
+    file.remove();
+  }
+
+  file.setFileName( JailDir + "/." + jailName + ".meta/ipv4" );
+  if ( checkIPv4->isChecked() ) {
+    if ( file.open( QIODevice::WriteOnly ) ) {
+       QTextStream stream( &file ); tmp = lineIP->text();
+       if (tmp.indexOf("/") == -1)
+         tmp = tmp + "/24"; 
+       stream << tmp;
+       file.close();
+    }
+  } else {
+    file.remove();
+  }
+
+  file.setFileName( JailDir + "/." + jailName + ".meta/bridge-ipv4" );
+  if ( checkIPv4Bridge->isChecked() ) {
+    if ( file.open( QIODevice::WriteOnly ) ) {
+       QTextStream stream( &file ); tmp = lineIPBridge->text();
+       if (tmp.indexOf("/") == -1)
+         tmp = tmp + "/24"; 
+       stream << tmp;
+       file.close();
+    }
+  } else {
+    file.remove();
+  }
+
+  file.setFileName( JailDir + "/." + jailName + ".meta/defaultrouter-ipv4" );
+  if ( checkIPv4Router->isChecked() ) {
+    if ( file.open( QIODevice::WriteOnly ) ) {
+       QTextStream stream( &file ); tmp = lineIPRouter->text();
+       if (tmp.indexOf("/") == -1)
+         tmp = tmp + "/24"; 
+       stream << tmp;
+       file.close();
+    }
+  } else {
+    file.remove();
+  }
+
+  file.setFileName( JailDir + "/." + jailName + ".meta/ipv6" );
+  if ( checkIPv6->isChecked() ) {
+    if ( file.open( QIODevice::WriteOnly ) ) {
+       QTextStream stream( &file ); tmp = lineIP6->text();
+       if (tmp.indexOf("/") == -1)
+         tmp = tmp + "/64"; 
+       stream << tmp;
+       file.close();
+    }
+  } else {
+    file.remove();
+  }
+
+  file.setFileName( JailDir + "/." + jailName + ".meta/bridge-ipv6" );
+  if ( checkIPv6Bridge->isChecked() ) {
+    if ( file.open( QIODevice::WriteOnly ) ) {
+       QTextStream stream( &file ); tmp = lineIP6Bridge->text();
+       if (tmp.indexOf("/") == -1)
+         tmp = tmp + "/64"; 
+       stream << tmp;
+       file.close();
+    }
+  } else {
+    file.remove();
+  }
+
+  file.setFileName( JailDir + "/." + jailName + ".meta/defaultrouter-ipv6" );
+  if ( checkIPv6Router->isChecked() ) {
+    if ( file.open( QIODevice::WriteOnly ) ) {
+       QTextStream stream( &file ); tmp = lineIP6Router->text();
+       if (tmp.indexOf("/") == -1)
+         tmp = tmp + "/64"; 
+       stream << tmp;
+       file.close();
+    }
+  } else {
+    file.remove();
+  }
+
+        /*
 	QStringList IPs;
 	for ( int i=0; i<listIP->count() ; i++)
 		IPs << listIP->item(i)->text();
@@ -75,26 +366,80 @@
                 ipcmd.waitForFinished(100);
                 QCoreApplication::processEvents();
         }
+        */
 	
 }
 
 void dialogEditIP::slotAddClicked()
 {
-	bool ok;
-	QString url = QInputDialog::getText(this, tr("Add IP"),
-					tr("IP Address:"), QLineEdit::Normal,
-					QString(), &ok);
-	if ( ok ) {
-          if ( pcbsd::Utils::validateIPV4(url) || pcbsd::Utils::validateIPV6(url) )
-	    listIP->addItem(url);
-          else
-	    QMessageBox::critical(this, tr("Warden"), \
+   bool ok;
+   QString address = QInputDialog::getText(this, tr("Add IP"),
+			tr("IP Address:"), QLineEdit::Normal,
+			QString(), &ok);
+   if ( ! ok )
+      return;
+
+   if ( ! checkValidBlock(address, "IPv4") || checkValidBlock(address, "IPv6") )
+      QMessageBox::critical(this, tr("Warden"), \
                                 tr("Please enter a valid IPV4 or IPV6 address!"), \
                                 QMessageBox::Ok, \
                                 QMessageBox::Ok);
-        }
+
+   // IPv4 Aliases
+   if ( comboIPType->currentIndex() == 0 ) {
+      if ( address.indexOf("/") == -1 ) 
+         address = address + "/24";
+      IPv4Alias << address;
+      listIP->addItem(address);
+   }
+
+   // IPv4 Bridge Aliases
+   if ( comboIPType->currentIndex() == 1 ) {
+      if ( address.indexOf("/") == -1 ) 
+         address = address + "/24";
+      IPv4AliasBridge << address;
+      listIP->addItem(address);
+   }
+
+   // IPv6 Aliases
+   if ( comboIPType->currentIndex() == 2 ) {
+      if ( address.indexOf("/") == -1 ) 
+         address = address + "/64";
+      IPv6Alias << address;
+      listIP->addItem(address);
+   }
+
+   // IPv6 Bridge Aliases
+   if ( comboIPType->currentIndex() == 3 ) {
+      if ( address.indexOf("/") == -1 ) 
+         address = address + "/64";
+      IPv6AliasBridge << address;
+      listIP->addItem(address);
+   }
+
 }
 
+bool dialogEditIP::checkValidBlock(QString block, QString type)
+{
+   QString url = block;
+
+   // Strip off the /24 part
+   if ( url.indexOf("/") != -1 )
+      url.truncate(url.indexOf("/"));
+
+   if ( type == "IPv4" ) {
+      if ( ! pcbsd::Utils::validateIPV4(url) )
+	return false;
+
+   } else {
+      if ( ! pcbsd::Utils::validateIPV6(url) )
+	return false;
+
+   }
+
+   return true;
+}
+
 void dialogEditIP::slotRemClicked()
 {
 	if ( ! listIP->currentItem() )

Modified: pcbsd/current/src-qt4/warden-gui/dialogEditIP.h
===================================================================
--- pcbsd/current/src-qt4/warden-gui/dialogEditIP.h	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-qt4/warden-gui/dialogEditIP.h	2013-04-16 16:18:23 UTC (rev 22317)
@@ -14,7 +14,7 @@
           setupUi(this);
         }
 
-	void programInit(QString, QStringList);
+	void programInit(QString);
 
 public slots:
 
@@ -26,11 +26,19 @@
         void slotRemClicked();
         void slotCancelClicked();
         void slotSaveClicked();
+        void slotCheckChecks();
+        void slotComboIPChanged();
 
 private:
 	void displayRepos();
         void saveSettings();
-        QString wardenIP;
+        bool checkValidBlock(QString block, QString type);
+        QString jailName;
+        QString JailDir;
+        QStringList IPv4Alias;
+        QStringList IPv4AliasBridge;
+        QStringList IPv6Alias;
+        QStringList IPv6AliasBridge;
 
 signals:
         void saved();

Modified: pcbsd/current/src-qt4/warden-gui/dialogEditIP.ui
===================================================================
(Binary files differ)

Modified: pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp
===================================================================
--- pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp	2013-04-16 16:18:23 UTC (rev 22317)
@@ -42,6 +42,10 @@
    listJails->setSelectionMode(QAbstractItemView::SingleSelection);
    listJails->setAllColumnsShowFocus(TRUE);
 
+   // Run this a single time, just to be sure we did any jail import / migration
+   // from legacy jails
+   system("warden list");
+
    // Hide the identifier column / host column
    listJails->setColumnHidden(0, true);
    listJails->setColumnWidth(1, 200);
@@ -129,7 +133,7 @@
 
 void dialogWarden::refreshJails()
 {
-   QString jType, jIPs, jZFS;
+   QString jType, jName, jZFS;
    QStringList jD;
    QStringList mountOut;
  
@@ -165,26 +169,15 @@
        jD.clear();
 
        qDebug() << "Checking:" << d[i];
+
+       jName = d[i].replace(".meta", "").remove(0, 1);
 	   
-       // Check for the IP of this jail
-       QFile fileIP( JailDir + "/" + d[i] + "/ip" );
-       if ( ! fileIP.exists() )
-          continue;
-       if ( ! fileIP.open( QIODevice::ReadOnly ) )
-          continue;
-       QTextStream streamip( &fileIP );
-       QString jIP;
-       while ( !streamip.atEnd() )
-          jIP = streamip.readLine(); // line of text excluding '\n'
-       fileIP.close();
-
        // Check if this jail is created on ZFS
        jZFS="NO";
        for (int z = 0; z < mountOut.size(); ++z)
-	  if ( mountOut.at(z).indexOf("on " + JailDir + "/" + jIP) != -1 && mountOut.at(z).indexOf("(zfs,") != -1 )
+	  if ( mountOut.at(z).indexOf("on " + JailDir + "/" + jName) != -1 && mountOut.at(z).indexOf("(zfs,") != -1 )
              jZFS="YES";
 
-
        // Check for the hostname of this jail
        QFile file( JailDir + "/" + d[i] + "/host" );
        if ( ! file.exists() )
@@ -197,17 +190,22 @@
           host = stream.readLine(); // line of text excluding '\n'
        file.close();
 	    
-       // Check for additional IPs in this jail
-       jIPs = "";
-       QFile fileip(JailDir + "/" + d[i] + "/ip-extra" );
-       if ( fileip.exists() ) {
-         if (fileip.open( QIODevice::ReadOnly ) ) {
-            QTextStream stream2( &fileip );
-            while ( !stream2.atEnd() )
-              jIPs = jIPs + stream2.readLine().simplified() + " "; // line of text excluding '\n'
-	 }
-         fileip.close();
+       // Build list of IPs for this jail
+       QString jIPs = "";
+       QStringList ipFiles;
+       ipFiles << "ipv4" << "ipv6";
+       for (int f = 0; f < ipFiles.size(); ++f) {
+         QFile fileip(JailDir + "/" + d[i] + "/" + ipFiles.at(f) );
+         if ( fileip.exists() ) {
+           if (fileip.open( QIODevice::ReadOnly ) ) {
+              QTextStream stream2( &fileip );
+              while ( !stream2.atEnd() )
+                jIPs = jIPs + stream2.readLine().simplified() + " "; // line of text excluding '\n'
+	   }
+           fileip.close();
+         }
        }
+       qDebug() << jIPs;
 
        // Check the type of jail
        jType = "Traditional";
@@ -220,14 +218,14 @@
 
        // Display the jail in the tree widget now
        QStringList cols;
-       cols << jIP << jIP << host;
+       cols << jName << host;
 
        QTreeWidgetItem *curItem = new QTreeWidgetItem( listJails, cols );
        if ( ! listJails->currentItem() )
          listJails->setCurrentItem(curItem);
 
        // Save additional jail details into list
-       jD << jIP << "Pending" << jType << jIPs << "" << "" << "" << jZFS;
+       jD << jName << "Pending" << jType << jIPs << "" << "" << "" << jZFS;
        jailDetails << jD;
    
    } // end of loop
@@ -304,17 +302,22 @@
 	return;
     }
 
-    // Check for additional IPs in this jail
-    QString jIPs;
-    QFile fileip(JailDir + "/." + currentDetailsWorkingJail + ".meta/ip-extra" );
-    if ( fileip.exists() ) {
-      if (fileip.open( QIODevice::ReadOnly ) ) {
-         QTextStream stream2( &fileip );
-         while ( !stream2.atEnd() )
-           jIPs = jIPs + stream2.readLine().simplified() + " "; // line of text excluding '\n'
+    // Build list of IPs for this jail
+    QString jIPs = "";
+    QStringList ipFiles;
+    ipFiles << "ipv4" << "ipv6";
+    for (int f = 0; f < ipFiles.size(); ++f) {
+       QFile fileip(JailDir + "/." + currentDetailsWorkingJail + ".meta/" + ipFiles.at(f) );
+       if ( fileip.exists() ) {
+         if (fileip.open( QIODevice::ReadOnly ) ) {
+            QTextStream stream2( &fileip );
+            while ( !stream2.atEnd() )
+             jIPs = jIPs + stream2.readLine().simplified() + " "; // line of text excluding '\n'
+         }
          fileip.close();
-      }
+       }
     }
+    qDebug() << "Found IPS:" << jIPs;
 
     // Save the new jail IPs
     for (int i=0; i < jailDetails.count(); ++i) {
@@ -581,11 +584,11 @@
 	    if ( exitStatus == 0) {
                 running = true;
 		(*it)->setIcon(1, QIcon(":running.png"));
-	        (*it)->setText(3, "Running");
+	        (*it)->setText(2, "Running");
 	    } else {
                 running = false;
 		(*it)->setIcon(1, QIcon(":stopped.png"));
-	        (*it)->setText(3, "Not Running");
+	        (*it)->setText(2, "Not Running");
 	    }
 
 	    // See if we can update push buttons
@@ -624,8 +627,8 @@
 
     if ( listJails->currentItem()) {
           popupip = listJails->currentItem()->text(0);
-          Status = listJails->currentItem()->text(3);
-          Updates = listJails->currentItem()->text(4);
+          Status = listJails->currentItem()->text(2);
+          Updates = listJails->currentItem()->text(3);
 	  popup = new QMenu();
 	  if ( Status == "Running" )
 	      popup->addAction( tr("Stop this Jail") , this, SLOT(slotStopJail() )  );
@@ -686,7 +689,7 @@
           return;
 
 	// If jail is running, lets stop it
-        if ( listJails->currentItem()->text(3) == "Running" ) {
+        if ( listJails->currentItem()->text(2) == "Running" ) {
 	   slotStopJail();
            return;
         }
@@ -897,19 +900,19 @@
       }
       newJailWizard->setHostIPUsed(uH, uI);
       
-      connect( newJailWizard, SIGNAL(create(const QString &, const QString &, bool, const QString &, bool, bool, bool, bool, const QString &)), this, SLOT(slotCreateNewJail(const QString &, const QString &, bool, const QString &, bool, bool, bool, bool, const QString &) ) );
+      connect( newJailWizard, SIGNAL(create(const QString &, const QString &, const QString &, bool, bool, const QString &, bool, bool, bool, bool, const QString &)), this, SLOT(slotCreateNewJail(const QString &, const QString &, const QString &, bool, bool, const QString &, bool, bool, bool, bool, const QString &) ) );
       newJailWizard->show();
 }
 
 
-void dialogWarden::slotCreateNewJail( const QString &IP, const QString &host, bool tradjail, const QString &rootpw, bool src, bool ports, bool autostart, bool linuxJail, const QString &linuxScript )
+void dialogWarden::slotCreateNewJail( const QString &IP, const QString &IP6, const QString &host, bool tradjail, bool PCUtils, const QString &rootpw, bool src, bool ports, bool autostart, bool linuxJail, const QString &linuxScript )
 {
     if ( tradjail || linuxJail )
       newRootPW=rootpw;
     else
       newRootPW="";
     
-    newIP=IP;
+    newHost=host;
 
     /***********************************************************************************************************************
         Now create the jail here
@@ -926,9 +929,22 @@
       createJailProc = new QProcess( this );
       QString program = "warden";
       QStringList args;
-      args << "create" << IP << host;
+      args << "create" << host;
 
       // Set our optional flags
+      if ( ! IP.isEmpty() ) {
+        args << "--ipv4";
+        args << IP;
+      }
+
+      if ( ! IP6.isEmpty() ) {
+        args << "--ipv6";
+        args << IP6;
+      }
+
+      if ( tradjail && ! PCUtils )
+        args << "--vanilla";
+
       if ( ! tradjail && ! linuxJail )
         args << "--portjail";
 
@@ -943,7 +959,7 @@
 
       if ( autostart )
 	args << "--startauto";
-      
+
       // Connect the exited signal and start the process 
       createJailProc->setProcessChannelMode(QProcess::MergedChannels);
       createJailProc->setReadChannel(QProcess::StandardOutput);
@@ -975,7 +991,7 @@
     userAddProc = new QProcess( this );
     QString program = ProgDir + "/scripts/backend/setupusers.sh";
     QStringList args;
-    args << newIP << newRootPW;
+    args << newHost << newRootPW;
       
     // Connect the exited signal and start the process 
     userAddProc->setProcessChannelMode(QProcess::MergedChannels);
@@ -1363,14 +1379,14 @@
    currentSnapshot = -1;
    //pushStart->setEnabled(false);
 
-   if ( listJails->currentItem()->text(3) == "Running" ) {
+   if ( listJails->currentItem()->text(2) == "Running" ) {
      //pushStart->setEnabled(true);
      pushTerminal->setEnabled(true);
      pushStart->setIcon(QIcon(":stopjail.png"));
      pushStart->setIconSize(QSize(16,16));
      pushStart->setToolTip(tr("Stop the selected jail"));
    }
-   if ( listJails->currentItem()->text(3) == "Not Running" ) {
+   if ( listJails->currentItem()->text(2) == "Not Running" ) {
      //pushStart->setEnabled(true);
      pushTerminal->setEnabled(false);
      pushStart->setIcon(QIcon(":running.png"));
@@ -1438,24 +1454,9 @@
    if ( ! listJails->currentItem() )
      return;
 
-   QString IPs;
-
-   for (int i=0; i < jailDetails.count(); ++i) {
-     if ( jailDetails.at(i).at(0) != listJails->currentItem()->text(0) )
-        continue;
-     IPs = jailDetails.at(i).at(3);
-     if ( jailDetails.at(i).at(1) == "Pending" )
-	return;
-     break;
-   }
-  
-
    dIP = new dialogEditIP();
    connect(dIP, SIGNAL(saved()),this, SLOT(slotMonitorJailDetails()) );
-   if ( IPs.isEmpty() )
-      dIP->programInit(listJails->currentItem()->text(0), QStringList() );
-   else
-      dIP->programInit(listJails->currentItem()->text(0), IPs.split(" ") );
+   dIP->programInit(listJails->currentItem()->text(0));
    dIP->exec();
 
 }

Modified: pcbsd/current/src-qt4/warden-gui/dialogwarden.h
===================================================================
--- pcbsd/current/src-qt4/warden-gui/dialogwarden.h	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-qt4/warden-gui/dialogwarden.h	2013-04-16 16:18:23 UTC (rev 22317)
@@ -53,7 +53,7 @@
     void slotFinishedOutput();
     void slotReadPkgsOutput();
     void slotClickedNewJail();
-    void slotCreateNewJail( const QString &, const QString &, bool, const QString &, bool, bool, bool, bool, const QString & );
+    void slotCreateNewJail( const QString &, const QString &, const QString &, bool, bool, const QString &, bool, bool, bool, bool, const QString & );
     void slotReadCreateOutput();
     void slotFinishedJailCreate();
     void slotReadUserAddOutput();
@@ -123,7 +123,6 @@
     QProcess *deleteJailProc;
     wizardNewJail *newJailWizard;
     QProcess *createJailProc;
-    QString newIP;
     QString newHost;
     bool newSrc;
     bool newPorts;

Modified: pcbsd/current/src-qt4/warden-gui/dialogwarden.ui
===================================================================
(Binary files differ)

Modified: pcbsd/current/src-qt4/warden-gui/wizardNewJail.cpp
===================================================================
--- pcbsd/current/src-qt4/warden-gui/wizardNewJail.cpp	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-qt4/warden-gui/wizardNewJail.cpp	2013-04-16 16:18:23 UTC (rev 22317)
@@ -21,12 +21,30 @@
     connect(lineRoot, SIGNAL(textChanged ( const QString & )), this, SLOT(slotCheckComplete() ) );
     connect(lineRoot2, SIGNAL(textChanged ( const QString & )), this, SLOT(slotCheckComplete() ) );
     connect(lineIP, SIGNAL(textChanged ( const QString & )), this, SLOT(slotCheckComplete() ) );
+    connect(lineIP6, SIGNAL(textChanged ( const QString & )), this, SLOT(slotCheckComplete() ) );
+    connect(checkIPv4, SIGNAL(clicked()), this, SLOT(slotCheckChecks()));
+    connect(checkIPv6, SIGNAL(clicked()), this, SLOT(slotCheckChecks()));
     connect(lineHost, SIGNAL(textChanged ( const QString & )), this, SLOT(slotCheckComplete() ) );
     connect(lineLinuxScript, SIGNAL(textChanged ( const QString & )), this, SLOT(slotCheckComplete() ) );
     connect(pushLinuxScript, SIGNAL(clicked()), this, SLOT(slotSelectLinuxScript()) );
     connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(slotCheckComplete()) );
 }
 
+void wizardNewJail::slotCheckChecks()
+{
+   if ( checkIPv4->isChecked() )
+      lineIP->setEnabled(true);
+   else
+      lineIP->setEnabled(false);
+
+   if ( checkIPv6->isChecked() )
+      lineIP6->setEnabled(true);
+   else
+      lineIP6->setEnabled(false);
+
+   slotCheckComplete();
+}
+
 void wizardNewJail::setHostIPUsed(QStringList uH, QStringList uIP)
 {
    usedHosts = uH;
@@ -35,8 +53,13 @@
 
 void wizardNewJail::accept()
 {
+    QString ip4, ip6;
+    if ( checkIPv4->isChecked() )
+       ip4 = lineIP->text();
+    if ( checkIPv6->isChecked() )
+       ip6 = lineIP6->text();
     
-    emit create(lineIP->text(), lineHost->text(), radioTraditionalJail->isChecked(),
+    emit create(ip4, ip6, lineHost->text(), radioTraditionalJail->isChecked(), checkPCBSDUtils->isChecked(),
                 lineRoot->text(), checkSystemSource->isChecked(), checkPortsTree->isChecked(),
                 checkAutostart->isChecked(), radioLinuxJail->isChecked(), lineLinuxScript->text());
     close();
@@ -65,10 +88,14 @@
   switch (currentId()) {
      case Page_IP:
          // Make sure items are not empty
-         if ( lineIP->text().isEmpty() ) {
+         if ( checkIPv4->isChecked() && lineIP->text().isEmpty() ) {
             button(QWizard::NextButton)->setEnabled(false);
             return false;
 	 }
+         if ( checkIPv6->isChecked() && lineIP6->text().isEmpty() ) {
+            button(QWizard::NextButton)->setEnabled(false);
+            return false;
+	 }
          if ( lineHost->text().isEmpty() ) {
             button(QWizard::NextButton)->setEnabled(false);
             return false;

Modified: pcbsd/current/src-qt4/warden-gui/wizardNewJail.h
===================================================================
--- pcbsd/current/src-qt4/warden-gui/wizardNewJail.h	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-qt4/warden-gui/wizardNewJail.h	2013-04-16 16:18:23 UTC (rev 22317)
@@ -24,6 +24,7 @@
     virtual void accept();
     void slotClose();
     void slotCheckComplete();
+    void slotCheckChecks();
     void slotSelectLinuxScript();
 
 private:
@@ -32,6 +33,6 @@
     enum { Page_IP, Page_Type, Page_Root, Page_Linux, Page_Opts };
 
 signals:
-     void create(const QString &, const QString &, bool, const QString &,  bool, bool, bool, bool, const QString &);
+     void create(const QString &, const QString &, const QString &, bool, bool, const QString &,  bool, bool, bool, bool, const QString &);
 } ;
 #endif // WIZARDCREATEJAIL_H

Modified: pcbsd/current/src-qt4/warden-gui/wizardNewJail.ui
===================================================================
(Binary files differ)

Modified: pcbsd/current/src-sh/port-files/pkg-plist
===================================================================
--- pcbsd/current/src-sh/port-files/pkg-plist	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/port-files/pkg-plist	2013-04-16 16:18:23 UTC (rev 22317)
@@ -38,6 +38,7 @@
 share/warden/scripts/backend/startjail.sh
 share/warden/scripts/backend/chrootjail.sh
 share/warden/scripts/backend/listjails.sh
+share/warden/scripts/backend/listpbis.sh
 share/warden/scripts/backend/cronsnap.sh
 share/warden/scripts/backend/setupusers.sh
 share/warden/scripts/backend/checkstatus.sh

Modified: pcbsd/current/src-sh/warden/LICENSE
===================================================================
--- pcbsd/current/src-sh/warden/LICENSE	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/LICENSE	2013-04-16 16:18:23 UTC (rev 22317)
@@ -1,4 +1,4 @@
-Copyright 2012 PC-BSD / iXsystems. All rights reserved.
+Copyright 2013 PC-BSD / iXsystems. All rights reserved.
 
 Redistribution and use in source and binary forms, with or without modification, are permitted provided 
 that the following conditions are met:

Modified: pcbsd/current/src-sh/warden/bin/warden
===================================================================
--- pcbsd/current/src-sh/warden/bin/warden	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/bin/warden	2013-04-16 16:18:23 UTC (rev 22317)
@@ -2,7 +2,7 @@
 # Command-line interaction script for the warden
 # Author: Kris Moore
 # License: BSD
-# "The Warden" Copyright 2008 PC-BSD Software (iXsystems)
+# "The Warden" Copyright 2013 PC-BSD Software (iXsystems)
 ######################################################################
 
 # Source external functions
@@ -43,7 +43,7 @@
    echo "   gui - Launch the GUI menu"
 fi
 
-echo "
+cat<<__EOF__
          auto - Toggles the autostart flag for a jail
       bspkgng - BootStrap pkgng and setup TrueOS repo
       checkup - Check for updates to a jail
@@ -56,10 +56,11 @@
        import - Imports a jail from a .wdn file
          list - Lists the installed jails
          pkgs - Lists the installed packages in a jail
+         pbis - Lists the installed pbi's in a jail
           set - Sets options for a jail
         start - Start a jail
          stop - Stops a jail
-         type - Set the jail type (portjail/normal)
+         type - Set the jail type (portjail|pluginjail|standard)
     zfsmksnap - Create a ZFS snapshot of a jail 
  zfslistclone - List clones of jail snapshots
   zfslistsnap - List snapshots of a jail
@@ -68,7 +69,7 @@
 zfsrevertsnap - Revert jail to a snapshot
    zfsrmclone - Remove a clone directory
     zfsrmsnap - Remove snapshot of a jail
-"
+__EOF__
 };
 
 help_get()
@@ -80,20 +81,29 @@
 
 Available options:
 
-     ip: Lets you see additional IP addresses for this jail
-  flags: Lets you see additional flags to pass to the 'jail' command at startup
+              ipv4: Lets you see the IPv4 address for this jail
+              ipv6: Lets you see the IPv6 address for this jail
+        alias-ipv4: Lets you see additional IPv4 addresses for this jail
+        alias-ipv6: Lets you see additional IPv6 addresses for this jail
+       bridge-ipv4: Lets you see the vnet bridge IPv4 address for this jail
+       bridge-ipv6: Lets you see the vnet bridge IPv6 address for this jail
+ alias-bridge-ipv4: Lets you see additional vnet bridge IPv4 addresses for this jail
+ alias-bridge-ipv6: Lets you see additional vnet bridge IPv6 addresses for this jail
+defaultrouter-ipv4: Lets you see the default IPv4 router for this jail
+defaultrouter-ipv6: Lets you see the default IPv6 router for this jail
+	     flags: Lets you see additional flags to pass to the 'jail' command at startup
 
 Usage:
 
-  warden get ip <Jail IP>
+  warden get ipv4 <Jail>
 
-  warden get flags <Jail IP>
+  warden get flags <Jail>
 
 Example:
 
-  warden get ip 192.168.0.5
+  warden get ipv4 myjail
 
-  warden get flags 192.168.0.5
+  warden get flags myjail
 "
 };
 
@@ -106,20 +116,31 @@
 
 Available options:
 
-     ip: Lets you set additional IP addresses for this jail
-  flags: Lets you set additional flags to pass to the 'jail' command at startup
+              ipv4: Lets you set the IPv4 address for this jail
+              ipv6: Lets you set the IPv6 address for this jail
+        alias-ipv4: Lets you set additional IPv4 addresses for this jail
+        alias-ipv6: Lets you set additional IPv6 addresses for this jail
+       bridge-ipv4: Lets you set the vnet bridge IPv4 address for this jail
+       bridge-ipv6: Lets you set the vnet bridge IPv6 address for this jail
+ alias-bridge-ipv4: Lets you set additional vnet bridge IPv4 addresses for this jail
+ alias-bridge-ipv6: Lets you set additional vnet bridge IPv6 addresses for this jail
+defaultrouter-ipv4: Lets you set the default IPv4 router for this jail
+defaultrouter-ipv6: Lets you set the default IPv6 router for this jail
+        flags: Lets you set additional flags to pass to the 'jail' command at startup
 
 Usage:
 
-  warden set ip <Jail IP> <IP1>,<IP2>,<IP3>
+  warden set ipv4 <Jail> <IP1>,<IP2>,<IP3>
 
-  warden set flags <Jail IP> <Flag1>,<Flag2>,<Flag3>
+  warden set flags <Jail> <Flag1>,<Flag2>,<Flag3>
 
 Example:
 
-  warden set ip 192.168.0.5 fe80::8e89:a5ff:fe52:ad19,192.168.1.50,192.168.2.10
+  warden set ipv4 myjail 192.168.1.50,192.168.2.10
 
-  warden set flags 192.168.0.5 allow.raw_sockets=true,allow.chflags=true
+  warden set ipv6 myjail fe80::8e89:a5ff:fe52:ad19,fe80::8e89:a5ff:fe52:ad21
+
+  warden set flags myjail allow.raw_sockets=true,allow.chflags=true
 "
 };
 
@@ -132,13 +153,13 @@
 
 Usage:
 
-  warden checkup <IP>
+  warden checkup <Jail>
    or
   warden checkup all
 
 Example:
 
-  warden checkup 192.168.0.5
+  warden checkup myjail
 "
 };
 
@@ -151,11 +172,11 @@
 
 Usage:
 
-  warden zfslistclone <IP>
+  warden zfslistclone <Jail>
 
 Example:
 
-  warden zfslistclone 192.168.0.5
+  warden zfslistclone myjail
 "
 };
 
@@ -168,11 +189,11 @@
 
 Usage:
 
-  warden zfslistsnap <IP>
+  warden zfslistsnap <Jail>
 
 Example:
 
-  warden zfslistsnap 192.168.0.5
+  warden zfslistsnap myjail
 "
 };
 
@@ -185,11 +206,11 @@
 
 Usage:
 
-  warden zfsclonesnap <IP> <SNAP>
+  warden zfsclonesnap <Jail> <SNAP>
 
 Example:
 
-  warden zfsclonesnap 192.168.0.5 20120505-140510
+  warden zfsclonesnap myjail 20120505-140510
 "
 };
 
@@ -202,7 +223,7 @@
 
 Usage:
 
-  warden zfscronsnap <IP> <action> <frequency> <daysToKeep>
+  warden zfscronsnap <Jail> <action> <frequency> <daysToKeep>
   
   action = start / stop
   frequency = daily / hourly
@@ -210,11 +231,11 @@
 
 Example:
 
-  warden zfscronsnap 192.168.0.5 start daily 10
+  warden zfscronsnap myjail start daily 10
 
   or
 
-  warden zfscronsnap 192.168.0.5 stop
+  warden zfscronsnap myjail stop
 "
 };
 
@@ -227,11 +248,11 @@
 
 Usage:
 
-  warden zfsrevertsnap <IP> <SNAP>
+  warden zfsrevertsnap <Jail> <SNAP>
 
 Example:
 
-  warden zfsrevertsnap 192.168.0.5 20120505-140510
+  warden zfsrevertsnap myjail 20120505-140510
 "
 };
 
@@ -244,11 +265,11 @@
 
 Usage:
 
-  warden zfsrmclone <IP> <CLONE>
+  warden zfsrmclone <Jail> <CLONE>
 
 Example:
 
-  warden zfsrmclone 192.168.0.5 20120505-140510
+  warden zfsrmclone myjail 20120505-140510
 "
 };
 
@@ -261,11 +282,11 @@
 
 Usage:
 
-  warden zfsrmsnap <IP> <SNAP>
+  warden zfsrmsnap <Jail> <SNAP>
 
 Example:
 
-  warden zfsrmsnap 192.168.0.5 20120505-140510
+  warden zfsrmsnap myjail 20120505-140510
 "
 };
 
@@ -279,11 +300,11 @@
 
 Usage:
 
-  warden zfsmksnap <IP>
+  warden zfsmksnap <Jail>
 
 Example:
 
-  warden zfsmksnap 192.168.0.5
+  warden zfsmksnap myjail
 "
 };
 
@@ -296,11 +317,11 @@
 
 Usage:
 
-  warden details <IP>
+  warden details <Jail>
 
 Example:
 
-  warden details 192.168.0.5
+  warden details myjail
 "
 };
 
@@ -313,38 +334,42 @@
 Lets you set the type of jail to these options:
 
 portjail: Jail with access to your home directories and Xorg
+pluginjail: Jail that can be used to install FreeNAS plugins
 standard: Normal FreeBSD secure jail environment
 
 The flag status can be checked with 'warden list'. 
 
 Usage:
 
-  warden type <IP> <type>
+  warden type <Jail> <type>
 
 Example:
 
-  warden type 192.168.0.5 portjail
+  warden type myjail portjail
 "
 };
 
+
 help_bspkgng()
 {
  title
  echo "Help bspkgng
 
 BootStraps the pkgng package system, and installs the TrueOS repository
-and utilities into a jail. 
+and utilities into a jail.
 
 Usage:
 
-  warden bspkgng <IP>
+  warden bspkgng <Jail>
 
 Example:
 
-  warden bspkgng 192.168.0.5
+  warden bspkgng myjail
 "
 };
 
+
+
 help_auto()
 {
  title
@@ -356,11 +381,11 @@
 
 Usage:
 
-  warden auto <IP>
+  warden auto <Jail>
 
 Example:
 
-  warden auto 192.168.0.5
+  warden auto myjail
 "
 };
 
@@ -373,14 +398,31 @@
 
 Usage:
 
-  warden pkgs
+  warden pkgs <Jail>
 
 Example:
 
-  warden pkgs 192.168.0.5
+  warden pkgs myjail
 "
 };
 
+help_pbis()
+{
+ title
+ echo "Help pbis
+
+Generates a listing of the installed pbi's in a jail.
+
+Usage:
+
+  warden pbis <Jail>
+
+Example:
+
+  warden pbis myjail
+"
+};
+
 help_list()
 {
  title
@@ -389,9 +431,12 @@
 Generates a quick listing of the installed jails, including the running
 status.
 
+Available Flags:
+  -v           (Verbose listing)
+
 Usage:
 
-  warden list
+  warden list [flags] [hosts]
 "
 };
 
@@ -411,11 +456,11 @@
 
 Usage:
 
-  warden export <IP> --dir=<path>
+  warden export <Jail> --dir=<path>
 
 Example:
 
-  warden export 192.168.0.5 --dir=/tmp
+  warden export myjail --dir=/tmp
 "
 };
 
@@ -428,8 +473,9 @@
 the imported jail on the fly using optional flags.  
 
 Available Flags:
-  --ip=<IP>      (Specify a new IP address to assign to this jail)
-  --host=<HOST>  (Specify a new host name to assign to this jail)
+  --ipv4=<IP/NETMASK> (Specify a new IPv4/NETMASK address to assign to this jail)
+  --ipv6=<IP/NETMASK> (Specify a new IPv6/NETMASK address to assign to this jail)
+  --host=<HOST>       (Specify a new host name to assign to this jail)
 
 Usage:
 
@@ -437,7 +483,7 @@
 
 Example:
 
-  warden import /home/kris/192.168.0.5.wdn
+  warden import /home/kris/myjail.wdn
 "
 };
 
@@ -452,11 +498,11 @@
 
 Usage:
 
-  warden chroot <IP> <optional cmd>
+  warden chroot <Jail> <optional cmd>
 
 Example:
 
-  warden chroot 192.168.0.5
+  warden chroot myjail
 "
 };
 
@@ -470,11 +516,11 @@
 
 Usage:
 
-  warden start <IP>
+  warden start <Jail>
 
 Example:
 
-  warden start 192.168.0.5
+  warden start myjail
 "
 };
 
@@ -486,11 +532,11 @@
 Stops a running jail
 
 Usage:
-  warden stop <IP>
+  warden stop <Jail>
 
 Example:
 
-  warden stop 192.168.0.5
+  warden stop myjail
 "
 };
 
@@ -507,11 +553,11 @@
 
 Usage:
 
-  warden delete <IP>
+  warden delete <Jail>
 
 Example:
 
-  warden delete 192.168.0.5 
+  warden delete myjail
 "
 };
 
@@ -525,23 +571,27 @@
 Creates a new jail, with options for system source, ports and autostarting.
 
 Available Flags:
-  -32       		       (Create 32bit jail on 64bit system)
-  --src       		       (Includes /usr/src system source)
-  --ports     		       (Includes the ports tree)
-  --vanilla    		       (Don't install PC-BSD pkgng repo and utilities)
-  --startauto 		       (Start this jail at system boot)
-  --portjail  		       (Make this a portjail)
+  -32                          (Create 32bit jail on 64bit system)
+  --ipv4 <ip/mask>             (Set primary IPv4 address for jail)
+  --ipv6 <ip/mask>             (Set primary IPv6 address for jail)
+  --src                        (Includes /usr/src system source)
+  --ports                      (Includes the ports tree)
+  --vanilla                    (Don't install PC-BSD pkgng repo and utilities)
+  --startauto                  (Start this jail at system boot)
+  --portjail                   (Make this a portjail)
+  --pluginjail                 (Make this a pluginjail)
   --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)
+  --version <string>           (Use this instead of /etc/version)
 
 Usage:
 
-  warden create <IP> <HOSTNAME> <flags>
+  warden create <JAILNAME> <flags>
 
 Example:
 
-  warden create 192.168.0.5 jailbird --src --ports --startauto
+  warden create jailbird --ipv4 192.168.0.25/24 --src --ports --startauto
 "
 };
 
@@ -566,6 +616,7 @@
            export) help_export ;;
            import) help_import ;;
            pkgs) help_pkgs ;;
+           pbis) help_pbis ;;
            type) help_type ;;
            get) help_get ;;
            set) help_set ;;
@@ -581,54 +632,117 @@
          esac  ;;
 
 
-    pkgs) IP="${2}"
-         if [ -z "${IP}" ]; then exit_err "No IP specified!"; fi
-         if [ ! -e "${JDIR}/${IP}" ]; then exit_err "No such jail!"; fi
+    pkgs) JAILNAME="${2}"
+         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
+         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
 	 set_warden_metadir
 
-         ${PROGDIR}/scripts/backend/listpkgs.sh "${IP}" 
+         ${PROGDIR}/scripts/backend/listpkgs.sh "${JAILNAME}" 
          ;;
-details) IP="${2}"
-         if [ -z "${IP}" ]; then exit_err "No IP specified!"; fi
-         if [ ! -e "${JDIR}/${IP}" ]; then exit_err "No such jail!"; fi
+details) JAILNAME="${2}"
+         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
+         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
 	 set_warden_metadir
 
-         ${PROGDIR}/scripts/backend/details.sh "${IP}" 
+         ${PROGDIR}/scripts/backend/details.sh "${JAILNAME}" 
          ;;
+    pbis) JAILNAME="${2}"
+         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
+         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
+	 set_warden_metadir
+
+         ${PROGDIR}/scripts/backend/listpbis.sh "${JAILNAME}" 
+         ;;
     get) require_root
 	 OPT="${2}"
-         IP="${3}"
-         if [ -z "${IP}" ] ; then exit_err "No IP specified!"; fi
-         if [ ! -e "${JDIR}/${IP}" ] ; then exit_err "No such jail!"; fi
+         JAILNAME="${3}"
+         if [ -z "${JAILNAME}" ] ; then exit_err "No jail specified!"; fi
+         if [ ! -e "${JDIR}/${JAILNAME}" ] ; then exit_err "No such jail!"; fi
 	 set_warden_metadir
 
 	 case $OPT in
-             ip) cat "${JMETADIR}/ip-extra"  2>/dev/null | sed 's| |,|g' ;;
-          flags) cat "${JMETADIR}/jail-flags" 2>/dev/null | sed 's| |,|g' ;;
+             flags) cat "${JMETADIR}/jail-flags" 2>/dev/null | sed 's| |,|g' ;;
+              ipv4) cat "${JMETADIR}/ipv4"  2>/dev/null | sed 's| |,|g' ;;
+              ipv6) cat "${JMETADIR}/ipv6"  2>/dev/null | sed 's| |,|g' ;;
+        alias-ipv4) cat "${JMETADIR}/alias-ipv4"  2>/dev/null | sed 's| |,|g' ;;
+        alias-ipv6) cat "${JMETADIR}/alias-ipv6"  2>/dev/null | sed 's| |,|g' ;;
+       bridge-ipv4) cat "${JMETADIR}/bridge-ipv4" 2>/dev/null | sed 's| |,|g' ;;
+       bridge-ipv6) cat "${JMETADIR}/bridge-ipv6" 2>/dev/null | sed 's| |,|g' ;;
+ alias-bridge-ipv4) cat "${JMETADIR}/alias-bridge-ipv4" 2>/dev/null | sed 's| |,|g' ;;
+ alias-bridge-ipv6) cat "${JMETADIR}/alias-bridge-ipv6" 2>/dev/null | sed 's| |,|g' ;;
+defaultrouter-ipv4) cat "${JMETADIR}/defaultrouter-ipv4" 2>/dev/null | sed 's| |,|g' ;;
+defaultrouter-ipv6) cat "${JMETADIR}/defaultrouter-ipv6" 2>/dev/null | sed 's| |,|g' ;;
               *) exit_err "Invalid option!" ;;
          esac
-                 
          ;;
 
     set) require_root
 	 OPT="${2}" 
-         IP="${3}"
-         if [ -z "${IP}" ] ; then exit_err "No IP specified!"; fi
-         if [ ! -e "${JDIR}/${IP}" ] ; then exit_err "No such jail!"; fi
+         JAILNAME="${3}"
+         if [ -z "${JAILNAME}" ] ; then exit_err "No jail specified!"; fi
+         if [ ! -e "${JDIR}/${JAILNAME}" ] ; then exit_err "No such jail!"; fi
 	 set_warden_metadir
 
 	 case $OPT in
-             ip) EXTRAIPS="${4}"
-
+             ipv4) IP4="${4}"
+		 get_ip_and_netmask "${IP4}"
+		 IP4="${JIP}"
+  		 MASK4="${JMASK}"
+  		 if [ -z "$MASK4" ] ; then MASK4="24"; fi
+	         echo "$IP4/$MASK4" > "${JMETADIR}/ipv4"
+                 ;;
+             ipv6) IP6="${4}"
+		 get_ip_and_netmask "${IP6}"
+		 IP6="${JIP}"
+  		 MASK6="${JMASK}"
+  		 if [ -z "$MASK6" ] ; then MASK4="64"; fi
+	         echo "$IP6/$MASK6" > "${JMETADIR}/ipv6"
+                 ;;
+       alias-ipv4) EXTRAIPS="${4}"
 	         IPS=`echo $EXTRAIPS | sed 's|,| |g'`
-	         rm "${JMETADIR}/ip-extra" >/dev/null 2>/dev/null
+	         rm "${JMETADIR}/alias-ipv4" >/dev/null 2>/dev/null
 	         for _ip in $IPS
 	         do
-	            echo "$_ip" >> "${JMETADIR}/ip-extra"
+	            echo "$_ip" >> "${JMETADIR}/alias-ipv4"
 	         done
                 ;;
+       alias-ipv6) EXTRAIPS="${4}"
+	         IPS=`echo $EXTRAIPS | sed 's|,| |g'`
+	         rm "${JMETADIR}/alias-ipv6" >/dev/null 2>/dev/null
+	         for _ip in $IPS
+	         do
+	            echo "$_ip" >> "${JMETADIR}/alias-ipv6"
+	         done
+                ;;
+       bridge-ipv4) BIP4="${4}"
+	         echo "$BIP4" > "${JMETADIR}/bridge-ipv4"
+                 ;;
+       bridge-ipv6) BIP6="${4}"
+	         echo "$BIP6" > "${JMETADIR}/bridge-ipv6"
+                 ;;
+ alias-bridge-ipv4) EXTRAIPS="${4}"
+	         IPS=`echo $EXTRAIPS | sed 's|,| |g'`
+	         rm "${JMETADIR}/alias-bridge-ipv4" >/dev/null 2>/dev/null
+	         for _ip in $IPS
+	         do
+	            echo "$_ip" >> "${JMETADIR}/alias-bridge-ipv4"
+	         done
+                ;;
+ alias-bridge-ipv6) EXTRAIPS="${4}"
+	         IPS=`echo $EXTRAIPS | sed 's|,| |g'`
+	         rm "${JMETADIR}/alias-bridge-ipv6" >/dev/null 2>/dev/null
+	         for _ip in $IPS
+	         do
+	            echo "$_ip" >> "${JMETADIR}/alias-bridge-ipv6"
+	         done
+                ;;
+defaultrouter-ipv4) DEFAULTROUTER="${4}"
+	         echo "$DEFAULTROUTER" > "${JMETADIR}/defaultrouter-ipv4"
+                 ;;
+defaultrouter-ipv6) DEFAULTROUTER="${4}"
+	         echo "$DEFAULTROUTER" > "${JMETADIR}/defaultrouter-ipv6"
+                 ;;
           flags) EXTRAFLAGS="${4}"
-
 	         echo $EXTRAFLAGS | sed 's|,| |g' > "${JMETADIR}/jail-flags"
                 ;;
               *) exit_err "Invalid option!" ;;
@@ -636,45 +750,54 @@
          ;;
 
    type) require_root
-	 IP="${2}"
+	 JAILNAME="${2}"
          TYPE="${3}"
+         JAILDIR="${JDIR}/${JAILNAME}"
 
-         if [ -z "${IP}" ] ; then exit_err "No IP specified!"; fi
-         if [ ! -e "${JDIR}/${IP}" ] ; then exit_err "No such jail!"; fi
+         if [ -z "${JAILNAME}" ] ; then exit_err "No jail specified!"; fi
+         if [ ! -e "${JAILDIR}" ] ; then exit_err "No such jail!"; fi
 
 	 set_warden_metadir
 	 if [ -e "${JMETADIR}/jail-linux" ] ; then exit_err "Cannot change type on Linux jail!"; fi
 
 	 case $TYPE in
-	   portjail) mkportjail "${JDIR}/${IP}" ;;
-	   standard) rm ${JMETADIR}/jail-portjail >/dev/null 2>/dev/null ;;
+	   portjail)
+              rm ${JMETADIR}/jail-pluginjail > /dev/null 2>/dev/null
+              mkportjail "${JAILDIR}"
+              ;;
+	   standard)
+              rm ${JMETADIR}/jail-pluginjail > /dev/null 2>/dev/null
+              rm ${JMETADIR}/jail-portjail >/dev/null 2>/dev/null
+              ;;
+	   pluginjail)
+              mkpluginjail "${JAILDIR}"
+              ;;
 	   *) exit_err "Invalid TYPE" ;;
          esac
          ;;
+
  bspkgng) require_root
-	 IP="${2}"
-
-         if [ -z "${IP}" ]; then exit_err "No IP specified!"; fi
-         if [ ! -e "${JDIR}/${IP}" ]; then exit_err "No such jail!"; fi
-         bootstrap_pkgng "${JDIR}/$IP"
+    JAILNAME="${2}"
+         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
+         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
+         bootstrap_pkgng "${JDIR}/${JAILNAME}"
          ;;
 
    auto) require_root
-	 IP="${2}"
+	 JAILNAME="${2}"
 
-         if [ -z "${IP}" ]; then exit_err "No IP specified!"; fi
+         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
 
-         if [ ! -e "${JDIR}/${IP}" ]; then exit_err "No such jail!"; fi
+         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
 	 set_warden_metadir
 
-
          if [ -e "${JMETADIR}/autostart" ]
          then
             rm "${JMETADIR}/autostart"
-            echo "Disabled autostart for ${IP}"
+            echo "Disabled autostart for ${JAILNAME}"
          else
             touch "${JMETADIR}/autostart"
-            echo "Enabled autostart for ${IP}"
+            echo "Enabled autostart for ${JAILNAME}"
          fi 
 
          ;;
@@ -682,51 +805,53 @@
     gui) require_root
 	  ${PROGDIR}/bin/warden-gui ;;
 
-    list) ${PROGDIR}/scripts/backend/listjails.sh ;;
+    list) require_root
+	shift
+        ${PROGDIR}/scripts/backend/listjails.sh $* ;;
     
    start) require_root
 	  # Time to startup the jail
-          IP="${2}"
+          JAILNAME="${2}"
 
-          if [ -z "${IP}" ]; then exit_err "No IP specified!"; fi
-          if [ ! -e "${JDIR}/${IP}" ]; then exit_err "No such jail!"; fi 
+          if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
+          if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi 
 	  set_warden_metadir
          
           # Check if this jail is already running
-          ${PROGDIR}/scripts/backend/checkstatus.sh "${IP}"
+          ${PROGDIR}/scripts/backend/checkstatus.sh "${JAILNAME}"
           if [ "$?" = "0" ]; then exit_err "This jail is already running!"; fi
  
-          ${PROGDIR}/scripts/backend/startjail.sh "${IP}" 
+          ${PROGDIR}/scripts/backend/startjail.sh "${JAILNAME}" 
           ;;
    stop)  require_root
           # Time to stop the jail
-          IP="${2}"
+          JAILNAME="${2}"
 
-          if [ -z "${IP}" ]; then exit_err "No IP specified!"; fi
-          if [ ! -e "${JDIR}/${IP}" ]; then exit_err "No such jail!"; fi 
+          if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
+          if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi 
 	  set_warden_metadir
          
-          ${PROGDIR}/scripts/backend/stopjail.sh "${IP}" 
+          ${PROGDIR}/scripts/backend/stopjail.sh "${JAILNAME}" 
           ;;
 
  checkup) # Log a user into chroot session
-          IP="${2}"
+          JAILNAME="${2}"
 
-          if [ -z "${IP}" ]; then exit_err "No IP specified!"; fi
-          if [ ! -e "${JDIR}/${IP}" -a "$IP" != "all" ]; then exit_err "No such jail!"; fi
+          if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
+          if [ ! -e "${JDIR}/${JAILNAME}" -a "${JAILNAME}" != "all" ]; then exit_err "No such jail!"; fi
 
-          ${PROGDIR}/scripts/backend/checkupdates.sh "${IP}"
+          ${PROGDIR}/scripts/backend/checkupdates.sh "${JAILNAME}"
           ;;
 
 
  chroot) # Log a user into chroot session
-          IP="${2}"
+          JAILNAME="${2}"
 
-          if [ -z "${IP}" ]; then exit_err "No IP specified!"; fi
-          if [ ! -e "${JDIR}/${IP}" ]; then exit_err "No such jail!"; fi
+          if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
+          if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
 	  set_warden_metadir
 
-          ${PROGDIR}/scripts/backend/chrootjail.sh "${IP}" "${3}"
+          ${PROGDIR}/scripts/backend/chrootjail.sh "${JAILNAME}" "${3}"
           ;;
 
  import) require_root
@@ -734,23 +859,56 @@
          IFILE="$2"
          if [ ! -e "$IFILE" ]; then exit_err "Invalid filename: ${IFILE}"; fi
 
-         IP="OFF"
+         HOST=`basename "${IFILE}" | sed 's|\.wdn$||'`
+
+         IP4="OFF"
+         IP6="OFF"
          HOST="OFF"
          for i in "$@"
          do
-           # Check if we have a new IP for this import
-           echo "${i}" | grep '\-\-ip=' >/dev/null 2>/dev/null
+           # Check if we have a new IPv4 address for this import
+           echo "${i}" | grep '\-\-ipv4=' >/dev/null 2>/dev/null
            if [ "$?" = "0" ]
            then
-              IP="`echo ${i} | cut -d '=' -f 2`"
+              tmp="`echo ${i} | cut -d '=' -f 2`"
+              IP4="`echo ${tmp} | cut -d '/' -f 1 -s`"
+              MASK4="`echo ${tmp} | cut -d '/' -f 2 -s`"
 
               #Sanity check on the IP
-              check_ip ${IP}
-              if [ "$?" != "0" ]; then exit_err "Invalid IP address!"; fi
+              if ! is_ipv4 "${IP4}" ; then
+                 exit_err "Invalid IPv4 address!"
+              fi
 
-              # Check if the directory already exists
-              if [ -e "${JDIR}/${IP}" ]; then exit_err "A jail with this IP already exists!"; fi
+              for i in `ls -d ${JDIR}/.*.meta 2>/dev/null`
+              do
+                if [ "`cat ${i}/ipv4 2>/dev/null`" = "${IP4}/${MASK4}" ] ; then
+                  exit_err "A jail with this IPv4 address already exists!"
+                fi 
+              done 
+           fi
 
+           # Check if we have a new IPv4 address for this import
+           echo "${i}" | grep '\-\-ipv6=' >/dev/null 2>/dev/null
+           if [ "$?" = "0" ]
+           then
+              tmp="`echo ${i} | cut -d '=' -f 2`"
+              IP6="`echo ${tmp} | cut -d '/' -f 1 -s`"
+              MASK6="`echo ${tmp} | cut -d '/' -f 2 -s`"
+
+              #Sanity check on the IP
+              if ! is_ipv6 "${IP6}" ; then
+                 exit_err "Invalid IPv6 address!"
+              fi
+
+              for i in `ls -d ${JDIR}/.*.meta 2>/dev/null`
+              do
+                _ipv6=`cat ${i}/ipv6 2>/dev/null | tr a-z A-Z`
+                _nipv6="`echo ${IP6}|tr a-z A-Z`/${MASK6}"
+                
+                if [ "${_ipv6}" = "${_nipv6}" ] ; then
+                  exit_err "A jail with this IPv6 address already exists!"
+                fi 
+              done 
            fi
   
            # Check if we have a new hostname for this jail
@@ -762,15 +920,22 @@
 
          done
 
-          # Import the jail now!
-          ${PROGDIR}/scripts/backend/importjail.sh "${IFILE}" "${IP}" "${HOST}"
+         if [ "${IP4}" != "OFF" ] ; then
+            IP4="${IP4}/${MASK4}"
+         fi
+         if [ "${IP6}" != "OFF" ] ; then
+            IP6="${IP6}/${MASK6}"
+         fi
+
+         # Import the jail now!
+         ${PROGDIR}/scripts/backend/importjail.sh "${IFILE}" "${HOST}" "${IP4}" "${IP6}"
         ;;
 
  export) require_root
          # The user wants to export a jail, lets do it!
-         IP="$2"
-         if [ -z "$IP" ]; then exit_err "No IP specified!"; fi
-         if [ ! -e "${JDIR}/${IP}" ]; then exit_err "No such jail!"; fi
+         JAILNAME="$2"
+         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
+         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
 	 set_warden_metadir
 
          # Check if the user wants to place the file in their own DIR
@@ -788,105 +953,114 @@
          done
 
          # Export the jail now
-         ${PROGDIR}/scripts/backend/exportjail.sh "${IP}" "${DIR}"
+         ${PROGDIR}/scripts/backend/exportjail.sh "${JAILNAME}" "${DIR}"
 
          ;;
 
  zfsmksnap) require_root
-         IP="$2"
-         if [ -z "$IP" ]; then exit_err "No IP specified!"; fi
-         if [ ! -e "${JDIR}/${IP}" ]; then exit_err "No such jail!"; fi
+         JAILNAME="$2"
+         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
+         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
 	 set_warden_metadir
-         ${PROGDIR}/scripts/backend/zfsmksnap.sh "${IP}"
+         ${PROGDIR}/scripts/backend/zfsmksnap.sh "${JAILNAME}"
          ;;
 
  zfslistclone) require_root
-         IP="$2"
-         if [ -z "$IP" ]; then exit_err "No IP specified!"; fi
-         if [ ! -e "${JDIR}/${IP}" ]; then exit_err "No such jail!"; fi
+         JAILNAME="$2"
+         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
+         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
 	 set_warden_metadir
-         ${PROGDIR}/scripts/backend/zfslistclone.sh "${IP}"
+         ${PROGDIR}/scripts/backend/zfslistclone.sh "${JAILNAME}"
          ;;
 
  zfslistsnap) require_root
-         IP="$2"
-         if [ -z "$IP" ]; then exit_err "No IP specified!"; fi
-         if [ ! -e "${JDIR}/${IP}" ]; then exit_err "No such jail!"; fi
+         JAILNAME="$2"
+         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
+         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
 	 set_warden_metadir
-         ${PROGDIR}/scripts/backend/zfslistsnap.sh "${IP}"
+         ${PROGDIR}/scripts/backend/zfslistsnap.sh "${JAILNAME}"
          ;;
 
  zfsclonesnap) require_root
-         IP="$2"
+         JAILNAME="$2"
          SNAP="$3"
-         if [ -z "$IP" ]; then exit_err "No IP specified!"; fi
-         if [ ! -e "${JDIR}/${IP}" ]; then exit_err "No such jail!"; fi
+         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
+         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
 	 set_warden_metadir
-         ${PROGDIR}/scripts/backend/zfsclonesnap.sh "${IP}" "$SNAP"
+         ${PROGDIR}/scripts/backend/zfsclonesnap.sh "${JAILNAME}" "${SNAP}"
          ;;
 
  zfscronsnap) require_root
-         IP="$2"
-         if [ -z "$IP" ]; then exit_err "No IP specified!"; fi
-         if [ ! -e "${JDIR}/${IP}" ]; then exit_err "No such jail!"; fi
+         JAILNAME="$2"
+         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
+         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
 	 set_warden_metadir
-         ${PROGDIR}/scripts/backend/zfscronsnap.sh "${IP}" "$3" "$4" "$5"
+         ${PROGDIR}/scripts/backend/zfscronsnap.sh "${JAILNAME}" "$3" "$4" "$5"
          ;;
 
 
  zfsrevertsnap) require_root
-         IP="$2"
+         JAILNAME="$2"
          SNAP="$3"
-         if [ -z "$IP" ]; then exit_err "No IP specified!"; fi
-         if [ ! -e "${JDIR}/${IP}" ]; then exit_err "No such jail!"; fi
+         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
+         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
 	 set_warden_metadir
-         ${PROGDIR}/scripts/backend/zfsrevertsnap.sh "${IP}" "$SNAP"
+         ${PROGDIR}/scripts/backend/zfsrevertsnap.sh "${JAILNAME}" "$SNAP"
          ;;
 
  zfsrmclone) require_root
-         IP="$2"
+         JAILNAME="$2"
          CLONE="$3"
-         if [ -z "$IP" ]; then exit_err "No IP specified!"; fi
-
-         if [ ! -e "${JDIR}/${IP}" ]; then exit_err "No such jail!"; fi
+         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
+         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
 	 set_warden_metadir
-         ${PROGDIR}/scripts/backend/zfsrmclone.sh "${IP}" "$CLONE"
+         ${PROGDIR}/scripts/backend/zfsrmclone.sh "${JAILNAME}" "${CLONE}"
          ;;
 
  zfsrmsnap) require_root
-         IP="$2"
+         JAILNAME="$2"
          SNAP="$3"
-         if [ -z "$IP" ]; then exit_err "No IP specified!"; fi
-
-         if [ ! -e "${JDIR}/${IP}" ]; then exit_err "No such jail!"; fi
+         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
+         if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
 	 set_warden_metadir
-         ${PROGDIR}/scripts/backend/zfsrmsnap.sh "${IP}" "$SNAP"
+         ${PROGDIR}/scripts/backend/zfsrmsnap.sh "${JAILNAME}" "${SNAP}"
          ;;
 
  create) require_root
          # The user wants to create a new jail, do error checking
-         IP="$2"
-         HOST="$3"
-         if [ -z "$IP" -o -z "$HOST" ]; then exit_err "No IP / Host specified!"; fi
+         JAILNAME="$2"
+         if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
 
-         #Sanity check on the IP
-         check_ip ${IP}
-         if [ "$?" != "0" ]; then exit_err "Invalid IP address!"; fi
+         HOST="$2"
 
          #Now check for the presence of the optional flags
+         IP4="OFF"
+         IP6="OFF"
          SRC="NO"
          PORTS="NO"
-         AUTO="NO"
-         PORTJAIL="NO"
-         LINUXJAIL="NO"
+         AUTOSTART="NO"
+         VANILLA="NO"
+         VERSION=
+         JAILTYPE="standard"
+         ARCHIVE_FILE= 
          while [ $# -gt 0 ]; do
            case $1 in
+             --ipv4) shift
+			  if [ -z "$1" ] ; then exit_err "No IPv4 address specified!"; fi
+                          IP4="${1}"
+                          ;;
+             --ipv6) shift
+			  if [ -z "$1" ] ; then exit_err "No IPv6 address specified!"; fi
+                          IP6="${1}"
+                          ;;
+
              --src) SRC="YES" ;;
              --ports) PORTS="YES" ;;
-             --startauto) AUTO="YES" ;;
-              --portjail) PORTJAIL="YES" ;;
-               --vanilla) VANILLA="YES" ;;
-             --linuxjail) LINUXJAIL="YES" ; shift
+             --startauto) AUTOSTART="YES" ;;
+             --vanilla) VANILLA="YES" ;;
+             --portjail) JAILTYPE="portjail" ;;
+             --pluginjail) JAILTYPE="pluginjail" ; VANILLA="YES" ;; 
+             --linuxjail) JAILTYPE="linuxjail" ; 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 
@@ -906,7 +1080,7 @@
 			     exit_err "No such file: $ARCHIVE_FILE"
 			  fi
 			  ;;
-             --linuxarchive) LINUXJAIL="YES" ; shift
+             --linuxarchive) JAILTYPE="linuxjail" ; shift
 			  if [ -z "$1" ] ; then exit_err "No archive file specified!"; fi
 			  LINUXARCHIVE_FILE="$1" ; export LINUXARCHIVE_FILE
 			  if [ ! -e "$LINUXARCHIVE_FILE" ] ; then
@@ -916,49 +1090,65 @@
 			     exit_err "--linuxjail and --linuxarchive are mutually exclusive!"
 			  fi
 			  ;;
+             --version) shift
+			  if [ -z "$1" ] ; then exit_err "No version string specified!"; fi
+                          VERSION="${1}"
+                          ;;
            esac
            shift
          done
 
          # Check to ensure this jail does not already exist
-         if [ -e "${JDIR}/${IP}" ]; then exit_err "A jail with this IP already exists!"; fi  
+         if [ -e "${JDIR}/${JAILNAME}" ]; then exit_err "A jail with this name already exists!"; fi  
 
+          #
+          # Redonkulous number of parameters that exceeds 9,
+          # export into environment
+          #
+          export IP4
+          export IP6
+          export SRC
+          export PORTS
+          export AUTOSTART
+          export JAILTYPE
+          export ARCHIVE_FILE
+          export VERSION
+          export VANILLA
+
           # Passed all tests, create the jail now
-          ${PROGDIR}/scripts/backend/createjail.sh "${IP}" "${HOST}" "${SRC}" "${PORTS}" "${AUTO}" "${PORTJAIL}" "${LINUXJAIL}" "${ARCHIVE_FILE}" "$VANILLA"
+          ${PROGDIR}/scripts/backend/createjail.sh "${JAILNAME}"
 
         ;;
   delete) require_root
           # Time to delete a jail
-          IP="${2}"
+          JAILNAME="${2}"
 
-          if [ -z "${IP}" ]; then exit_err "No IP specified!"; fi
-          if [ ! -e "${JDIR}/${IP}" ]; then exit_err "No such jail!"; fi
+          if [ -z "${JAILNAME}" ]; then exit_err "No jail specified!"; fi
+          if [ ! -e "${JDIR}/${JAILNAME}" ]; then exit_err "No such jail!"; fi
 	  set_warden_metadir
 
           if [ "$3" != "--confirm" ]
           then
-            echo "Are you sure you want to delete ${IP}?"
+            echo "Are you sure you want to delete ${JAILNAME}?"
             echo -e "Choice: (y/n)\c"
             read confirm
             if [ "$confirm" != "y" ]; then exit_err "Canceled!"; fi
           fi
 
           # Check if this jail is running
-          ${PROGDIR}/scripts/backend/checkstatus.sh "${IP}"
+          ${PROGDIR}/scripts/backend/checkstatus.sh "${JAILNAME}"
           if [ "$?" = "0" ] ; then
-            ${PROGDIR}/scripts/backend/stopjail.sh "${IP}"
+            ${PROGDIR}/scripts/backend/stopjail.sh "${JAILNAME}"
           fi
 
           # Check if this jail is STILL running
-          ${PROGDIR}/scripts/backend/checkstatus.sh "${IP}"
+          ${PROGDIR}/scripts/backend/checkstatus.sh "${JAILNAME}"
           if [ "$?" = "0" ] ; then exit_err "Jail still is running or has leftovers.."; fi
 
           # Delete it now
-          ${PROGDIR}/scripts/backend/deletejail.sh "${IP}"
+          ${PROGDIR}/scripts/backend/deletejail.sh "${JAILNAME}"
         ;;
    *) help_main ;;
 esac
 
 exit 0
-
-

Modified: pcbsd/current/src-sh/warden/conf/warden.conf
===================================================================
--- pcbsd/current/src-sh/warden/conf/warden.conf	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/conf/warden.conf	2013-04-16 16:18:23 UTC (rev 22317)
@@ -10,3 +10,6 @@
 
 # Location of the jails
 JDIR: /usr/jails
+
+# FreeBSD release to use
+FREEBSD_RELEASE: 9.1-RELEASE

Modified: pcbsd/current/src-sh/warden/scripts/backend/checkstatus.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/checkstatus.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/checkstatus.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -1,6 +1,6 @@
 #!/bin/sh
 # Script to check a jail status
-# Args $1 = IP
+# Args $1 = JAILNAME
 ######################################################################
 
 # Source our functions
@@ -9,11 +9,11 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-IP="$1"
+JAILNAME="$1"
 
-if [ -z "$IP" ]
+if [ -z "${JAILNAME}" ]
 then
-  echo "ERROR: You must specify an IP to check"
+  echo "ERROR: You must specify a jail name to check"
   exit 5
 fi
 
@@ -23,9 +23,11 @@
   exit 5
 fi
 
-if [ ! -d "${JDIR}/${IP}" ]
+JAILDIR="${JDIR}/${JAILNAME}"
+
+if [ ! -d "${JAILDIR}" ]
 then
-  echo "ERROR: No jail located at $JDIR/$IP"
+  echo "ERROR: No jail located at ${JAILDIR}"
   exit 5
 fi
 
@@ -34,17 +36,14 @@
 
 # Check if anything is still mounted in this jail
 hasmount="0"
-for mountpoint in $(mount | grep -e '${JDIR}/${IP}/' | cut -d" " -f3); do
+for mountpoint in $(mount | grep -e '${JAILDIR}/' | cut -d" " -f3); do
   hasmount="1"
 done
 
 # Check if the jail is active
-jls | grep ${JDIR}/${IP}$ >/dev/null 2>/dev/null
+jls | grep ${JAILNAME}$ >/dev/null 2>/dev/null
 if [ "$?" = "0" -o "$hasmount" = "1" ]; then
   exit 0
 else
   exit 1
 fi
-
-
-

Modified: pcbsd/current/src-sh/warden/scripts/backend/checkupdates.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/checkupdates.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/checkupdates.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -1,6 +1,6 @@
 #!/bin/sh
 # Script to check for jail updates
-# Args $1 = IP
+# Args $1 = JAILNAME
 ######################################################################
 
 # Source our functions
@@ -9,11 +9,11 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-IP="$1"
+JAILNAME="$1"
 
-if [ -z "$IP" ]
+if [ -z "${JAILNAME}" ]
 then
-  echo "ERROR: You must specify an IP to check"
+  echo "ERROR: You must specify a jail to check"
   exit 5
 fi
 
@@ -23,9 +23,11 @@
   exit 5
 fi
 
-if [ ! -d "${JDIR}/${IP}" -a "${IP}" != "all" ]
+JAILDIR="${JDIR}/${JAILNAME}"
+
+if [ ! -d "${JAILDIR}" -a "${JAILNAME}" != "all" ]
 then
-  echo "ERROR: No jail located at $JDIR/$IP"
+  echo "ERROR: No jail located at ${JAILDIR}"
   exit 5
 fi
 
@@ -34,23 +36,25 @@
 #####################################################################
 
 # Check for updates
-if [ "$IP" = "all" ] ; then
+if [ "${JAILNAME}" = "all" ] ; then
   cd ${JDIR}
   for i in `ls -d .*.meta`
   do
-    if [ ! -e "${i}/ip" ] ; then continue ; fi
-    IP="`cat ${i}/ip`"
+    JAILNAME=`echo ${i}|sed 's|.meta$||'|sed 's|^.||'`
+    HOST="`cat ${i}/host`"
     set_warden_metadir
     if [ -e "${JMETADIR}/jail-linux" ] ; then continue; fi
 
-    echo "Checking for jail updates to ${IP}"
+    echo "Checking for jail updates to ${HOST}"
     echo "################################################"
  
-    # Check for meta-pkg updates
-    pc-metapkgmanager --chroot ${JDIR}/${IP} checkup
+    # Check for pkgng updates
+    if [ -e "${JDIR}/${JAILNAME}/usr/local/sbin/pkg-static" ] ; then
+       chroot "${JDIR}/${JAILNAME}" pkg upgrade -n
+    fi
 
     # Check for system-updates
-    chroot ${JDIR}/${IP} cat /usr/sbin/freebsd-update | sed 's|! -t 0|-z '1'|g' | /bin/sh -s 'fetch'
+    chroot ${JDIR}/${JAILNAME} cat /usr/sbin/freebsd-update | sed 's|! -t 0|-z '1'|g' | /bin/sh -s 'fetch'
   done
 else
   set_warden_metadir
@@ -60,11 +64,14 @@
     exit 5
   fi
 
-   echo "Checking for jail updates to ${IP}..."
+   echo "Checking for jail updates to ${JAILNAME}..."
    echo "################################################"
-   # Check for meta-pkg updates
-   pc-metapkgmanager --chroot ${JDIR}/${IP} checkup
 
+   # Check for pkgng updates
+   if [ -e "${JDIR}/${JAILNAME}/usr/local/sbin/pkg-static" ] ; then
+      chroot "${JDIR}/${JAILNAME}" pkg upgrade -n
+   fi
+
    # Check for system-updates
-   chroot ${JDIR}/${IP} cat /usr/sbin/freebsd-update | sed 's|! -t 0|-z '1'|g' | /bin/sh -s 'fetch'
+   chroot ${JDIR}/${JAILNAME} cat /usr/sbin/freebsd-update | sed 's|! -t 0|-z '1'|g' | /bin/sh -s 'fetch'
 fi

Modified: pcbsd/current/src-sh/warden/scripts/backend/chrootjail.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/chrootjail.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/chrootjail.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -1,6 +1,6 @@
 #!/bin/sh
 # Chroot into a working jail
-# IP = $1
+# JAILNAME = $1
 ######################################################################
 
 # Source our functions
@@ -9,9 +9,9 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-IP="$1"
+JAILNAME="$1"
 
-if [ -z "${IP}" ]
+if [ -z "${JAILNAME}" ]
 then
   echo "ERROR: No jail specified to chroot into!"
   exit 5
@@ -23,16 +23,18 @@
   exit 5
 fi
 
-if [ ! -d "${JDIR}/${IP}" ]
+JAILDIR="${JDIR}/${JAILNAME}"
+
+if [ ! -d "${JAILDIR}" ]
 then
-  echo "ERROR: No jail located at $JDIR/$IP"
+  echo "ERROR: No jail located at ${JAILDIR}"
   exit 5
 fi
 
 set_warden_metadir
 
 # Make sure the jail is running
-jls | grep ${JDIR}/${IP}$ >/dev/null 2>/dev/null
+jls | grep ${JAILDIR}$ >/dev/null 2>/dev/null
 if [ "$?" != "0" ]
 then
   echo "ERROR: Jail is not running!"
@@ -40,7 +42,7 @@
 fi
 
 # Get the JailID for this jail
-JID="`jls | grep ${JDIR}/${IP}$ | tr -s " " | cut -d " " -f 2`"
+JID="`jls | grep ${JAILDIR}$ | tr -s " " | cut -d " " -f 2`"
 
 # If on an portjail, make display available
 if [ -e "${JMETADIR}/jail-portjail" ] ; then
@@ -57,7 +59,7 @@
 ###################################################################
 
 if [ -z "$2" ] ; then
-  echo "Started shell session on ${IP}. Type exit when finished."
+  echo "Started shell session on ${JAILNAME}. Type exit when finished."
   if [ -e "${JMETADIR}/jail-linux" ] ; then
     jailme ${JID} /bin/bash
   else

Modified: pcbsd/current/src-sh/warden/scripts/backend/createjail.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/createjail.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/createjail.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -8,49 +8,52 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-# Location of the chroot environment
-WORLDCHROOT="${JDIR}/.warden-chroot-${ARCH}"
-export WORLDCHROOT
-
 setup_linux_jail()
 {
   echo "Setting up linux jail..."
 
   mkdir -p ${JMETADIR}
   echo "${HOST}" > ${JMETADIR}/host
-  echo "${IP}" > ${JMETADIR}/ip
-  if [ "$STARTUP" = "YES" ] ; then
+
+  if [ "${IP4}" != "OFF" ] ; then
+    echo "${IP4}/${MASK4}" > ${JMETADIR}/ipv4
+  fi
+  if [ "${IP6}" != "OFF" ] ; then
+    echo "${IP6}/${MASK6}" > ${JMETADIR}/ipv6
+  fi
+
+  if [ "$AUTOSTART" = "YES" ] ; then
     touch "${JMETADIR}/autostart"
   fi
   touch "${JMETADIR}/jail-linux"
 
   if [ -n "$LINUXARCHIVE_FILE" ] ; then
     echo "Extracting ${LINUXARCHIVE_FILE}..."
-    tar xvf ${LINUXARCHIVE_FILE} -C "${JDIR}/${IP}" 2>/dev/null
+    tar xvf ${LINUXARCHIVE_FILE} -C "${JAILDIR}" 2>/dev/null
     if [ $? -ne 0 ] ; then
        echo "Failed Extracting ${LINUXARCHIVE_FILE}"
-       warden delete --confirm ${IP} 2>/dev/null
+       warden delete --confirm ${JAILNAME} 2>/dev/null
        exit 1
     fi
   else
-    sh ${LINUX_JAIL_SCRIPT} "${JDIR}/${IP}" "${IP}" "${JMETADIR}"
+    sh ${LINUX_JAIL_SCRIPT} "${JAILDIR}" "${IP}" "${JMETADIR}"
     if [ $? -ne 0 ] ; then
        echo "Failed running ${LINUX_JAIL_SCRIPT}"
-       warden delete --confirm ${IP} 2>/dev/null
+       warden delete --confirm ${JAILNAME} 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 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/
-  rm ${JDIR}/${IP}/tmp/passwd
+  echo "root::0:0::0:0:Charlie &:/root:/bin/bash" > ${JAILDIR}/etc/master.passwd
+  pwd_mkdb -d ${JAILDIR}/tmp -p ${JAILDIR}/etc/master.passwd 2>/dev/null
+  mv ${JAILDIR}/tmp/master.passwd ${JAILDIR}/etc/
+  mv ${JAILDIR}/tmp/pwd.db ${JAILDIR}/etc/
+  mv ${JAILDIR}/tmp/spwd.db ${JAILDIR}/etc/
+  rm ${JAILDIR}/tmp/passwd
 
   # Copy resolv.conf
-  cp /etc/resolv.conf ${JDIR}/${IP}/etc/resolv.conf
+  cp /etc/resolv.conf ${JAILDIR}/etc/resolv.conf
 
   # Do some touch-up to make linux happy
   echo '#!/bin/bash
@@ -59,41 +62,71 @@
 grpconv
 touch /etc/fstab
 touch /etc/mtab
-' > ${JDIR}/${IP}/.fixSH
-  chmod 755 ${JDIR}/${IP}/.fixSH
-  chroot ${JDIR}/${IP} /.fixSH
-  rm ${JDIR}/${IP}/.fixSH
+' > ${JAILDIR}/.fixSH
+  chmod 755 ${JAILDIR}/.fixSH
+  chroot ${JAILDIR} /.fixSH
+  rm ${JAILDIR}/.fixSH
 
   # If we are auto-starting the jail, do it now
-  if [ "$STARTUP" = "YES" ] ; then warden start ${IP} ; fi
+  if [ "$AUTOSTART" = "YES" ] ; then warden start ${JAILNAME} ; fi
 
-  echo "Success! Linux jail created at ${JDIR}/${IP}"
+  echo "Success! Linux jail created at ${JAILDIR}"
 }
 
 # Load our passed values
-IP="${1}"
-HOST="${2}"
-SOURCE="${3}"
-PORTS="${4}"
-STARTUP="${5}"
-PORTJAIL="${6}"
-LINUXJAIL="${7}"
-ARCHIVEFILE="${8}"
-VANILLA="${9}"
+JAILNAME="${1}"
+HOST="${1}"
 
+# Everything else is passed via environmental variables
+
+case "${JAILTYPE}" in
+  portjail) PORTJAIL="YES" ;;
+  pluginjail) PLUGINJAIL="YES" ;;
+  linuxjail) LINUXJAIL="YES" ;;
+  standard) ;;
+esac
+
+# Location of the chroot environment
+isDirZFS "${JDIR}"
+if [ $? -eq 0 ] ; then
+  WORLDCHROOT_PLUGINJAIL="${JDIR}/.warden-pj-chroot-${ARCH}"
+  WORLDCHROOT_STANDARD="${JDIR}/.warden-chroot-${ARCH}"
+else
+  WORLDCHROOT_PLUGINJAIL="${JDIR}/.warden-pj-chroot-${ARCH}.tbz"
+  WORLDCHROOT_STANDARD="${JDIR}/.warden-chroot-${ARCH}.tbz"
+fi
+if [ "${PLUGINJAIL}" = "YES" ] ; then
+  WORLDCHROOT="${WORLDCHROOT_PLUGINJAIL}"
+else
+  WORLDCHROOT="${WORLDCHROOT_STANDARD}"
+fi
+export WORLDCHROOT WORLDCHROOT_PLUGINJAIL WORLDCHROOT_STANDARD
+
+if [ "${IP4}" != "OFF" ] ; then
+  get_ip_and_netmask "${IP4}"
+  IP4="${JIP}"
+  MASK4="${JMASK}"
+  if [ -z "$MASK4" ] ; then MASK4="24"; fi
+fi
+
+if [ "${IP6}" != "OFF" ] ; then
+  get_ip_and_netmask "${IP6}"
+  IP6="${JIP}"
+  MASK6="${JMASK}"
+  if [ -z "$MASK6" ] ; then MASK6="64"; fi
+fi
+
 # See if we are overriding the default archive file
 if [ ! -z "$ARCHIVEFILE" ] ; then
    WORLDCHROOT="$ARCHIVEFILE"
-   export WORLDCHROOT
 fi
 
-if [ -z "$IP" -o -z "${HOST}" -o -z "$SOURCE" -o -z "${PORTS}" -o -z "${STARTUP}" ] 
-then
-  echo "ERROR: Missing required data!"
-  exit 6
+if [ -z "$HOST" ] ; then
+   echo "ERROR: Missing hostname!"
+   exit 6
 fi
 
-JAILDIR="${JDIR}/${IP}"
+JAILDIR="${JDIR}/${JAILNAME}"
 set_warden_metadir
 
 if [ -e "${JAILDIR}" ]
@@ -112,20 +145,69 @@
   fi
 done
 
+# Get next unique ID
+META_ID=0
+for i in `ls -d ${JDIR}/.*.meta 2>/dev/null`
+do
+  id=`cat ${i}/id`
+  if [ "${id}" -gt "${META_ID}" ] ; then
+    META_ID="${id}"
+  fi
+done
+: $(( META_ID += 1 ))
+
 # Check if we need to download the chroot file
-if [ ! -e "${WORLDCHROOT}" -a "${LINUXJAIL}" != "YES" ] ; then downloadchroot ; fi
 
+#
+# If this is a pluginjail, we clone a regular freebsd chroot, then we
+# bootstrap packageng, install the required packages that a pluginjail
+# needs, then snapshot it. Once this is done, creating a pluginjail is
+# as easy as doing a zfs clone.
+#
+if [ "${PLUGINJAIL}" = "YES" -a ! -e "${WORLDCHROOT}" ] ; then
+  if [ ! -e "${WORLDCHROOT_STANDARD}" ] ; then
+    downloadchroot "${WORLDCHROOT_STANDARD}"
+  fi
 
+  isDirZFS "${JDIR}"
+  if [ $? -eq 0 ] ; then
+    tank=`getZFSTank "$JDIR"`
+    zfsp=`getZFSRelativePath "${WORLDCHROOT_STANDARD}"`
+    clonep="/$(basename ${WORLDCHROOT_PLUGINJAIL})"
+
+    mnt=`getZFSMountpoint ${tank}`
+    pjdir="${mnt}${clonep}"
+
+    zfs clone ${tank}${zfsp}@clean ${tank}${clonep}
+    if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS pluginjail clone"; fi
+
+    cp /etc/resolv.conf ${pjdir}/etc/resolv.conf
+
+    bootstrap_pkgng "${pjdir}" "pluginjail"
+
+    zfs snapshot ${tank}${clonep}@clean
+    if [ $? -ne 0 ] ; then exit_err "Failed creating clean ZFS pluginjail snapshot"; fi
+
+  # We're on UFS :-(
+  else
+    downloadchroot "${WORLDCHROOT_STANDARD}"
+
+  fi
+
+elif [ ! -e "${WORLDCHROOT}" -a "${LINUXJAIL}" != "YES" ] ; then
+  downloadchroot "${WORLDCHROOT}"
+fi
+
 # If we are setting up a linux jail, lets do it now
 if [ "$LINUXJAIL" = "YES" ] ; then
-   isDirZFS "${JDIR}" "1"
+   isDirZFS "${JDIR}"
    if [ $? -eq 0 ] ; then
      # Create ZFS mount
-     zData=`getZFSDataset "$JDIR"`
-     if [ -z "$zData" ] ; then
-        exit_err "Failed getting ZFS dataset for $JDIR..";
+     tank=`getZFSTank "$JDIR"`
+     if [ -z "$tank" ] ; then
+       exit_err "Failed getting ZFS dataset for $JDIR..";
      fi
-     zfs create -o mountpoint=${JAILDIR} -p ${zData}/`basename ${JAILDIR}`
+     zfs create -o mountpoint=${JAILDIR} -p ${tank}${JAILDIR}
      if [ $? -ne 0 ] ; then exit_err "Failed creating ZFS dataset"; fi
    else
      mkdir -p "${JAILDIR}"
@@ -136,14 +218,13 @@
 
 echo "Building new Jail... Please wait..."
 
-isDirZFS "${JDIR}" "1"
+isDirZFS "${JDIR}"
 if [ $? -eq 0 ] ; then
    # Create ZFS CLONE
-   zData=`getZFSDataset "$JDIR"`
-   if [ -z "$zData" ] ; then
-      exit_err "Failed getting ZFS dataset for $JDIR..";
-   fi
-   zfs clone ${zData}/`basename ${WORLDCHROOT}`@clean ${zData}/`basename ${JAILDIR}`
+   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
@@ -154,13 +235,24 @@
    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
 
-
 mkdir ${JMETADIR}
 echo "${HOST}" > ${JMETADIR}/host
-echo "${IP}" > ${JMETADIR}/ip
+if [ "${IP4}" != "OFF" ] ; then
+   echo "${IP4}/${MASK4}" > ${JMETADIR}/ipv4
+fi
+if [ "${IP6}" != "OFF" ] ; then
+   echo "${IP6}/${MASK6}" > ${JMETADIR}/ipv6
+fi
+echo "${META_ID}" > ${JMETADIR}/id
 
 if [ "$SOURCE" = "YES" ]
 then
@@ -170,7 +262,7 @@
   SYSVER="$(uname -r)"
   get_file_from_mirrors "/${SYSVER}/${ARCH}/dist/src.txz" "src.txz"
   if [ $? -ne 0 ] ; then
-     echo "Error while downloading the freebsd world."
+    echo "Error while downloading the freebsd world."
   else
     echo "Extracting sources.. May take a while.."
     tar xvf src.txz -C "${JAILDIR}" 2>/dev/null
@@ -192,7 +284,7 @@
 fi
 
 # Create an empty fstab
-touch "${JDIR}/${IP}/etc/fstab"
+touch "${JAILDIR}/etc/fstab"
 
 # If this isn't a fresh jail, we can skip to not clobber existing setup
 if [ -z "$ARCHIVEFILE" ] ; then
@@ -202,10 +294,11 @@
 sendmail_enable=\"NO\"
 hostname=\"${HOST}\"
 devfs_enable=\"YES\"
-devfs_system_ruleset=\"devfsrules_common\"" > "${JDIR}/${IP}/etc/rc.conf"
+devfs_system_ruleset=\"devfsrules_common\"" > "${JAILDIR}/etc/rc.conf"
 
   # Create the host for this device
-  echo "# : src/etc/hosts,v 1.16 2003/01/28 21:29:23 dbaker Exp $
+cat<<__EOF__>"${JAILDIR}/etc/hosts"
+# : src/etc/hosts,v 1.16 2003/01/28 21:29:23 dbaker Exp $
 #
 # Host Database
 #
@@ -219,21 +312,22 @@
 #
 ::1                     localhost localhost.localdomain
 127.0.0.1               localhost localhost.localdomain ${HOST}
-${IP}			${HOST}" > "${JDIR}/${IP}/etc/hosts"
+__EOF__
 
+  if [ "${IP4}" != "OFF" ] ; then
+    echo "${IP4}			${HOST}" >> "${JAILDIR}/etc/hosts"
+  fi
+  if [ "${IP6}" != "OFF" ] ; then
+    echo "${IP6}			${HOST}" >> "${JAILDIR}/etc/hosts"
+    sed -i '' "s|#ListenAddress ::|ListenAddress ${IP6}|g" ${JAILDIR}/etc/ssh/sshd_config
+  fi
+
   # Copy resolv.conf
-  cp /etc/resolv.conf "${JDIR}/${IP}/etc/resolv.conf"
+  cp /etc/resolv.conf "${JAILDIR}/etc/resolv.conf"
 
-
-  # Check if ipv6
-  isV6 "${IP}"
-  if [ $? -eq 0 ] ; then
-    sed -i '' "s|#ListenAddress ::|ListenAddress ${IP}|g" ${JDIR}/${IP}/etc/ssh/sshd_config
-  fi
-
 fi # End of ARCHIVEFILE check
 
-if [ "$STARTUP" = "YES" ] ; then
+if [ "$AUTOSTART" = "YES" ] ; then
   touch "${JMETADIR}/autostart"
 fi
 
@@ -242,27 +336,38 @@
 
 # Check if we need to copy the timezone file
 if [ -e "/etc/localtime" ] ; then
-   cp /etc/localtime ${JDIR}/${IP}/etc/localtime
+   cp /etc/localtime ${JAILDIR}/etc/localtime
 fi
 
 # Setup PC-BSD PKGNG repo / utilities
 if [ "$VANILLA" != "YES" ] ; then
   bootstrap_pkgng "${JAILDIR}"
   if [ $? -ne 0 ] ; then
-     echo "You can manually re-try by running # warden bspkgng ${IP}"
+     echo "You can manually re-try by running # warden bspkgng ${JAILNAME}"
   fi
 fi
 
 # Set the default meta-pkg set
-mkdir -p ${JDIR}/${IP}/usr/local/etc >/dev/null 2>/dev/null
-echo "PCBSD_METAPKGSET: trueos" > ${JDIR}/${IP}/usr/local/etc/pcbsd.conf
+mkdir -p ${JAILDIR}/usr/local/etc >/dev/null 2>/dev/null
+echo "PCBSD_METAPKGSET: warden" > ${JAILDIR}/usr/local/etc/pcbsd.conf
 
+# Copy over the pbid scripts
+checkpbiscripts "${JAILDIR}"
+
 # Check if making a portjail
-if [ "$PORTJAIL" = "YES" ] ; then mkportjail "${JDIR}/${IP}" ; fi
+if [ "$PORTJAIL" = "YES" ] ; then mkportjail "${JAILDIR}" ; fi
 
+# Check if making a pluginjail
+if [ "$PLUGINJAIL" = "YES" ] ; then mkpluginjail "${JAILDIR}" ; fi
+
 # If we are auto-starting the jail, do it now
-if [ "$STARTUP" = "YES" ] ; then warden start ${IP} ; fi
+if [ "$AUTOSTART" = "YES" ] ; then warden start ${JAILNAME} ; fi
 
-echo "Jail created at ${JDIR}/${IP}"
+echo "Success!"
+echo "Jail created at ${JAILDIR}"
 
+if [ "${PLUGINJAIL}" = "YES" ] ; then
+  mkdir -p "${JAILDIR}/.plugins"
+fi
+
 exit 0

Modified: pcbsd/current/src-sh/warden/scripts/backend/cronsnap.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/cronsnap.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/cronsnap.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -20,59 +20,54 @@
 do
   if [ ! -e "${i}/cron" ] ; then continue ; fi
   if [ ! -e "${i}/cron-keep" ] ; then continue ; fi
-  jIP="`cat ${i}/ip`"
-  if [ ! -d "${JDIR}/${jIP}" ] ; then continue ; fi
+
+  jHOST="`cat ${i}/host`"
+  JAILDIR="${JDIR}/${jHOST}"
+
+  if [ ! -d "${JAILDIR}" ] ; then continue ; fi
+
   CRONFREQ="`cat ${i}/cron`"
   CRONKEEPDAYS="`cat ${i}/cron-keep`"
 
   # Figure out if we need to create a new snapshot
-  snaps=$(listZFSSnap "${JDIR}/$jIP")
+  snaps=$(listZFSSnap "${JAILDIR}")
   lastsnap=`echo $snaps | rev | cut -d " " -f 1 | rev`
   needSnap=0
   zdate=`date +%Y%m%d-%H%M%S`
   if [ "$CRONFREQ" = "daily" ] ; then
-     #echo "Checking for daily snapshots to ${jIP}..."
-     today=`date +%Y-%m-%d`
-     lastsnap=`echo $lastsnap | cut -d '-' -f 1-3`
+     #echo "Checking for daily snapshots to ${jHOST}..."
+     today=`date +%Y%m%d`
+     lastsnap=`echo $lastsnap | cut -d '-' -f 1`
      if [ "$today" != "$lastsnap" ] ; then
         needSnap=1
      fi
   else
   # Hourly
-     #echo "Checking for hourly snapshots to ${jIP}..."
-     today=`date +%Y-%m-%d`
+     #echo "Checking for hourly snapshots to ${jHOST}..."
+     today=`date +%Y%m%d`
      hour=`date +%H`
-     lastday=`echo $lastsnap | cut -d '-' -f 1-3`
-     lasthour=`echo $lastsnap | cut -d '-' -f 4 | cut -c 1-2`
+     lastday=`echo $lastsnap | cut -d '-' -f 1`
+     lasthour=`echo $lastsnap | cut -d '-' -f 2 | cut -c 1-2`
      if [ "$today" != "$lastday" -o "$hour" != "$lasthour" ] ; then
         needSnap=1
      fi
   fi
   if [ "$needSnap" = "1" ] ; then
-     mkZFSSnap "${JDIR}/${jIP}"
+     mkZFSSnap "${JAILDIR}"
   fi
 
-
   # Do any pruning
   num=0
-  echo "$snaps" | sort -g -r >/tmp/.wardensnaps.$$
-  while read snap
+  for snap in `echo $snaps | sort -r`
   do
-     if [ "$CRONFREQ" = "daily" ] ; then
-        cur="`echo $snap | cut -d '-' -f 1-3`" 
-     else
-        cur="`echo $snap | cut -d '-' -f 1-4`" 
-     fi
+     cur="`echo $snap | cut -d '-' -f 1`" 
      if [ "$cur" != "$prev" ] ; then
         num=`expr $num + 1`
         prev="$cur"
      fi
-     #echo "Checking $cur : Prev $prev : KEEPDAYS $CRONKEEPDAYS : NUM $num"
      if [ $num -gt $CRONKEEPDAYS ] ; then
         #echo "Pruning old snapshot: $snap"
-        rmZFSSnap "${JDIR}/${jIP}" "$snap"
+        rmZFSSnap "${JAILDIR}" "$snap"
      fi
-  done < /tmp/.wardensnaps.$$
-  rm /tmp/.wardensnaps.$$
+  done
 done
-

Modified: pcbsd/current/src-sh/warden/scripts/backend/deletejail.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/deletejail.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/deletejail.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -9,9 +9,9 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-IP="$1"
+JAILNAME="$1"
 
-if [ -z "${IP}" ]
+if [ -z "${JAILNAME}" ]
 then
   echo "ERROR: No jail specified to delete!"
   rtn
@@ -25,40 +25,41 @@
   exit 5
 fi
 
-if [ ! -d "${JDIR}/${IP}" ] ; then
-   echo "ERROR: No such jail at ${JDIR}/${IP}"
+JAILDIR="${JDIR}/${JAILNAME}"
+
+if [ ! -d "${JAILDIR}" ] ; then
+   echo "ERROR: No such jail at ${JAILDIR}"
    exit 5
 fi
 
 set_warden_metadir
 
 # Check if the jail is running first
-${PROGDIR}/scripts/backend/checkstatus.sh "${IP}"
+${PROGDIR}/scripts/backend/checkstatus.sh "${JAILNAME}"
 if [ "$?" = "0" ]
 then
   # Make sure the jail is stopped
-  ${PROGDIR}/scripts/backend/stopjail.sh "${IP}"
+  ${PROGDIR}/scripts/backend/stopjail.sh "${JAILNAME}"
 fi
 
 # Confirm jail was shutdown and no mounts are left
-${PROGDIR}/scripts/backend/checkstatus.sh "${IP}"
+${PROGDIR}/scripts/backend/checkstatus.sh "${JAILNAME}"
 if [ "$?" = "0" ] ; then
    echo "ERROR: Jail is still running, or has active mount-points.. Please stop manually."
    exit 5
 fi
 
 echo -e "Deleting Jail...\c"
-isDirZFS "${JDIR}/${IP}" "1"
+isDirZFS "${JAILDIR}" "1"
 if [ $? -eq 0 ] ; then
-  zData=`getZFSDataset "${JDIR}/${IP}"`
-  if [ -z "$zData" ] ; then
-     exit_err "Failed getting ZFS dataset for ${JDIR}/${IP}..";
-  fi
-  zfs destroy -r ${zData}
-  rmdir ${JDIR}/${IP} 2>/dev/null
+  # Create ZFS mount
+  tank=`getZFSTank "$JDIR"`
+  jailp=`getZFSRelativePath "${JAILDIR}"`
+  zfs destroy -r ${tank}${jailp}
+  rmdir ${JAILDIR} 2>/dev/null
 else
-  chflags -R noschg "${JDIR}/${IP}"
-  rm -rf "${JDIR}/${IP}"
+  chflags -R noschg "${JAILDIR}"
+  rm -rf "${JAILDIR}"
 fi
 
 if [ ! -z "${JMETADIR}" -a "${JMETADIR}" != " " ] ; then
@@ -66,4 +67,3 @@
 fi
 
 echo "Done"
-

Modified: pcbsd/current/src-sh/warden/scripts/backend/details.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/details.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/details.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -1,6 +1,6 @@
 #!/bin/sh
 # Script to check a jail status
-# Args $1 = IP
+# Args $1 = JAILNAME
 ######################################################################
 
 # Source our functions
@@ -9,11 +9,11 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-IP="$1"
+JAILNAME="$1"
 
-if [ -z "$IP" ]
+if [ -z "${JAILNAME}" ]
 then
-  echo "ERROR: You must specify an IP to check"
+  echo "ERROR: You must specify a jail to check"
   exit 5
 fi
 
@@ -23,34 +23,77 @@
   exit 5
 fi
 
-if [ ! -d "${JDIR}/${IP}" ]
+JAILDIR="${JDIR}/${JAILNAME}"
+
+if [ ! -d "${JAILDIR}" ]
 then
-  echo "ERROR: No jail located at $JDIR/$IP"
+  echo "ERROR: No jail located at ${JAILDIR}"
   exit 5
 fi
 
+set_warden_metadir
+
+IP4="`cat ${JMETADIR}/ipv4 2>/dev/null`"
+if [ -n "${IP4}" ] ; then
+  get_ip_and_netmask "${IP4}"
+  IP4="${JIP}"
+  MASK4="${JMASK}"
+fi
+
+IP6="`cat ${JMETADIR}/ipv6 2>/dev/null`"
+if [ -n "${IP6}" ] ; then
+  get_ip_and_netmask "${IP6}"
+  IP6="${JIP}"
+  MASK6="${JMASK}"
+fi
+
 # Display details about this jail now
 #####################################################################
-echo "Details for jail: ${IP}"
-isDirZFS "${JDIR}/${IP}" "1"
+echo "Details for jail: ${JAILNAME}"
+isDirZFS "${JAILDIR}" "1"
 if [ $? -eq 0 ] ; then 
-   tank=`getZFSTank "${JDIR}/${IP}"`
-   diskUsage=`df -m | grep -w ${tank}${JDIR}/${IP}$ | awk '{print $3}'`
+   tank=`getZFSDataset "${JAILDIR}"`
+   diskUsage=`df -m | grep -w "^${tank} " | awk '{print $3}'`
 else
-   diskUsage=`du -c -x -m ${JDIR}/${IP} 2>/dev/null | grep total | tail -n 1 | awk '{print $1}'`
+   diskUsage=`du -c -x -m ${JAILDIR} 2>/dev/null | grep total | tail -n 1 | awk '{print $1}'`
 fi
-sockstat | grep "${IP}" | grep '*.*' | awk '{print $6}' | sed "s|${IP}:||g" | sort -g | uniq >/tmp/.socklist.$$
-while read line
-do
-  if [ -z "$portList" ] ; then
-    portList="${line}" 
-  else
-    portList="${portList},$line" 
-  fi
-done < /tmp/.socklist.$$
-rm /tmp/.socklist.$$
-activeCon=`sockstat | grep "${IP}" | grep -v '*.*' | wc -l | awk '{print $1}'`
 
+portList4=
+activeCon4=
+if [ -n "${IP4}" ] ; then
+   sockstat | grep "${IP4}" | grep '*.*' | awk '{print $6}' | sed "s|${IP4}:||g" | sort -g | uniq >/tmp/.socklist4.$$
+   while read line
+   do
+     if [ -z "$portList4" ] ; then
+       portList4="${line}" 
+     else
+       portList4="${portList4},$line" 
+     fi
+   done < /tmp/.socklist4.$$
+   rm /tmp/.socklist4.$$
+   activeCon4=`sockstat | grep "${IP4}" | grep -v '*.*' | wc -l | awk '{print $1}'`
+fi
+
+portList6=
+activeCon6=
+if [ -n "${IP6}" ] ; then
+   sockstat | grep "${IP6}" | grep '*.*' | awk '{print $6}' | sed "s|${IP6}:||g" | sort -g | uniq >/tmp/.socklist6.$$
+   while read line
+   do
+     if [ -z "$portList6" ] ; then
+       portList6="${line}" 
+     else
+       portList6="${portList6},$line" 
+     fi
+   done < /tmp/.socklist6.$$
+   rm /tmp/.socklist6.$$
+   activeCon6=`sockstat | grep "${IP6}" | grep -v '*.*' | wc -l | awk '{print $1}'`
+fi
+
 echo "Disk Usage: ${diskUsage}MB"
-echo "Active Ports: ${portList}"
-echo "Current Connections: ${activeCon}"
+
+echo "Active IPv4 Ports: ${portList4}"
+echo "Current IPv4 Connections: ${activeCon4}"
+
+echo "Active IPv6 Ports: ${portList6}"
+echo "Current IPv6 Connections: ${activeCon6}"

Modified: pcbsd/current/src-sh/warden/scripts/backend/exportjail.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/exportjail.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/exportjail.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -8,10 +8,10 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-IP="$1"
+JAILNAME="$1"
 OUTDIR="$2"
 
-if [ -z "${IP}" ]
+if [ -z "${JAILNAME}" ]
 then
   echo "ERROR: No jail specified to chroot into!"
   exit 5
@@ -23,65 +23,77 @@
   exit 5
 fi
 
-if [ ! -d "${JDIR}/${IP}" ]
+JAILDIR="${JDIR}/${JAILNAME}"
+
+if [ ! -d "${JAILDIR}" ]
 then
-  echo "ERROR: No jail located at $JDIR/$IP"
+  echo "ERROR: No jail located at ${JAILDIR}"
   exit 5
 fi
 
 set_warden_metadir
 
 # First check if this jail is running, and stop it
-${PROGDIR}/scripts/backend/checkstatus.sh "$IP"
+${PROGDIR}/scripts/backend/checkstatus.sh "${JAILNAME}"
 if [ "$?" = "0" ]
 then
-  ${PROGDIR}/scripts/backend/stopjail.sh "$IP"
+  ${PROGDIR}/scripts/backend/stopjail.sh "${JAILNAME}"
 fi
 
 # Now that the jail is stopped, lets make a large tbz file of it
-cd ${JDIR}/${IP}
+cd ${JAILDIR}
 
 # Get the Hostname
 HOST="`cat ${JMETADIR}/host`"
 
+IP4="`cat ${JMETADIR}/ipv4 2>/dev/null`"
+IP6="`cat ${JMETADIR}/ipv6 2>/dev/null`"
 
-echo "Creating compressed archive of ${IP}... Please Wait..." >&1
-tar cvJf "${WTMP}/${IP}.tlz" -C "${JDIR}/${IP}" . 2>${WTMP}/${IP}.files
+get_ip_and_netmask "${IP4}"
+IP4="${JIP}"
+MASK4="${JMASK}"
 
+get_ip_and_netmask "${IP6}"
+IP6="${JIP}"
+MASK6="${JMASK}"
+
+echo "Creating compressed archive of ${JAILNAME}... Please Wait..." >&1
+tar cvJf "${WTMP}/${JAILNAME}.tlz" -C "${JAILDIR}" . 2>${WTMP}/${JAILNAME}.files
+
 cd ${WTMP}
 
-LINES="`wc -l ${IP}.files | sed -e 's, ,,g' | cut -d '.' -f 1`"
+LINES="`wc -l ${JAILNAME}.files | sed -e 's, ,,g' | cut -d '.' -f 1`"
 
-
 # Finished, now make the header info
 cd ${WTMP}
 echo "[Warden file]
 Ver: 1.0 
 OS: `uname -r | cut -d '-' -f 1`
 Files: $LINES
-IP: ${IP}
+IP4: ${IP4}/${MASK4}
+IP6: ${IP6}/${MASK6}
 HOST: ${HOST}
-" >${WTMP}/${IP}.header
+" >${WTMP}/${JAILNAME}.header
 
 # Copy over jail extra meta-data
 cp ${JMETADIR}/jail-* ${WTMP}/ 2>/dev/null
 
 # Compress the header file
-tar cvzf ${IP}.header.tgz ${IP}.header jail-* 2>/dev/null
+tar cvzf ${JAILNAME}.header.tgz ${JAILNAME}.header jail-* 2>/dev/null
 
 # Create our spacer
 echo "
 ___WARDEN_START___" > .spacer
 
 # Make the .wdn file now
-cat ${IP}.header.tgz .spacer ${IP}.tlz > ${IP}.wdn
+cat ${JAILNAME}.header.tgz .spacer ${JAILNAME}.tlz > ${JAILNAME}.wdn
 
 # Remove the old files
-rm ${IP}.header
-rm ${IP}.files
-rm ${IP}.tlz
+rm ${JAILNAME}.header
+rm ${JAILNAME}.files
+rm ${JAILNAME}.tlz
 rm .spacer
-rm ${IP}.header.tgz
+rm ${JAILNAME}.header.tgz
 
 # Remove any extra jail meta-files from WTMP
 for i in `ls ${JMETADIR}/jail-* 2>/dev/null`
@@ -93,12 +105,10 @@
 if [ ! -z "${OUTDIR}" ]
 then
   mkdir -p ${OUTDIR} 2>/dev/null
-  mv ${IP}.wdn ${OUTDIR}/
-  echo "Created ${IP}.wdn in ${OUTDIR}" >&1
+  mv ${JAILNAME}.wdn ${OUTDIR}/
+  echo "Created ${JAILNAME}.wdn in ${OUTDIR}" >&1
 else 
-  echo "Created ${IP}.wdn in ${WTMP}" >&1
+  echo "Created ${JAILNAME}.wdn in ${WTMP}" >&1
 fi
 
-
 exit 0
-

Modified: pcbsd/current/src-sh/warden/scripts/backend/functions.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/functions.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/functions.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -32,12 +32,19 @@
 WTMP="$(grep ^WTMP: /usr/local/etc/warden.conf | cut -d' ' -f2)"
 export WTMP
 
+# FreeBSD release
+FREEBSD_RELEASE="$(grep ^FREEBSD_RELEASE: /usr/local/etc/warden.conf | cut -d' ' -f2)"
+if [ -z "${FREEBSD_RELEASE}" ] ; then
+  FREEBSD_RELEASE="$(uname -r)"
+fi
+export UNAME_r="${FREEBSD_RELEASE}"
+
 # Temp file for dialog responses
 ATMP="/tmp/.wans"
 export ATMP
 
 # Warden Version
-WARDENVER="1.2"
+WARDENVER="1.3"
 export WARDENVER
 
 # Dirs to nullfs mount in X jail
@@ -46,62 +53,126 @@
 # Clone directory
 CDIR="${JDIR}/clones"
 
-### Download the chroot
-downloadchroot() {
+downloadpluginjail() {
+  local _ver="${1}"
 
-  SYSVER="$(uname -r)"
+  SYSVER=`echo "${_ver}" | sed -E 's|^FreeNAS-(([0-9]+\.){2}[0-9]+).*|\1|'`
+  SYSREL=`echo "${_ver}" | sed -E 's|^FreeNAS-([0-9]+\.){2}[0-9]+-([a-zA-Z0-9]+)-.*|\2|'`
+  SYSARCH=`echo "${_ver}" | sed -E 's#^(.*)(x86|x64)#\2#'`
 
-  local dFiles="base.txz doc.txz games.txz"
-  if [ "$ARCH" = "amd64" ] ; then
-     dFiles="$dFiles lib32.txz"
-  fi
+  SF="http://downloads.sourceforge.net/project/freenas"
+  URL="${SF}/FreeNAS-${SYSVER}/${SYSREL}/${SYSARCH}/plugins"
 
+  PJAIL="FreeNAS-${SYSVER}-${SYSREL}-${SYSARCH}.Plugins_Jail.pbi"
+  PJAILSHA256="${PJAIL}.sha256"
+
   if [ ! -d "${JDIR}" ] ; then mkdir -p "${JDIR}" ; fi
   cd ${JDIR}
 
   echo "Fetching jail environment. This may take a while..."
-  for i in $dFiles
-  do
-    echo "Downloading ${SYSVER}/${ARCH}/dist/${i} ..."
 
-    get_file_from_mirrors "/${SYSVER}/${ARCH}/dist/${i}" "$i"
-    [ $? -ne 0 ] && printerror "Error while downloading the freebsd world."
-  done
+  if [ ! -e "${PJAIL}" ] ; then
+     echo "Downloading ${URL}/${PJAIL} ..."
+     get_file "${URL}/${PJAIL}" "${PJAIL}" 3
+     [ $? -ne 0 ] && printerror "Error while downloading the pluginjail."
+  fi
 
+  if [ ! -e "${PJAILSHA256}" ] ; then
+     echo "Downloading ${URL}/${PJAILSHA256} ..."
+     get_file "${URL}/${PJAILSHA256}" "${PJAILSHA256}" 3
+     [ $? -ne 0 ] && printerror "Error while downloading the pluginjail sha256."
+  fi
 
+  [ "$(sha256 -q ${PJAIL})" != "$(cat ${PJAILSHA256})" ] &&
+    printerror "Error in download data, checksum mismatch. Please try again later."
+
   # Creating ZFS dataset?
-  isDirZFS "${JDIR}" "1"
+  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
-       # Check the mount-point for this zfs dataset
-       zData=`getZFSDataset "$JDIR"`
-       if [ -z "$zData" ] ; then 
-          exit_err "Failed getting ZFS dataset for $JDIR.."; 
-       fi
-       zfs create -o mountpoint=${WORLDCHROOT} -p ${zData}/`basename ${WORLDCHROOT}`
+       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}
   else
-    mkdir ${WORLDCHROOT}
+    # Save the chroot tarball
+    mv ${PJAIL} ${WORLDCHROOT}
   fi
+  rm ${PJAILSHA256}
+};
 
-  # Extract dist files
-  for i in $dFiles
-  do
-    tar xvpf ${i} -C ${WORLDCHROOT} 2>/dev/null
-    if [ $? -ne 0 ] ; then exit_err "Failed extracting freebsd environment"; fi
-    rm ${i}
-  done
+### Download the chroot
+downloadchroot() {
+  local CHROOT="${1}"
 
-  # Create ZFS clean snapshot
-  isDirZFS "${JDIR}" "1"
+  # XXX If this is PCBSD, pbreg get /PC-BSD/Version
+  SYSVER="$(echo "$(uname -r)" | cut -f1 -d'-')"
+  FBSD_TARBALL="fbsd-release.txz"
+  FBSD_TARBALL_CKSUM="${FBSD_TARBALL}.md5"
+
+  # Set the mirror URL, may be overridden by setting MIRRORURL environment variable
+  if [ -z "${MIRRORURL}" ]; then
+    get_mirror
+    MIRRORURL="$VAL"
+  fi
+
+  if [ ! -d "${JDIR}" ] ; then mkdir -p "${JDIR}" ; fi
+  cd ${JDIR}
+
+  echo "Fetching jail environment. This may take a while..."
+  echo "Downloading ${MIRRORURL}/${SYSVER}/${ARCH}/netinstall/${FBSD_TARBALL} ..."
+
+  if [ ! -e "$FBSD_TARBALL" ] ; then
+     get_file "${MIRRORURL}/${SYSVER}/${ARCH}/netinstall/${FBSD_TARBALL}" "$FBSD_TARBALL" 3
+     [ $? -ne 0 ] && printerror "Error while downloading the portsjail."
+  fi
+
+  if [ ! -e "$FBSD_TARBALL_CKSUM" ] ; then
+     get_file "${MIRRORURL}/${SYSVER}/${ARCH}/netinstall/${FBSD_TARBALL_CKSUM}" "$FBSD_TARBALL_CKSUM" 3
+     [ $? -ne 0 ] && printerror "Error while downloading the portsjail."
+  fi
+
+  [ "$(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
-    zfs snapshot ${zData}/`basename $WORLDCHROOT`@clean
+    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
+
+    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}
   fi
+  rm ${FBSD_TARBALL_CKSUM}
 };
 
 
@@ -197,80 +268,75 @@
   touch ${JMETADIR}/jail-portjail
 }
 
+mkpluginjail() {
+  if [ -z "${1}" ] ; then return ; fi
+  ETCFILES="resolv.conf passwd master.passwd spwd.db pwd.db group localtime"
+  for file in ${ETCFILES}; do
+    rm ${1}/etc/${file} >/dev/null 2>&1
+    cp /etc/${file} ${1}/etc/${file}
+  done
+  
+  # Need to symlink /home
+  chroot ${1} ln -fs /usr/home /home
+
+  # Make sure we remove our cleartmp rc.d script, causes issues
+  [ -e "${1}/etc/rc.d/cleartmp" ] && rm ${1}/etc/rc.d/cleartmp
+  # Flag this type
+  touch ${JMETADIR}/jail-pluginjail
+}
+
 mkZFSSnap() {
   isDirZFS "${1}" "1"
   if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${1}" ; fi
+  tank=`getZFSTank "$1"`
+  rp=`getZFSRelativePath "$1"`
   zdate=`date +%Y-%m-%d-%H-%M-%S`
-  # Check the mount-point for this tank
-  zData=`getZFSDataset "$1"`
-  if [ -z "$zData" ] ; then
-     exit_err "Failed getting ZFS dataset for $1..";
-  fi
-  zfs snapshot ${zData}@$zdate
-  if [ $? -ne 0 ] ; then exit_err "Failed snapshot of dataset: $1"; fi
+  zfs snapshot $tank${rp}@$zdate
 }
 
 listZFSSnap() {
   isDirZFS "${1}" "1"
   if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${1}" ; fi
-  # Check the mount-point for this tank
-  zData=`getZFSDataset "$1"`
-  if [ -z "$zData" ] ; then
-     exit_err "Failed getting ZFS dataset for $1..";
-  fi
-  zfs list -t snapshot | grep -w "^${zData}" | cut -d '@' -f 2 | awk '{print $1}'
+  tank=`getZFSTank "$1"`
+  rp=`getZFSRelativePath "$1"`
+  zfs list -t snapshot | grep -w "^${tank}${rp}" | cut -d '@' -f 2 | awk '{print $1}'
 }
 
 listZFSClone() {
   isDirZFS "${1}" "1"
   if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${1}" ; fi
+  tank=`getZFSTank "$1"`
+  cdir=`getZFSRelativePath "${CDIR}"` 
   echo "Clone Directory: ${CDIR}"
   echo "-----------------------------------"
-  # Check the mount-point for this tank
-  zData=`getZFSDataset "$CDIR"`
-  if [ -z "$zData" ] ; then
-     exit_err "Failed getting ZFS dataset for $CDIR..";
-  fi
-  zfs list | grep -w "^${zData}/${2}" | awk '{print $5}' | sed "s|${CDIR}/${2}-||g"
+  zfs list | grep -w "^${tank}${cdir}/${2}" | awk '{print $5}' | sed "s|${CDIR}/${2}-||g"
 }
 
 rmZFSClone() {
   CLONEDIR="${CDIR}/${3}-${2}"
   isDirZFS "${CLONEDIR}" "1"
   if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${CLONEDIR}" ; fi
-  # Check the mount-point for this tank
-  zData=`getZFSDataset "$CLONEDIR"`
-  if [ -z "$zData" ] ; then
-     exit_err "Failed getting ZFS dataset for $CLONEDIR..";
-  fi
-  zfs destroy ${zData}
-  if [ $? -ne 0 ] ; then exit_err "Failed removing: $CLONEDIR"; fi
+  tank=`getZFSTank "${CLONEDIR}"`
+  rp=`getZFSRelativePath "${CLONEDIR}"`
+  zfs destroy ${tank}${rp}
 }
 
 rmZFSSnap() {
   isDirZFS "${1}" "1"
   if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${1}" ; fi
   tank=`getZFSTank "$1"`
-  # Check the mount-point for this tank
-  zData=`getZFSDataset "$1"`
-  if [ -z "$zData" ] ; then
-     exit_err "Failed getting ZFS dataset for $1..";
-  fi
-  zfs destroy ${zData}@$2
-  if [ $? -ne 0 ] ; then exit_err "Failed removing: ${1}@${2}"; fi
+  rp=`getZFSRelativePath "$1"`
+  zfs destroy $tank${rp}@$2
 }
 
 revertZFSSnap() {
   isDirZFS "${1}" "1"
   if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${1}" ; fi
-  # Check the mount-point for this tank
-  zData=`getZFSDataset "$1"`
-  if [ -z "$zData" ] ; then
-     exit_err "Failed getting ZFS dataset for $1..";
-  fi
+  tank=`getZFSTank "$1"`
+  rp=`getZFSRelativePath "$1"`
 
   # Make sure this is a valid snapshot
-  zfs list -t snapshot | grep -w "^${zData}" | cut -d '@' -f 2 | awk '{print $1}' | grep -q ${2}
+  zfs list -t snapshot | grep -w "^${tank}${rp}" | cut -d '@' -f 2 | awk '{print $1}' | grep -q ${2}
   if [ $? -ne 0 ] ; then printerror "Invalid ZFS snapshot!" ; fi
 
   # Check if the jail is running first
@@ -286,8 +352,7 @@
   fi
 
   # Rollback the snapshot
-  zfs rollback -R -f ${zData}@$2
-  if [ $? -ne 0 ] ; then exit_err "Failed rollback: ${zData}@${2}"; fi
+  zfs rollback -R -f ${tank}${rp}@$2
 
   # If it was started, restart the jail now
   if [ "$restartJail" = "YES" ]; then
@@ -299,18 +364,12 @@
 cloneZFSSnap() {
   isDirZFS "${1}" "1"
   if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${1}" ; fi
-  # Check the mount-point for this tank
-  zData=`getZFSDataset "$1"`
-  if [ -z "$zData" ] ; then
-     exit_err "Failed getting ZFS dataset for $1..";
-  fi
-  zDataJ=`getZFSDataset "$JDIR"`
-  if [ -z "$zDataJ" ] ; then
-     exit_err "Failed getting ZFS dataset for $JDIR..";
-  fi
+  tank=`getZFSTank "$1"`
+  rp=`getZFSRelativePath "$1"`
+  cdir=`getZFSRelativePath "${CDIR}"`
 
   # Make sure this is a valid snapshot
-  zfs list -t snapshot | grep -w "^${zData}" | cut -d '@' -f 2 | awk '{print $1}' | grep -q ${2}
+  zfs list -t snapshot | grep -w "^${tank}${rp}" | cut -d '@' -f 2 | awk '{print $1}' | grep -q ${2}
   if [ $? -ne 0 ] ; then printerror "Invalid ZFS snapshot!" ; fi
 
   if [ -d "${CDIR}/${3}-${2}" ] ; then
@@ -318,17 +377,206 @@
   fi
 
   # Clone the snapshot
-  zfs clone -p ${zData}@$2 ${zDataJ}/`basename $CDIR`/${3}-${2}
+  zfs clone -p ${tank}${rp}@$2 ${tank}${cdir}/${3}-${2}
 
   echo "Snapshot cloned and mounted to: ${CDIR}/${3}-${2}"
 }
 
 set_warden_metadir()
 {
-   JMETADIR="${JDIR}/.${IP}.meta"
+   JMETADIR="${JDIR}/.${JAILNAME}.meta"
    export JMETADIR
 }
 
+get_ip_and_netmask()
+{
+   JIP=`echo "${1}" | cut -f1 -d'/'`
+   JMASK=`echo "${1}" | cut -f2 -d'/' -s`
+}
+
+get_interface_addresses()
+{
+   ifconfig ${1} | grep -w inet | awk '{ print $2 }'
+}
+
+get_interface_ipv4_addresses()
+{
+   ifconfig ${1} | grep -w inet | awk '{ print $2 }'
+}
+
+get_interface_ipv6_addresses()
+{
+   ifconfig ${1} | grep -w inet6 | awk '{ print $2 }'
+}
+
+get_interface_address()
+{
+   ifconfig ${1} | grep -w inet | head -1 | awk '{ print $2 }'
+}
+
+get_interface_ipv4_address()
+{
+   ifconfig ${1} | grep -w inet | head -1 | awk '{ print $2 }'
+}
+
+get_interface_ipv6_address()
+{
+   ifconfig ${1} | grep -w inet6 | head -1 | awk '{ print $2 }'
+}
+
+get_interface_aliases()
+{
+   local _count
+
+   _count=`ifconfig ${1} | grep -w inet | wc -l`
+   _count="$(echo "${_count} - 1" | bc)"
+
+   ifconfig ${1} | grep -w inet | tail -${_count} | awk '{ print $2 }'
+}
+
+get_interface_ipv4_aliases()
+{
+   local _count
+
+   _count=`ifconfig ${1} | grep -w inet | wc -l`
+   _count="$(echo "${_count} - 1" | bc)"
+
+   ifconfig ${1} | grep -w inet | tail -${_count} | awk '{ print $2 }'
+}
+
+get_interface_ipv6_aliases()
+{
+   local _count
+
+   _count=`ifconfig ${1} | grep -w inet | wc -l`
+   _count="$(echo "${_count} - 1" | bc)"
+
+   ifconfig ${1} | grep -w inet6 | tail -${_count} | awk '{ print $2 }'
+}
+
+get_default_route()
+{
+   netstat -f inet -nr | grep '^default' | awk '{ print $2 }'
+}
+
+get_default_interface()
+{
+   netstat -f inet -nrW | grep '^default' | awk '{ print $7 }'
+}
+
+get_bridge_interfaces()
+{
+   ifconfig -a | grep -E '^bridge[0-9]+' | cut -f1 -d:
+}
+
+get_bridge_members()
+{
+   ifconfig ${1} | grep -w member | awk '{ print $2 }'
+}
+
+get_bridge_interface_by_ipv4_network()
+{
+   local network="${1}"
+   local bridges="$(get_bridge_interfaces)"
+
+   if [ -z "${network}" ]
+   then
+      return 1
+   fi
+
+   for _bridge in ${bridges}
+   do
+      local ips="$(get_interface_ipv4_aliases "${_bridge}")"
+      for _ip in ${ips}
+      do
+         if in_ipv4_network "${_ip}" "${network}"
+         then
+            echo "${_bridge}"
+            return 0
+         fi
+      done
+   done
+
+   return 1
+}
+
+get_bridge_interface_by_ipv6_network()
+{
+   local network="${1}"
+   local bridges="$(get_bridge_interfaces)"
+
+   if [ -z "${network}" ]
+   then
+      return 1
+   fi
+
+   for _bridge in ${bridges}
+   do
+      local ips="$(get_interface_ipv6_aliases "${_bridge}")"
+      for _ip in ${ips}
+      do
+         if in_ipv6_network "${_ip}" "${network}"
+         then
+            echo "${_bridge}"
+            return 0
+         fi
+      done
+   done
+
+   return 1
+}
+
+is_bridge_member()
+{
+   local _bridge="${1}"
+   local _iface="${2}"
+
+   for _member in `get_bridge_members ${_bridge}`
+   do
+      if [ "${_member}" = "${_iface}" ] ; then
+         return 0
+      fi
+   done
+
+   return 1
+}
+
+jail_interfaces_down()
+{
+   local _jid="${1}"
+   local _bridgeif
+   local _epaira
+   local _epairb
+
+   _epairb=`jexec ${_jid} ifconfig -a | grep '^epair' | cut -f1 -d:`
+   if [ -n "${_epairb}" ] ; then
+      _epaira=`echo ${_epairb} | sed -E 's|b$|a|'`
+      _bridgeif=
+
+      for _bridge in `ifconfig -a | grep -E '^bridge[0-9]+' | cut -f1 -d:`
+      do
+         for _member in `ifconfig ${_bridge} | grep member | awk '{ print $2 }'`
+         do
+            if [ "${_member}" = "${_epaira}" ] ; then
+               _bridgeif="${_bridge}"
+                break
+            fi
+         done
+         if [ -n "${_bridgeif}" ] ; then
+            break
+         fi
+      done
+
+      jexec ${_jid} ifconfig ${_epairb} down
+      ifconfig ${_epaira} down
+      ifconfig ${_epaira} destroy
+      _count=`ifconfig ${_bridgeif} | grep member | awk '{ print $2 }' | wc -l`
+      if [ "${_count}" -le "1" ] ; then
+         ifconfig ${_bridgeif} destroy
+      fi
+   fi
+}
+
 enable_cron()
 {
    cronscript="${PROGDIR}/scripts/backend/cronsnap.sh"
@@ -352,40 +600,371 @@
    done
 }
 
+is_ipv4()
+{
+   local addr="${1}"
+   local res=1
+
+   local ipv4="$(/usr/local/bin/sipcalc "${addr}"|head -1|cut -f2 -d'['|awk '{ print $1 }')"
+   if [ "${ipv4}" = "ipv4" ]
+   then
+      res=0
+   fi
+
+   return ${res}
+}
+
+is_ipv6()
+{
+   local addr="${1}"
+   local res=1
+
+   local ipv6="$(/usr/local/bin/sipcalc "${addr}"|head -1|cut -f2 -d'['|awk '{ print $1 }')"
+   if [ "${ipv6}" = "ipv6" ]
+   then
+      res=0
+   fi
+
+   return ${res}
+}
+
+in_ipv4_network()
+{
+   local addr="${1}"
+   local network="${2}"
+   local res=1
+
+   local start="$(/usr/local/bin/sipcalc "${network}"|awk '/^Usable/ { print $4 }')"
+   local end="$(/usr/local/bin/sipcalc "${network}"|awk '/^Usable/ { print $6 }')"
+
+   local iaddr="$(/usr/local/bin/sipcalc "${addr}"|awk '/(decimal)/ { print $5 }')"
+   local istart="$(/usr/local/bin/sipcalc "${start}"|awk '/(decimal)/ { print $5 }')"
+   local iend="$(/usr/local/bin/sipcalc "${end}"|awk '/(decimal)/ { print $5 }')"
+
+   if [ "${iaddr}" -ge "${istart}" -a "${iaddr}" -le "${iend}" ]
+   then
+      res=0
+   fi
+
+   return ${res}
+}
+
+ipv6_to_binary()
+{
+   echo ${1}|awk '{
+      split($1, octets, ":");
+      olen = length(octets);
+		
+      bnum = "";
+      for (i = 1;i <= olen;i++) {
+         tbnum = "";
+         dnum = int(sprintf("0x%s", octets[i]));
+         for (;;) {
+            rem = int(dnum % 2);
+            if (rem == 0) 
+               tbnum = sprintf("0%s", tbnum);
+            else		
+               tbnum = sprintf("1%s", tbnum);
+            dnum /= 2;
+            if (dnum < 1)
+               break;
+         }
+         bnum = sprintf("%s%016s", bnum, tbnum);
+      }
+      printf("%s", bnum);
+   }'
+}
+
+in_ipv6_network()
+{
+   local addr="${1}"
+   local network="${2}"
+   local mask="$(echo "${network}"|cut -f2 -d'/' -s)"
+   local res=1
+
+   local addr="$(/usr/local/bin/sipcalc "${addr}"|awk \
+      '/^Expanded/ { print $4}')"
+   local start="$(/usr/local/bin/sipcalc "${network}"|egrep \
+      '^Network range'|awk '{ print $4 }')"
+
+   local baddr="$(ipv6_to_binary "${addr}")"
+   local bstart="$(ipv6_to_binary "${start}")"
+
+   local baddrnet="$(echo "${baddr}"|awk -v mask="${mask}" \
+      '{ s = substr($0, 1, mask); printf("%s", s); }')"
+   local bstartnet="$(echo "${bstart}"|awk -v mask="${mask}" \
+      '{ s = substr($0, 1, mask); printf("%s", s); }')"
+
+   if [ "${baddrnet}" = "${bstartnet}" ]
+   then
+      res=0
+   fi
+
+   return ${res}
+}
+
+install_pc_extractoverlay()
+{
+  if [ -z "${1}" ] ; then
+    return 1 
+  fi 
+
+  mkdir -p ${1}/usr/local/bin
+  mkdir -p ${1}/usr/local/share/pcbsd/conf
+  mkdir -p ${1}/usr/local/share/pcbsd/distfiles
+
+  cp /usr/local/bin/pc-extractoverlay ${1}/usr/local/bin/
+  chmod 755 ${1}/usr/local/bin/pc-extractoverlay
+
+  cp /usr/local/share/pcbsd/conf/server-excludes \
+    ${1}/usr/local/share/pcbsd/conf
+  cp /usr/local/share/pcbsd/distfiles/server-overlay.txz \
+    ${1}/usr/local/share/pcbsd/distfiles
+
+  return 0
+}
+
+make_bootstrap_pkgng_file_standard()
+{
+  local jaildir="${1}"
+  local outfile="${2}"
+
+  local release="$(uname -r)"
+  local arch="$(uname -m)"
+
+  get_mirror
+  local mirror="${VAL}"
+
+cat<<__EOF__>"${outfile}"
+#!/bin/sh
+tar xvf pkg.txz --exclude +MANIFEST --exclude +MTREE_DIRS 2>/dev/null
+pkg add pkg.txz
+rm pkg.txz
+
+echo "packagesite: ${mirror}/packages/${release}/${arch}" >/usr/local/etc/pkg.conf
+echo "HTTP_MIRROR: http" >>/usr/local/etc/pkg.conf
+echo "PUBKEY: /usr/local/etc/pkg-pubkey.cert" >>/usr/local/etc/pkg.conf
+echo "PKG_CACHEDIR: /usr/local/tmp" >>/usr/local/etc/pkg.conf
+pkg install -y pcbsd-utils
+exit $?
+__EOF__
+}
+
+make_bootstrap_pkgng_file_pluginjail()
+{
+
+  local jaildir="${1}"
+  local outfile="${2}"
+
+  local release="$(uname -r)"
+  local arch="$(uname -m)"
+
+  get_mirror
+  local mirror="${VAL}"
+
+  cp /usr/local/share/warden/pluginjail-packages "${jaildir}/pluginjail-packages"
+
+cat<<__EOF__>"${outfile}"
+#!/bin/sh
+tar xvf pkg.txz --exclude +MANIFEST --exclude +MTREE_DIRS 2>/dev/null
+pkg add pkg.txz
+rm pkg.txz
+
+mount -t devfs devfs /dev
+
+echo "packagesite: ${mirror}/packages/${release}/${arch}" >/usr/local/etc/pkg.conf
+echo "HTTP_MIRROR: http" >>/usr/local/etc/pkg.conf
+echo "PUBKEY: /usr/local/etc/pkg-pubkey.cert" >>/usr/local/etc/pkg.conf
+echo "PKG_CACHEDIR: /usr/local/tmp" >>/usr/local/etc/pkg.conf
+pkg install -y pcbsd-utils
+__EOF__
+
+echo '
+i=0
+count=`wc -l /pluginjail-packages| awk "{ print $1 }"`
+for p in `cat /pluginjail-packages`
+do
+  pkg install -y ${p}
+  : $(( i += 1 ))
+done
+
+umount devfs
+exit $?
+' >> "${outfile}"
+}
+
+
 bootstrap_pkgng()
 {
-  cd ${1}
-  SYSVER="$(uname -r)"
+  local jaildir="${1}"
+  local jailtype="${2}"
+  if [ -z "${jailtype}" ] ; then
+    jailtype="standard"
+  fi
+  local release="$(uname -r)"
+  local arch="$(uname -m)"
+
+  local ffunc="make_bootstrap_pkgng_file_standard"
+  if [ "${jailtype}" = "pluginjail" ] ; then
+    ffunc="make_bootstrap_pkgng_file_pluginjail"
+  fi
+
+  cd ${jaildir} 
   echo "Boot-strapping pkgng"
-  mkdir -p ${1}/usr/local/etc
-  cp /usr/local/etc/pkg-pubkey.cert ${1}/usr/local/etc/
 
-  echo '#!/bin/sh
-  tar xvf pkg.txz --exclude +MANIFEST --exclude +MTREE_DIRS 2>/dev/null
-  pkg add pkg.txz
-  rm pkg.txz
-  ARCH=$(uname -m)
-  REL=$(uname -r)
-  echo "packagesite: http://getmirror.pcbsd.org/packages/$REL/$ARCH" >/usr/local/etc/pkg.conf
-  echo "HTTP_MIRROR: http" >>/usr/local/etc/pkg.conf
-  echo "PUBKEY: /usr/local/etc/pkg-pubkey.cert" >>/usr/local/etc/pkg.conf
-  echo "PKG_CACHEDIR: /usr/local/tmp" >>/usr/local/etc/pkg.conf
-  pkg install -y pcbsd-utils
-  exit $?
-' > ${1}/bootstrap-pkgng
-  chmod 755 ${1}/bootstrap-pkgng
+  mkdir -p ${jaildir}/usr/local/etc
+  pubcert="/usr/local/etc/pkg-pubkey.cert"
 
+  cp "${pubcert}" ${jaildir}/usr/local/etc
+  install_pc_extractoverlay "${jaildir}"
+
+  ${ffunc} "${jaildir}" "${jaildir}/bootstrap-pkgng"
+  chmod 755 "${jaildir}/bootstrap-pkgng"
+
   if [ -e "pkg.txz" ] ; then rm pkg.txz ; fi
-  get_file_from_mirrors "/packages/${SYSVER}/${ARCH}/Latest/pkg.txz" "pkg.txz"
+  get_file_from_mirrors "/packages/${release}/${arch}/Latest/pkg.txz" "pkg.txz"
   if [ $? -eq 0 ] ; then
-    chroot ${1} /bootstrap-pkgng
+    chroot ${jaildir} /bootstrap-pkgng
     if [ $? -eq 0 ] ; then
-      rm ${1}/bootstrap-pkgng
-      chroot ${1} pc-extractoverlay server --sysinit
+      rm -f "${jaildir}/bootstrap-pkgng"
+      rm -f "${jaildir}/pluginjail-packages"
+      chroot ${jaildir} pc-extractoverlay server --sysinit
       return 0
-    fi 
+    fi
   fi
+
   echo "Failed boot-strapping PKGNG, most likely cause is internet connection failure."
-  rm ${1}/bootstrap-pkgng
+  rm -f "${jaildir}/bootstrap-pkgng"
+  rm -f "${jaildir}/pluginjail-packages"
   return 1
 }
+
+ipv4_configured()
+{
+   local iface="${1}"
+   local jid="${2}"
+   local jexec=
+
+   if [ -n "${jid}" ] ; then
+      jexec="jexec ${jid}"
+   fi
+
+   ${jexec} ifconfig "${iface}" | grep -qw inet 2>/dev/null
+   return $?
+}
+
+ipv4_address_configured()
+{
+   local iface="${1}"
+   local addr="${2}"
+   local jid="${3}"
+   local jexec= 
+
+   addr="$(echo ${addr}|cut -f1 -d'/')"
+
+   if [ -n "${jid}" ] ; then
+      jexec="jexec ${jid}"
+   fi
+
+   ${jexec} ifconfig "${iface}" | \
+      grep -w inet | \
+      awk '{ print $2 }' | \
+      grep -Ew "^${addr}" >/dev/null 2>&1
+   return $?
+}
+
+ipv6_configured()
+{
+   local iface="${1}"
+   local jid="${2}"
+   local jexec=
+
+   if [ -n "${jid}" ] ; then
+      jexec="jexec ${jid}"
+   fi
+
+   ${jexec} ifconfig "${iface}" | grep -qw inet6 2>/dev/null
+   return $?
+}
+
+ipv6_address_configured()
+{
+   local iface="${1}"
+   local addr="${2}"
+   local jid="${3}"
+   local jexec= 
+
+   addr="$(echo ${addr}|cut -f1 -d'/')"
+
+   if [ -n "${jid}" ] ; then
+      jexec="jexec ${jid}"
+   fi
+
+   ${jexec} ifconfig "${iface}" | \
+      grep -w inet6 | \
+      awk '{ print $2 }' | \
+      grep -Ew "^${addr}" >/dev/null 2>&1
+   return $?
+}
+
+get_ipfw_nat_instance()
+{
+   local iface="${1}"
+   local res=1
+
+   if [ -z "${iface}" ] ; then
+      local instance="`ipfw list|egrep '[0-9]+ nat'|awk '{ print $3 }'|tail -1`"
+      if [ -z "${instance}" ] ; then
+         instance="100"
+      else		  
+         : $(( instance += 100 )) 
+      fi
+      echo "${instance}"
+      return 0
+   fi
+
+   for ni in `ipfw list|egrep '[0-9]+ nat'|awk '{ print $3 }'`
+   do
+      ipfw nat "${ni}" show config|egrep -qw "${iface}"
+      if [ "$?" = "0" ] ; then
+         echo "${ni}"
+         res=0
+         break
+      fi
+   done
+
+   return ${res}
+}
+
+get_ipfw_nat_priority()
+{
+   local iface="${1}"
+   local res=1
+
+   if [ -z "${iface}" ] ; then
+      local priority="`ipfw list|egrep '[0-9]+ nat'|awk '{ print $1 }'|tail -1`"
+      if [ -z "${priority}" ] ; then
+         priority=2000
+      fi
+      printf "%05d\n" "${priority}"
+      return 0
+   fi
+
+   local IFS='
+'
+   for rule in `ipfw list|egrep '[0-9]+ nat'`
+   do
+      local priority="`echo "${rule}"|awk '{ print $1 }'`"
+      local ni="`echo "${rule}"|awk '{ print $3 }'`"
+
+      ipfw nat "${ni}" show config|egrep -qw "${iface}"
+      if [ "$?" = "0" ] ; then
+         echo "${priority}"
+         res=0
+         break
+      fi
+   done
+
+   return ${res}
+}
+

Modified: pcbsd/current/src-sh/warden/scripts/backend/importjail.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/importjail.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/importjail.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -9,9 +9,25 @@
 . ${PROGDIR}/scripts/backend/functions.sh
 
 IFILE="$1"
-IP="${2}"
-HOST="${3}"
+HOST="${2}"
+IP4="${3}"
+IP6="${4}"
 
+if [ "${IP4}" != "OFF" ] ; then
+  get_ip_and_netmask "${IP4}"
+  IP4="${JIP}"
+  MASK4="${JMASK}"
+fi
+
+if [ "${IP6}" != "OFF" ] ; then
+  get_ip_and_netmask "${IP6}"
+  IP6="${JIP}"
+  MASK6="${JMASK}"
+fi
+
+JAILNAME="${HOST}"
+JAILDIR="${JDIR}/${JAILNAME}"
+
 if [ -z "${IFILE}" -o ! -e "${IFILE}" ]
 then
   echo "ERROR: No jail specified or invalid file!"
@@ -24,16 +40,29 @@
   exit 5
 fi
 
-if [ "${IP}" != "OFF" ]
+if [ "${IP4}" != "OFF" ]
 then
-  # Make sure we don't have a jail with this new IP already
-  if [ -e "${JDIR}/${IP}" ]
-  then
-    echo "ERROR: A Jail exists with IP: $IP"
-    exit 5
-  fi
-  set_warden_metadir
+  for i in `ls -d ${JDIR}/.*.meta 2>/dev/null`
+  do
+    if [ "`cat ${i}/ipv4 2>/dev/null`" = "${IP4}/${MASK4}" ] ; then
+      echo "ERROR: A Jail exists with IP: ${IP4}"
+      exit 5
+    fi
+  done
 fi
+if [ "${IP6}" != "OFF" ]
+then
+  for i in `ls -d ${JDIR}/.*.meta 2>/dev/null`
+  do
+    _ipv6=`cat ${i}/ipv6 2>/dev/null|tr a-z A-Z`
+    _nipv6="`echo ${IP6}|tr a-z A-Z`/${MASK6}"
+    if [ "${ipv6}" = "${_nipv6}" ] ; then
+      echo "ERROR: A Jail exists with IP: ${IP6}"
+      exit 5
+    fi
+  done
+fi
+set_warden_metadir
 
 # Lets start importing the jail now
 ######################################################################
@@ -65,7 +94,8 @@
 VER=""
 OS=""
 FILES=""
-FIP=""
+FIP4=""
+FIP6=""
 FHOST=""
 
 HEADER=`ls *.header`
@@ -90,11 +120,17 @@
     FILES="`echo $line | cut -d ' ' -f 2-10`"
   fi
   
-  # Check for the built in IP
-  echo "$line" | grep -q "IP:"
+  # Check for the built in IP4
+  echo "$line" | grep -q "IP4:"
   if [ $? -eq 0 ]; then
-    FIP="`echo $line | cut -d ' ' -f 2-10`"
+    FIP4="`echo $line | cut -d ' ' -f 2-10`"
   fi
+
+  # Check for the built in IP6
+  echo "$line" | grep -q "IP6:"
+  if [ $? -eq 0 ]; then
+    FIP6="`echo $line | cut -d ' ' -f 2-10`"
+  fi
   
   # Check for the built in HOST
   echo "$line" | grep -q "HOST:"
@@ -120,35 +156,77 @@
     echo "This jail may not work...Importing anyway..."
 fi
 
+if [ "${IP4}" = "OFF" ]
+then
+  for i in `ls -d ${JDIR}/.*.meta 2>/dev/null`
+  do
+    if [ -n "${FIP4}" ] ; then
+      if [ "`cat ${i}/ipv4`" = "${FIP4}" ] ; then
+        echo "ERROR: A Jail already exists with IP: $FIP4"
+        rm -rf tmp.$$ 2>/dev/null
+        exit 7
+      fi
+    fi
+  done
+ 
+  # The user didn't specify a new IPv4 address, so use the built in one
+  get_ip_and_netmask "${FIP4}"
+  IP4="${JIP}"
+  MASK4="${JMASK}"
+fi
 
-if [ "${IP}" = "OFF" ]
+if [ "${IP6}" = "OFF" ]
 then
-  # Make sure we don't have a jail with this new IP already
-  if [ -e "${JDIR}/${FIP}" ]
-  then
-    echo "ERROR: A Jail already exists with IP: $FIP"
-    rm -rf tmp.$$ 2>/dev/null
-    exit 7
-  fi
+  for i in `ls -d ${JDIR}/.*.meta 2>/dev/null`
+  do
+    if [ -n "${FIP6}" ] ; then
+
+      _ipv6=`cat ${i}/ipv6 2>/dev/null|tr a-z A-Z`
+      _nipv6=`echo ${FIP6}|tr a-z A-Z`
+      if [ "${ipv6}" = "${_nipv6}" ] ; then
+        echo "ERROR: A Jail already exists with IP: $FIP6"
+        rm -rf tmp.$$ 2>/dev/null
+        exit 7
+      fi
+    fi
+  done
  
-  # The user didn't specify a new IP, so use the built in one
-  IP="${FIP}"
+  # The user didn't specify a new IPv6 address, so use the built in one
+  get_ip_and_netmask "${FIP6}"
+  IP6="${JIP}"
+  MASK6="${JMASK}"
 fi
 
 SKIP="`awk '/^___WARDEN_START___/ { print NR + 1; exit 0; }' ${IFILE}`"
-echo "Importing ${IFILE} with IP: ${IP}..."
+if [ -n "${IP4}" ] ; then
+  echo "Importing ${IFILE} with IP: ${IP4}..."
+elif [ -n "${IP6}" ] ; then
+  echo "Importing ${IFILE} with IP: ${IP6}..."
+fi
 
 # Make the new directory
-JAILDIR="${JDIR}/${IP}"
+JAILDIR="${JDIR}/${HOST}"
 isDirZFS "${JDIR}"
 if [ $? -eq 0 ] ; then
   # Create ZFS mount
   tank=`getZFSTank "$JDIR"`
-  zfs create -p ${tank}${JAILDIR}
+  rp=`getZFSRelativePath "${JAILDIR}"`
+  zfs create -p ${tank}${rp}
 else
   mkdir -p "${JAILDIR}"
 fi
 
+# Get next unique ID
+META_ID=0
+for i in `ls -d ${JDIR}/.*.meta 2>/dev/null`
+do
+  id=`cat ${i}/id`
+  if [ "${id}" -gt "${META_ID}" ] ; then
+    META_ID="${id}"
+  fi
+done
+: $(( META_ID += 1 ))
+
 # Create the meta-dir
 set_warden_metadir
 mkdir ${JMETADIR}
@@ -156,14 +234,22 @@
 # Copy over extra jail flags
 cp tmp.$$/jail-* ${JMETADIR}/ 2>/dev/null
 
+# give new jail an id
+echo "${META_ID}" > ${JMETADIR}/id
+
 # Cleanup tmp meta-dir
 rm -rf tmp.$$ 2>/dev/null
 
 # Extract the jail contents
-tail +${SKIP} ${IFILE} | tar xpf - -C "${JDIR}/${IP}" 2>/dev/null
+tail +${SKIP} ${IFILE} | tar xpf - -C "${JAILDIR}" 2>/dev/null
 
 # Make sure we have an IP address saved
-echo "${IP}" >"${JMETADIR}/ip"
+if [ -n "${IP4}" ] ; then
+  echo "${IP4}/${MASK4}" >"${JMETADIR}/ipv4"
+fi
+if [ -n "${IP6}" ] ; then
+  echo "${IP6}/${MASK6}" >"${JMETADIR}/ipv6"
+fi
 
 # Save the jail flags
 if [ -n "$JFLAGS" ] ; then
@@ -180,13 +266,14 @@
   echo "${HOST}" >"${JMETADIR}/host"
 
   # Change the hostname in rc.conf
-  if [ -e "${JDIR}/${IP}/etc/rc.conf" ] ; then
-    cat "${JDIR}/${IP}/etc/rc.conf" | grep -v "hostname=" >${JDIR}/${IP}/.rc.conf
-    echo "hostname=\"${HOST}\"" >>"${JDIR}/${IP}/.rc.conf"
-    mv "${JDIR}/${IP}/.rc.conf" "${JDIR}/${IP}/etc/rc.conf"
+  if [ -e "${JAILDIR}/etc/rc.conf" ] ; then
+    cat "${JAILDIR}/etc/rc.conf" | grep -v "hostname=" >${JAILDIR}/.rc.conf
+    echo "hostname=\"${HOST}\"" >>"${JAILDIR}/.rc.conf"
+    mv "${JAILDIR}/.rc.conf" "${JAILDIR}/etc/rc.conf"
   fi
 
 # Setup /etc/hosts now
+cat<<__EOF__>"${JAILDIR}/etc/hosts"
 echo "# : src/etc/hosts,v 1.16 2003/01/28 21:29:23 dbaker Exp $
 #
 # Host Database
@@ -201,8 +288,15 @@
 #
 ::1                     localhost localhost.localdomain
 127.0.0.1               localhost localhost.localdomain ${HOST}
-${IP}			${HOST}" > "${JDIR}/${IP}/etc/hosts"
+__EOF__
 
+if [ -n "${IP4}" ] ; then
+  echo "${IP4}			${HOST}" >> "${JAILDIR}/etc/hosts"
+fi
+if [ -n "${IP6}" ] ; then
+  echo "${IP6}			${HOST}" >> "${JAILDIR}/etc/hosts"
+fi
+
 # End Hostname setup
 fi
 

Modified: pcbsd/current/src-sh/warden/scripts/backend/listjails.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/listjails.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/listjails.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -15,27 +15,117 @@
   exit 4
 fi
 
+line()
+{
+  len="${1}"
 
+  i=0 
+  while [ "${i}" -lt "${len}" ] ; do
+    i=`expr ${i} + 1`
+    echo -n '-' 
+  done
+  echo 
+}
+
+lineline=0
+VERBOSE="NO"
+JAILS=
+while [ "$#" -gt "0" ] ; do
+  case "$1" in
+    -v) VERBOSE="YES" ;; 
+     *) JAILS="${JAILS} .$1.meta" ;;
+  esac
+  shift 
+done
+
+if [ "${VERBOSE}" != "YES" ] ; then
 # Prints a listing of the available jails
-echo "IP			HOST		AUTOSTART	STATUS     TYPE
---------------------------------------------------------------------------------"
+  printf "%-24s%-12s%-12s%-12s\n" ID AUTOSTART STATUS TYPE
+  line "75"
+fi
 
 cd ${JDIR}
+if [ -z "${JAILS}" ] ; then
+  JAILS=`ls -d .*.meta 2>/dev/null`
+fi
 
-for i in `ls -d .*.meta 2>/dev/null`
+for i in ${JAILS}
 do
-  HOST="<unknown>"
   AUTO="Disabled" 
   STATUS="<unknown>"
 
-  if [ ! -e "${i}/ip" ] ; then continue ; fi
+  if [ ! -e "${i}/id" ] ; then 
+     # Check if its an old-style jail
+     if [ ! -e "${i}/ip" ] ; then
+     	continue
+     fi
+     # This is an old style jail, lets convert it
+     cp ${i}/ip ${i}/ipv4
 
-  # Get the HostName
-  if [ -e "${i}/host" ]
-  then
-    HOST="`cat ${i}/host`"
+     # Get next unique ID
+     META_ID=0
+     for iDir in `ls -d ${JDIR}/.*.meta 2>/dev/null`
+     do
+       if [ ! -e "${iDir}/id" ] ; then continue ; fi
+       id=`cat ${iDir}/id`
+       if [ "${id}" -gt "${META_ID}" ] ; then
+          META_ID="${id}"
+       fi
+     done
+     : $(( META_ID += 1 ))
+     echo "$META_ID" > ${i}/id
+
   fi
 
+  ID="`cat ${i}/id 2>/dev/null`"
+  HOST="`cat ${i}/host 2>/dev/null`"
+
+  #
+  # IPv4 networking
+  # 
+  IPS4=
+  IP4=`cat ${i}/ipv4 2>/dev/null`
+  if [ -e "${i}/alias-ipv4" ] ; then
+    while read line
+    do
+      IPS4="${IPS4} ${line}" 
+    done < "${i}/alias-ipv4"
+  fi
+
+  BRIDGEIPS4=
+  BRIDGEIP4=`cat ${i}/bridge-ipv4 2>/dev/null`
+  if [ -e "${i}/alias-bridge-ipv4" ] ; then
+    while read line
+    do
+      BRIDGEIPS4="${BRIDGEIPS4} ${line}" 
+    done < "${i}/alias-bridge-ipv4"
+  fi
+
+  GATEWAY4=`cat ${i}/defaultrouter-ipv4 2>/dev/null`
+
+  #
+  # IPv6 networking
+  # 
+  IPS6=
+  IP6=`cat ${i}/ipv6 2>/dev/null`
+  if [ -e "${i}/alias-ipv6" ] ; then
+    while read line
+    do
+      IPS6="${IPS6} ${line}" 
+    done < "${i}/alias-ipv6"
+  fi
+
+  BRIDGEIPS6=
+  BRIDGEIP6=`cat ${i}/bridge-ipv6 2>/dev/null`
+  if [ -e "${i}/alias-bridge-ipv6" ] ; then
+    while read line
+    do
+      BRIDGEIPS6="${BRIDGEIPS6} ${line}" 
+    done < "${i}/alias-bridge-ipv6"
+  fi
+
+  GATEWAY6=`cat ${i}/defaultrouter-ipv6 2>/dev/null`
+
   # Check if we are autostarting this jail
   if [ -e "${i}/autostart" ] ; then
     AUTO="Enabled"
@@ -44,15 +134,17 @@
   # Figure out the type of jail
   if [ -e "${i}/jail-portjail" ] ; then
     TYPE="portjail"
+  elif [ -e "${i}/jail-pluginjail" ] ; then
+    TYPE="pluginjail"
   elif [ -e "${i}/jail-linux" ] ; then
     TYPE="linuxjail"
   else
     TYPE="standard"
   fi
 
-  jIP="`cat ${i}/ip`"
+  JAILNAME=`echo ${i}|sed 's|.meta$||'|sed 's|^.||'`
 
-  ${PROGDIR}/scripts/backend/checkstatus.sh ${jIP} 2>/dev/null
+  ${PROGDIR}/scripts/backend/checkstatus.sh ${JAILNAME} 2>/dev/null
   if [ "$?" = "0" ]
   then
     STATUS="Running"
@@ -60,14 +152,29 @@
     STATUS="Stopped"
   fi
 
-  # Pad the variables a bit
-  IP=`echo "${jIP}                 " | cut -c 1-23`
-  AUTO=`echo "${AUTO}              " | cut -c 1-15`
-  STATUS=`echo "${STATUS}          " | cut -c 1-10`
-  HOST=`echo "${HOST}              " | cut -c 1-15`
-  TYPE=`echo "${TYPE}              " | cut -c 1-10`
-  
+  if [ "${VERBOSE}" = "YES" ] ; then
+    cat<<__EOF__ 
 
-  echo -e "${IP} ${HOST} ${AUTO} ${STATUS} ${TYPE}"
+id: ${ID}
+host: ${HOST}
+ipv4: ${IP4}
+alias-ipv4: ${IPS4}
+bridge-ipv4: ${BRIDGEIP4}
+alias-bridge-ipv4: ${BRIDGEIPS4}
+defaultrouter-ipv4: ${GATEWAY4}
+ipv6: ${IP6}
+alias-ipv6: ${IPS6}
+bridge-ipv6: ${BRIDGEIP6}
+alias-bridge-ipv6: ${BRIDGEIPS6}
+defaultrouter-ipv6: ${GATEWAY6}
+autostart: ${AUTO}
+status: ${STATUS}
+type: ${TYPE}
+
+__EOF__
+
+  else
+    printf "%-24s%-12s%-12s%-12s\n" ${JAILNAME} ${AUTO} ${STATUS} ${TYPE}
+  fi
 done
 

Index: pcbsd/current/src-sh/warden/scripts/backend/listpbis.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/listpbis.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/listpbis.sh	2013-04-16 16:18:23 UTC (rev 22317)

Property changes on: pcbsd/current/src-sh/warden/scripts/backend/listpbis.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
Modified: pcbsd/current/src-sh/warden/scripts/backend/listpkgs.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/listpkgs.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/listpkgs.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -8,9 +8,9 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-IP="$1"
+JAILNAME="$1"
 
-if [ -z "${IP}" ]
+if [ -z "${JAILNAME}" ]
 then
   echo "ERROR: No jail specified to view packages in!"
   exit 5
@@ -22,13 +22,20 @@
   exit 5
 fi
 
-if [ ! -d "${JDIR}/${IP}" ]
+JAILDIR="${JDIR}/${JAILNAME}"
+
+if [ ! -d "${JAILDIR}" ]
 then
-  echo "ERROR: No jail located at $JDIR/$IP"
+  echo "ERROR: No jail located at ${JAILDIR}"
   exit 5
 fi
 
-
 # Done with error checking, now lets get a package listing
 ###################################################################
-chroot "${JDIR}/${IP}" pkg_info
+
+# Check if we are using pkgng or old-style
+if [ -e "${JAILDIR}/usr/local/sbin/pkg-static" ] ; then
+  chroot "${JAILDIR}" pkg info
+else
+  chroot "${JAILDIR}" pkg_info
+fi

Modified: pcbsd/current/src-sh/warden/scripts/backend/setupusers.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/setupusers.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/setupusers.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -1,6 +1,6 @@
 #!/bin/sh
 # Script to setup the initial rootpw on a jail
-# Args $1 = IP
+# Args $1 = JAILDIR
 # Args $2 = rootPW
 ######################################################################
 
@@ -10,15 +10,14 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-IP="$1"
+JAILNAME="$1"
 ROOTPW="${2}"
 
 export ROOTPW
 
-
-if [ -z "$IP" ]
+if [ -z "${JAILNAME}" ]
 then
-  echo "ERROR: You must specify an IP of a jail"
+  echo "ERROR: You must specify a jail"
   exit 5
 fi
 
@@ -28,9 +27,11 @@
   exit 5
 fi
 
-if [ ! -d "${JDIR}/${IP}" ]
+JAILDIR="${JDIR}/${JAILNAME}"
+
+if [ ! -d "${JAILDIR}" ]
 then
-  echo "ERROR: No jail located at $JDIR/$IP"
+  echo "ERROR: No jail located at ${JAILDIR}"
   exit 5
 fi
 
@@ -52,25 +53,25 @@
 
   echo '#!/bin/bash
 echo -e "${ROOTPW}\n${ROOTPW}" | passwd root
-' > "${JDIR}/${IP}/.chpass.sh"
+' > "${JAILDIR}/.chpass.sh"
 
 else
 
   echo '#!/bin/sh
 echo "${ROOTPW}" | pw usermod root -h 0
-' > "${JDIR}/${IP}/.chpass.sh"
+' > "${JAILDIR}/.chpass.sh"
 
 fi
 
-chmod 755 "${JDIR}/${IP}/.chpass.sh"
-chroot "${JDIR}/${IP}" /.chpass.sh
+chmod 755 "${JAILDIR}/.chpass.sh"
+chroot "${JAILDIR}" /.chpass.sh
 if [ $? -eq 0 ] ; then
   echo -e "Success!"
 else
   echo -e "FAILED!"
 fi
 
-rm "${JDIR}/${IP}/.chpass.sh"
+rm "${JAILDIR}/.chpass.sh"
 
 
 unset ROOTPW

Modified: pcbsd/current/src-sh/warden/scripts/backend/startjail.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/startjail.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/startjail.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -1,6 +1,6 @@
-#!/bin/sh
+#/bin/sh
 # Script to startup a jail
-# Args $1 = jail-dir
+# Args $1 = jail-name
 #######################################################################
 
 # Source our functions
@@ -9,9 +9,9 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-IP="${1}"
+JAILNAME="${1}"
 
-if [ -z "${IP}" ]
+if [ -z "${JAILNAME}" ]
 then
   echo "ERROR: No jail specified to start!"
   exit 5
@@ -23,27 +23,75 @@
   exit 5
 fi
 
-if [ ! -d "${JDIR}/${IP}" ]
+JAILDIR="${JDIR}/${JAILNAME}"
+
+if [ ! -d "${JAILDIR}" ]
 then
-  echo "ERROR: No jail located at $JDIR/$IP"
+  echo "ERROR: No jail located at ${JAILDIR}"
   exit 5
 fi
 
-# Check if we have a valid NIC
-ifconfig $NIC 2>/dev/null >/dev/null
-if [ $? -ne 0 ] ; then
-   echo "ERROR: Invalid network interface specified: $NIC"
-   exit 6
-fi
-
 # Make sure the jail is NOT already running
-jls | grep ${JDIR}/${IP}$ >/dev/null 2>/dev/null
+jls | grep ${JAILDIR}$ >/dev/null 2>/dev/null
 if [ "$?" = "0" ]
 then
   echo "ERROR: Jail appears to be running already!"
   exit 6
 fi
 
+IFACE=
+DEFAULT=0
+
+# Make sure jail uses special interface if specified
+if [ -e "${JMETADIR}/iface" ] ; then
+  IFACE=`cat "${JMETADIR}/iface"`
+fi
+if [ -z "${IFACE}" ] ; then
+   IFACE=`get_default_interface`
+   DEFAULT=1
+fi
+if [ -z "${IFACE}" ] ; then
+  echo "ERROR: no interface specified and a default doesn't exist!"
+  exit 6
+fi
+
+MTU=`ifconfig ${IFACE} | head -1 | sed -E 's/.*mtu ([0-9]+)/\1/g'`
+
+GATEWAY4=
+if [ -e "${JMETADIR}/defaultrouter-ipv4" ] ; then
+  GATEWAY4=`cat "${JMETADIR}/defaultrouter-ipv4"`
+fi
+GATEWAY6=
+if [ -e "${JMETADIR}/defaultrouter-ipv6" ] ; then
+  GATEWAY6=`cat "${JMETADIR}/defaultrouter-ipv6"`
+fi
+
+BRIDGEIP4=
+if [ -e "${JMETADIR}/bridge-ipv4" ] ; then
+  BRIDGEIP4=`cat "${JMETADIR}/bridge-ipv4"`
+fi
+
+BRIDGEIPS4=
+if [ -e "${JMETADIR}/alias-bridge-ipv4" ] ; then
+  while read line
+  do
+    BRIDGEIPS4="${BRIDGEIPS4} $line" 
+  done < ${JMETADIR}/alias-bridge-ipv4
+fi
+
+BRIDGEIP6=
+if [ -e "${JMETADIR}/bridge-ipv6" ] ; then
+  BRIDGEIP6=`cat "${JMETADIR}/bridge-ipv6"`
+fi
+
+BRIDGEIPS6=
+if [ -e "${JMETADIR}/alias-bridge-ipv6" ] ; then
+  while read line
+  do
+    BRIDGEIPS6="${BRIDGEIPS6} $line" 
+  done < ${JMETADIR}/alias-bridge-ipv6
+fi
+
 set_warden_metadir
 
 if [ -e "${JMETADIR}/jail-linux" ] ; then
@@ -52,68 +100,144 @@
 
 HOST="`cat ${JMETADIR}/host`"
 
-if is_symlinked_mountpoint ${JDIR}/${IP}/dev; then
-   echo "${JDIR}/${IP}/dev has symlink as parent, not mounting"
+if is_symlinked_mountpoint ${JAILDIR}/dev; then
+   echo "${JAILDIR}/dev has symlink as parent, not mounting"
 else
-   mount -t devfs devfs "${JDIR}/${IP}/dev"
+   mount -t devfs devfs "${JAILDIR}/dev"
 fi
 
 if [ "$LINUXJAIL" = "YES" ] ; then
   # Linux Jail
-  if is_symlinked_mountpoint ${JDIR}/${IP}/proc; then
-     echo "${JDIR}/${IP}/proc has symlink as parent, not mounting"
+  if is_symlinked_mountpoint ${JAILDIR}/proc; then
+     echo "${JAILDIR}/proc has symlink as parent, not mounting"
   else
-     mount -t linprocfs linproc "${JDIR}/${IP}/proc"
+     mount -t linprocfs linproc "${JAILDIR}/proc"
   fi
-  if is_symlinked_mountpoint ${JDIR}/${IP}/dev/fd; then
-     echo "${JDIR}/${IP}/dev/fd has symlink as parent, not mounting"
+  if is_symlinked_mountpoint ${JAILDIR}/dev/fd; then
+     echo "${JAILDIR}/dev/fd has symlink as parent, not mounting"
   else
-     mount -t fdescfs null "${JDIR}/${IP}/dev/fd"
+     mount -t fdescfs null "${JAILDIR}/dev/fd"
   fi
-  if is_symlinked_mountpoint ${JDIR}/${IP}/sys; then
-     echo "${JDIR}/${IP}/sys has symlink as parent, not mounting"
+  if is_symlinked_mountpoint ${JAILDIR}/sys; then
+     echo "${JAILDIR}/sys has symlink as parent, not mounting"
   else
-     mount -t linsysfs linsys "${JDIR}/${IP}/sys"
+     mount -t linsysfs linsys "${JAILDIR}/sys"
   fi
-  if [ -e "${JDIR}/${IP}/lib/init/rw" ] ; then
-    if is_symlinked_mountpoint ${JDIR}/${IP}/lib/init/rw; then
-       echo "${JDIR}/${IP}/lib/init/rw has symlink as parent, not mounting"
+  if [ -e "${JAILDIR}/lib/init/rw" ] ; then
+    if is_symlinked_mountpoint ${JAILDIR}/lib/init/rw; then
+       echo "${JAILDIR}/lib/init/rw has symlink as parent, not mounting"
     else
-       mount -t tmpfs tmpfs "${JDIR}/${IP}/lib/init/rw"
+       mount -t tmpfs tmpfs "${JAILDIR}/lib/init/rw"
     fi
   fi
 else
   # FreeBSD Jail
-  if is_symlinked_mountpoint ${JDIR}/${IP}/proc; then
-     echo "${JDIR}/${IP}/proc has symlink as parent, not mounting"
+  if is_symlinked_mountpoint ${JAILDIR}/proc; then
+     echo "${JAILDIR}/proc has symlink as parent, not mounting"
   else
-     mount -t procfs proc "${JDIR}/${IP}/proc"
+     mount -t procfs proc "${JAILDIR}/proc"
   fi
 
-  if [ -e "${JMETADIR}/jail-portjail" ] ; then mountjailxfs ${IP} ; fi
+  if [ -e "${JMETADIR}/jail-portjail" ] ; then mountjailxfs ${JAILNAME} ; fi
 fi
 
-IPS="${IP}"
-if [ -e "${JMETADIR}/ip-extra" ] ; then
+IP4=
+if [ -e "${JMETADIR}/ipv4" ] ; then
+  IP4=`cat "${JMETADIR}/ipv4"`
+fi
+
+IPS4=
+if [ -e "${JMETADIR}/alias-ipv4" ] ; then
   while read line
   do
-    IPS="${IPS} $line" 
-  done < ${JMETADIR}/ip-extra
+    IPS4="${IPS4} $line" 
+  done < ${JMETADIR}/alias-ipv4
 fi
 
-# Setup the IPs for this jail
-for _ip in $IPS
-do
-  isV6 "${_ip}"
-  if [ $? -eq 0 ] ; then
-    ifconfig $NIC inet6 alias ${_ip}
-    _ipflags="${_ipflags} ip6.addr=${_ip}"
-  else
-    ifconfig $NIC inet alias ${_ip}/32
-    _ipflags="${_ipflags} ip4.addr=${_ip}"
-  fi
-done
+IP6=
+if [ -e "${JMETADIR}/ipv6" ] ; then
+  IP6=`cat "${JMETADIR}/ipv6"`
+fi
 
+IPS6=
+if [ -e "${JMETADIR}/alias-ipv6" ] ; then
+  while read line
+  do
+    IPS6="${IPS6} $line" 
+  done < ${JMETADIR}/alias-ipv6
+fi
+
+BRIDGE=
+
+# See if we need to create a new bridge, or use an existing one
+_bridges=`get_bridge_interfaces`
+if [ -n "${_bridges}" ] ; then
+   for _bridge in ${_bridges}
+   do
+      _members=`get_bridge_members ${_bridge}`
+      for _member in ${_members}
+      do 
+         if [ "${_member}" = "${IFACE}" ] ; then
+            BRIDGE=${_bridge}
+            break
+         fi
+      done
+      if [ -n "${BRIDGE}" ] ; then
+         break
+      fi
+   done 
+fi
+
+if [ -z "${BRIDGE}" ] ; then
+   BRIDGE=`ifconfig bridge create mtu ${MTU}`
+fi
+if [ -n "${IFACE}" ] ; then
+   if ! is_bridge_member "${BRIDGE}" "${IFACE}" ; then
+      ifconfig ${BRIDGE} addm ${IFACE}
+   fi
+fi
+
+# create epair for vimage jail
+EPAIRA=`ifconfig epair create mtu ${MTU}`
+ifconfig ${EPAIRA} up
+
+EPAIRB=`echo ${EPAIRA}|sed -E "s/([0-9])a$/\1b/g"`
+ifconfig ${BRIDGE} addm ${EPAIRA} up
+
+if [ -n "${BRIDGEIP4}" ] ; then
+   if ! ipv4_configured "${BRIDGE}" ; then
+      ifconfig ${BRIDGE} inet "${BRIDGEIP4}"
+
+   elif ! ipv4_address_configured "${BRIDGE}" "${BRIDGEIP4}" ; then
+      ifconfig ${BRIDGE} inet alias "${BRIDGEIP4}"
+   fi
+fi
+if [ -n "${BRIDGEIPS4}" ] ; then
+   for _ip in ${BRIDGEIPS4}
+   do
+      if ! ipv4_address_configured "${BRIDGE}" "${_ip}" ; then
+         ifconfig ${BRIDGE} inet alias "${_ip}"
+      fi 
+   done
+fi
+
+if [ -n "${BRIDGEIP6}" ] ; then
+   if ! ipv6_configured "${BRIDGE}" ; then
+      ifconfig ${BRIDGE} inet6 "${BRIDGEIP6}"
+
+   elif ! ipv6_address_configured "${BRIDGE}" "${BRIDGEIP6}" ; then
+      ifconfig ${BRIDGE} inet6 alias "${BRIDGEIP6}"
+   fi
+fi
+if [ -n "${BRIDGEIPS6}" ] ; then
+   for _ip in ${BRIDGEIPS6}
+   do
+      if ! ipv6_address_configured "${BRIDGE}" "${_ip}" ; then
+         ifconfig ${BRIDGE} inet6 alias "${_ip}"
+      fi
+   done
+fi
+
 jFlags=""
 # Grab any additional jail flags
 if [ -e "${JMETADIR}/jail-flags" ] ; then
@@ -121,24 +245,128 @@
 fi
 
 # Start the jail now
-echo "jail -c path=${JDIR}/${IP} host.hostname=${HOST} ${_ipflags} ${jFlags} persist"
-jail -c path=${JDIR}/${IP} host.hostname=${HOST} ${_ipflags} ${jFlags} persist
+echo "jail -c path=${JAILDIR} host.hostname=${HOST} ${jFlags} persist vnet"
+jail -c path=${JAILDIR} host.hostname=${HOST} ${jFlags} persist vnet
 if [ $? -ne 0 ] ; then
    echo "ERROR: Failed starting jail with above command..."
+   umountjailxfs "${JAILNAME}"
+   exit 1
+fi
 
-   # Do cleanup now
-   isV6 "${_ip}"
-   if [ $? -eq 0 ] ; then
-      ifconfig $NIC inet6 ${_ip} delete
+JID="`jls | grep ${JAILDIR}$ | tr -s " " | cut -d " " -f 2`"
+
+# Move epairb into jail
+ifconfig ${EPAIRB} vnet ${JID}
+
+# Configure the IPv4 addresses
+if [ -n "${IP4}" ] ; then
+   jexec ${JID} ifconfig ${EPAIRB} inet "${IP4}"
+fi
+for ip4 in ${IPS4}
+do
+   ipv4_configured ${EPAIRB} ${JID}
+   if [ "$?" = "0" ] ; then
+      if ! ipv4_address_configured "${EPAIRB}" "${ip4}" "${JID}" ; then
+         jexec ${JID} ifconfig ${EPAIRB} inet alias ${ip4}
+      fi
    else
-      ifconfig $NIC inet -alias ${_ip}
+      jexec ${JID} ifconfig ${EPAIRB} inet ${ip4}
    fi
-   umountjailxfs "${IP}"
-   exit 1
+done
+
+# Configure the IPv6 addresses
+if [ -n "${IP6}" ] ; then
+   jexec ${JID} ifconfig ${EPAIRB} inet6 "${IP4}"
 fi
+for ip6 in ${IPS6}
+do
+   ipv6_configured ${EPAIRB} ${JID}
+   if [ "$?" = "0" ] ; then
+      if ! ipv6_address_configured "${EPAIRB}" "${ip6}" "${JID}" ; then
+         jexec ${JID} ifconfig ${EPAIRB} inet6 alias ${ip6}
+      fi
+   else
+      jexec ${JID} ifconfig ${EPAIRB} inet6 ${ip6}
+   fi
+done
 
-JID="`jls | grep ${JDIR}/${IP}$ | tr -s " " | cut -d " " -f 2`"
+#
+# Configure default IPv4 gateway 
+#
+if [ -n "${GATEWAY4}" ] ; then
+   jexec ${JID} route add -inet default ${GATEWAY4}
 
+#
+# No defaultrouter configured for IPv4, so if bridge IP address was
+# configured, we set the default router to that IP.
+#
+elif [ -n "${BRIDGEIP4}" ] ; then
+   get_ip_and_netmask "${BRIDGEIP4}"
+   jexec ${JID} route add -inet default ${JIP}
+fi
+
+#
+# Configure default IPv6 gateway
+#
+if [ -n "${GATEWAY6}" ] ; then
+   jexec ${JID} route add -inet6 default ${GATEWAY6}
+
+#
+# No defaultrouter configured for IPv6, so if bridge IP address was
+# configured, we set the default router to that IP.
+#
+elif [ -n "${BRIDGEIP6}" ] ; then
+   get_ip_and_netmask "${BRIDGEIP6}"
+   jexec ${JID} route add -inet6 default ${JIP}
+fi
+
+#
+# Set ourself to be a jail router with NAT. Don't
+# use PF since it will panic the box when used
+# with VIMAGE.
+#
+ip_forwarding=`sysctl -n net.inet.ip.forwarding`
+if [ "${ip_forwarding}" = "0" ] ; then
+   sysctl net.inet.ip.forwarding=1
+fi
+
+ip6_forwarding=`sysctl -n net.inet6.ip6.forwarding`
+if [ "${ip6_forwarding}" = "0" ] ; then
+   sysctl net.inet6.ip6.forwarding=1
+fi
+
+firewall_enable=`egrep '^firewall_enable' /etc/rc.conf|cut -f2 -d'='|sed 's|"||g'`
+firewall_type=`egrep '^firewall_type' /etc/rc.conf|cut -f2 -d'='|sed 's|"||g'`
+
+if [ "${firewall_enable}" != "YES" -o "${firewall_type}" != "open" ] ; then
+   tmp_rcconf=`mktemp /tmp/.wdn.XXXXXX`
+   egrep -v '^firewall_(enable|type)' /etc/rc.conf >> "${tmp_rcconf}"
+
+   cat<<__EOF__>>"${tmp_rcconf}"
+firewall_enable="YES"
+firewall_type="open"
+__EOF__
+
+   if [ -s "${tmp_rcconf}" ] ; then
+      cp /etc/rc.conf /var/tmp/rc.conf.bak
+      mv "${tmp_rcconf}" /etc/rc.conf
+      if [ "$?" != "0" ] ; then
+         mv /var/tmp/rc.conf.bak /etc/rc.conf
+      fi
+   fi
+   /etc/rc.d/ipfw forcerestart
+fi
+
+instance=`get_ipfw_nat_instance "${IFACE}"`
+if [ -z "${instance}" ] ; then
+echo "NAT IS NULL"
+   priority=`get_ipfw_nat_priority`
+   instance=`get_ipfw_nat_instance`
+
+   ipfw "${priority}" add nat "${instance}" all from any to any
+   ipfw nat "${instance}" config if "${IFACE}" reset
+fi
+
 if [ "$LINUXJAIL" = "YES" ] ; then
   # If we have a custom start script
   if [ -e "${JMETADIR}/jail-start" ] ; then
@@ -147,9 +375,9 @@
     jexec ${JID} ${sCmd} 2>&1
   else
     # Check for different init styles
-    if [ -e "${JDIR}/${IP}/etc/init.d/rc" ] ; then
+    if [ -e "${JAILDIR}/etc/init.d/rc" ] ; then
       jexec ${JID} /bin/sh /etc/init.d/rc 3 2>&1
-    elif [ -e "${JDIR}/${IP}/etc/rc" ] ; then
+    elif [ -e "${JAILDIR}/etc/rc" ] ; then
       jexec ${JID} /bin/sh /etc/rc 3 2>&1
     fi
   fi
@@ -164,4 +392,3 @@
     jexec ${JID} /bin/sh /etc/rc 2>&1
   fi
 fi
-

Modified: pcbsd/current/src-sh/warden/scripts/backend/stopjail.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/stopjail.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/stopjail.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -1,6 +1,6 @@
-#!/bin/sh
+#!/bin/sh 
 # Script to stop a jail
-# Args $1 = jail-dir
+# Args $1 = jail-name
 #######################################################################
 
 # Source our functions
@@ -9,13 +9,13 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-IP="${1}"
+JAILNAME="${1}"
 if [ "${2}" = "FAST" ]
 then
   FAST="Y"
 fi
 
-if [ -z "${IP}" ]
+if [ -z "${JAILNAME}" ]
 then
   echo "ERROR: No jail specified to delete!"
   exit 5
@@ -27,9 +27,11 @@
   exit 5
 fi
 
-if [ ! -d "${JDIR}/${IP}" ]
+JAILDIR="${JDIR}/${JAILNAME}"
+
+if [ ! -d "${JAILDIR}" ]
 then
-  echo "ERROR: No jail located at $JDIR/$IP"
+  echo "ERROR: No jail located at ${JAILDIR}"
   exit 5
 fi
 
@@ -42,38 +44,15 @@
 echo -e "Stopping the jail...\c"
 
 # Get the JailID for this jail
-JID="`jls | grep ${JDIR}/${IP}$ | tr -s " " | cut -d " " -f 2`"
+JID="`jls | grep ${JAILDIR}$ | tr -s " " | cut -d " " -f 2`"
 
 echo -e ".\c"
 
 # Check if we need umount x mnts
-if [ -e "${JMETADIR}/jail-portjail" ] ; then umountjailxfs ${IP} ; fi
+if [ -e "${JMETADIR}/jail-portjail" ] ; then umountjailxfs ${JAILNAME} ; fi
 
-# Get list of IPs for this jail
-IPS="${IP}"
-if [ -e "${JMETADIR}/ip-extra" ] ; then
-  while read line
-  do
-    IPS="${IPS} $line"
-  done < ${JMETADIR}/ip-extra
-fi
+jail_interfaces_down "${JID}"
 
-# Check if we need to remove the IP aliases from this jail
-for _ip in $IPS
-do 
-  # See if active alias
-  ifconfig $NIC | grep -q "${_ip}"
-  if [ $? -ne 0 ] ; then continue ; fi
-
-  isV6 "${_ip}"
-  if [ $? -eq 0 ] ; then
-    ifconfig $NIC inet6 ${_ip} delete
-  else
-    ifconfig $NIC inet -alias ${_ip}
-  fi
-  echo -e ".\c"
-done
-
 if [ -e "${JMETADIR}/jail-linux" ] ; then LINUXJAIL="YES" ; fi
 
 if [ "$LINUXJAIL" = "YES" ] ; then
@@ -86,11 +65,11 @@
     fi
   else
     # Check for different init styles
-    if [ -e "${JDIR}/${IP}/etc/init.d/rc" ] ; then
+    if [ -e "${JAILDIR}/etc/init.d/rc" ] ; then
       if [ -n "${JID}" ] ; then
         jexec ${JID} /bin/sh /etc/init.d/rc 0 2>&1
       fi
-    elif [ -e "${JDIR}/${IP}/etc/rc" ] ; then
+    elif [ -e "${JAILDIR}/etc/rc" ] ; then
       if [ -n "${JID}" ] ; then
         jexec ${JID} /bin/sh /etc/rc 0 2>&1
       fi
@@ -98,10 +77,10 @@
   fi
   sleep 3
 
-  umount -f ${JDIR}/${IP}/sys 2>/dev/null
-  umount -f ${JDIR}/${IP}/dev/fd 2>/dev/null
-  umount -f ${JDIR}/${IP}/dev 2>/dev/null
-  umount -f ${JDIR}/${IP}/lib/init/rw 2>/dev/null
+  umount -f ${JAILDIR}/sys 2>/dev/null
+  umount -f ${JAILDIR}/dev/fd 2>/dev/null
+  umount -f ${JAILDIR}/dev 2>/dev/null
+  umount -f ${JAILDIR}/lib/init/rw 2>/dev/null
 else
   # If we have a custom stop script
   if [ -e "${JMETADIR}/jail-stop" ] ; then
@@ -118,7 +97,7 @@
   fi
 fi
 
-umount -f ${JDIR}/${IP}/dev >/dev/null 2>/dev/null
+umount -f ${JAILDIR}/dev >/dev/null 2>/dev/null
 
 echo -e ".\c"
 
@@ -134,7 +113,7 @@
 echo -e ".\c"
 
 # Check if we need to unmount the devfs in jail
-mount | grep "${JDIR}/${IP}/dev" >/dev/null 2>/dev/null
+mount | grep "${JAILDIR}/dev" >/dev/null 2>/dev/null
 if [ "$?" = "0" ]
 then
   # Setup a 60 second timer to try and umount devfs, since takes a bit
@@ -145,7 +124,7 @@
    sleep 2
 
    # Try to unmount dev
-   umount -f "${JDIR}/${IP}/dev" 2>/dev/null
+   umount -f "${JAILDIR}/dev" 2>/dev/null
    if [ "$?" = "0" ]
    then
       break
@@ -163,9 +142,9 @@
 fi
 
 # Check if we need to unmount any extra dirs
-mount | grep "${JDIR}/${IP}/proc" >/dev/null 2>/dev/null
+mount | grep "${JAILDIR}/proc" >/dev/null 2>/dev/null
 if [ "$?" = "0" ]; then
-  umount -f "${JDIR}/${IP}/proc"
+  umount -f "${JAILDIR}/proc"
 fi
 
 if [ -e "${JMETADIR}/jail-portjail" ] ; then
@@ -181,5 +160,3 @@
 fi
 
 echo -e "Done"
-
-

Modified: pcbsd/current/src-sh/warden/scripts/backend/zfsclonesnap.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/zfsclonesnap.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/zfsclonesnap.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -1,6 +1,6 @@
 #!/bin/sh
 # ZFS functionality
-# Args $1 = jail-dir
+# Args $1 = jail-name
 # Args $2 = zfs directive
 #######################################################################
 
@@ -10,7 +10,7 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-IP="${1}"
+JAILNAME="${1}"
 SNAP="${2}"
 
 if [ -z "${SNAP}" ] ; then
@@ -18,7 +18,7 @@
    exit 1
 fi
 
-if [ -z "${IP}" ]
+if [ -z "${JAILNAME}" ]
 then
   echo "ERROR: No jail specified to start!"
   exit 5
@@ -30,10 +30,12 @@
   exit 5
 fi
 
-if [ ! -d "${JDIR}/${IP}" ]
+JAILDIR="${JDIR}/${JAILNAME}"
+
+if [ ! -d "${JAILDIR}" ]
 then
-  echo "ERROR: No jail located at $JDIR/$IP"
+  echo "ERROR: No jail located at ${JAILDIR}"
   exit 5
 fi
 
-cloneZFSSnap "${JDIR}/${IP}" "$SNAP" "$IP"
+cloneZFSSnap "${JAILDIR}" "$SNAP" "${JAILNAME}"

Modified: pcbsd/current/src-sh/warden/scripts/backend/zfscronsnap.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/zfscronsnap.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/zfscronsnap.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -1,6 +1,6 @@
 #!/bin/sh
 # ZFS functionality
-# Args $1 = jail-dir
+# Args $1 = jail-name
 # Args $2 = zfs directive
 #######################################################################
 
@@ -10,10 +10,10 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-IP="${1}"
+JAILNAME="${1}"
 ACTION="${2}"
 
-if [ -z "${IP}" ]
+if [ -z "${JAILNAME}" ]
 then
   echo "ERROR: No jail specified to start!"
   exit 5
@@ -25,16 +25,18 @@
   exit 5
 fi
 
-if [ ! -d "${JDIR}/${IP}" ]
+JAILDIR="${JDIR}/${JAILNAME}"
+
+if [ ! -d "${JAILDIR}" ]
 then
-  echo "ERROR: No jail located at $JDIR/$IP"
+  echo "ERROR: No jail located at ${JAILDIR}"
   exit 5
 fi
 
 set_warden_metadir
 
 if [ "$ACTION" = "start" ] ; then
-  isDirZFS "${JDIR}/${IP}" "1"
+  isDirZFS "${JAILDIR}" "1"
   if [ $? -ne 0 ] ; then printerror "Not a ZFS volume: ${1}" ; fi
 
   TIME="${3}"

Modified: pcbsd/current/src-sh/warden/scripts/backend/zfslistclone.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/zfslistclone.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/zfslistclone.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -1,6 +1,6 @@
 #!/bin/sh
 # ZFS functionality
-# Args $1 = jail-dir
+# Args $1 = jail-name
 # Args $2 = zfs directive
 #######################################################################
 
@@ -10,9 +10,9 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-IP="${1}"
+JAILNAME="${1}"
 
-if [ -z "${IP}" ]
+if [ -z "${JAILNAME}" ]
 then
   echo "ERROR: No jail specified!"
   exit 5
@@ -24,10 +24,12 @@
   exit 5
 fi
 
-if [ ! -d "${JDIR}/${IP}" ]
+JAILDIR="${JDIR}/${JAILNAME}"
+
+if [ ! -d "${JAILDIR}" ]
 then
-  echo "ERROR: No jail located at $JDIR/$IP"
+  echo "ERROR: No jail located at ${JAILDIR}"
   exit 5
 fi
 
-listZFSClone "${JDIR}/${IP}" "${IP}"
+listZFSClone "${JAILDIR}" "${JAILNAME}"

Modified: pcbsd/current/src-sh/warden/scripts/backend/zfslistsnap.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/zfslistsnap.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/zfslistsnap.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -1,6 +1,6 @@
 #!/bin/sh
 # ZFS functionality
-# Args $1 = jail-dir
+# Args $1 = jail-name
 # Args $2 = zfs directive
 #######################################################################
 
@@ -10,9 +10,9 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-IP="${1}"
+JAILNAME="${1}"
 
-if [ -z "${IP}" ]
+if [ -z "${JAILNAME}" ]
 then
   echo "ERROR: No jail specified to start!"
   exit 5
@@ -24,10 +24,12 @@
   exit 5
 fi
 
-if [ ! -d "${JDIR}/${IP}" ]
+JAILDIR="${JDIR}/${JAILNAME}"
+
+if [ ! -d "${JAILDIR}" ]
 then
-  echo "ERROR: No jail located at $JDIR/$IP"
+  echo "ERROR: No jail located at ${JAILDIR}"
   exit 5
 fi
 
-listZFSSnap "${JDIR}/${IP}"
+listZFSSnap "${JAILDIR}"

Modified: pcbsd/current/src-sh/warden/scripts/backend/zfsmksnap.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/zfsmksnap.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/zfsmksnap.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -1,6 +1,6 @@
 #!/bin/sh
 # ZFS functionality
-# Args $1 = jail-dir
+# Args $1 = jail-name
 # Args $2 = zfs directive
 #######################################################################
 
@@ -10,9 +10,9 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-IP="${1}"
+JAILNAME="${1}"
 
-if [ -z "${IP}" ]
+if [ -z "${JAILNAME}" ]
 then
   echo "ERROR: No jail specified to start!"
   exit 5
@@ -24,10 +24,12 @@
   exit 5
 fi
 
-if [ ! -d "${JDIR}/${IP}" ]
+JAILDIR="${JDIR}/${JAILNAME}"
+
+if [ ! -d "${JAILDIR}" ]
 then
-  echo "ERROR: No jail located at $JDIR/$IP"
+  echo "ERROR: No jail located at ${JAILDIR}"
   exit 5
 fi
 
-mkZFSSnap "${JDIR}/${IP}"
+mkZFSSnap "${JAILDIR}"

Modified: pcbsd/current/src-sh/warden/scripts/backend/zfsrevertsnap.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/zfsrevertsnap.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/zfsrevertsnap.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -1,6 +1,6 @@
 #!/bin/sh
 # ZFS functionality
-# Args $1 = jail-dir
+# Args $1 = jail-name
 # Args $2 = zfs directive
 #######################################################################
 
@@ -10,7 +10,7 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-IP="${1}"
+JAILNAME="${1}"
 SNAP="${2}"
 
 if [ -z "${SNAP}" ] ; then
@@ -18,7 +18,7 @@
    exit 1
 fi
 
-if [ -z "${IP}" ]
+if [ -z "${JAILNAME}" ]
 then
   echo "ERROR: No jail specified to start!"
   exit 5
@@ -30,10 +30,12 @@
   exit 5
 fi
 
-if [ ! -d "${JDIR}/${IP}" ]
+JAILDIR="${JDIR}/${JAILNAME}"
+
+if [ ! -d "${JAILDIR}" ]
 then
-  echo "ERROR: No jail located at $JDIR/$IP"
+  echo "ERROR: No jail located at ${JAILDIR}"
   exit 5
 fi
 
-revertZFSSnap "${JDIR}/${IP}" "$SNAP" "$IP"
+revertZFSSnap "${JAILDIR}" "${SNAP}" "${JAILNAME}"

Modified: pcbsd/current/src-sh/warden/scripts/backend/zfsrmclone.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/zfsrmclone.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/zfsrmclone.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -1,6 +1,6 @@
 #!/bin/sh
 # ZFS functionality
-# Args $1 = jail-dir
+# Args $1 = jail-name
 # Args $2 = zfs directive
 #######################################################################
 
@@ -10,7 +10,7 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-IP="${1}"
+JAILNAME="${1}"
 CLONE="${2}"
 
 if [ -z "${CLONE}" ] ; then
@@ -18,7 +18,7 @@
    exit 1
 fi
 
-if [ -z "${IP}" ]
+if [ -z "${JAILNAME}" ]
 then
   echo "ERROR: No jail specified to start!"
   exit 5
@@ -30,10 +30,12 @@
   exit 5
 fi
 
-if [ ! -d "${JDIR}/${IP}" ]
+JAILDIR="${JDIR}/${JAILNAME}"
+
+if [ ! -d "${JAILDIR}" ]
 then
-  echo "ERROR: No jail located at $JDIR/$IP"
+  echo "ERROR: No jail located at ${JAILDIR}"
   exit 5
 fi
 
-rmZFSClone "${JDIR}/${IP}" "${CLONE}" "${IP}"
+rmZFSClone "${JAILDIR}" "${CLONE}" "${JAILNAME}"

Modified: pcbsd/current/src-sh/warden/scripts/backend/zfsrmsnap.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/zfsrmsnap.sh	2013-04-15 19:37:25 UTC (rev 22316)
+++ pcbsd/current/src-sh/warden/scripts/backend/zfsrmsnap.sh	2013-04-16 16:18:23 UTC (rev 22317)
@@ -1,6 +1,6 @@
 #!/bin/sh
 # ZFS functionality
-# Args $1 = jail-dir
+# Args $1 = jail-name
 # Args $2 = zfs directive
 #######################################################################
 
@@ -10,10 +10,10 @@
 # Source our variables
 . ${PROGDIR}/scripts/backend/functions.sh
 
-IP="${1}"
+JAILNAME="${1}"
 SNAP="${2}"
 
-if [ -z "${IP}" ]
+if [ -z "${JAILNAME}" ]
 then
   echo "ERROR: No jail specified to start!"
   exit 5
@@ -25,10 +25,12 @@
   exit 5
 fi
 
-if [ ! -d "${JDIR}/${IP}" ]
+JAILDIR="${JDIR}/${JAILNAME}"
+
+if [ ! -d "${JAILDIR}" ]
 then
-  echo "ERROR: No jail located at $JDIR/$IP"
+  echo "ERROR: No jail located at ${JAILDIR}"
   exit 5
 fi
 
-rmZFSSnap "${JDIR}/${IP}" "$SNAP"
+rmZFSSnap "${JAILDIR}" "$SNAP"



More information about the Commits mailing list