[PC-BSD Commits] r19695 - pcbsd/current/src-sh/warden/scripts/backend

svn at pcbsd.org svn at pcbsd.org
Wed Oct 17 05:31:55 PDT 2012


Author: kris
Date: 2012-10-17 12:31:55 +0000 (Wed, 17 Oct 2012)
New Revision: 19695

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

When doing export / import of jails, save the optional jail-flags



Modified: pcbsd/current/src-sh/warden/scripts/backend/exportjail.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/exportjail.sh	2012-10-17 09:18:54 UTC (rev 19694)
+++ pcbsd/current/src-sh/warden/scripts/backend/exportjail.sh	2012-10-17 12:31:55 UTC (rev 19695)
@@ -52,6 +52,12 @@
 
 LINES="`wc -l ${IP}.files | sed -e 's, ,,g' | cut -d '.' -f 1`"
 
+# Save any optional jail flags
+if [ -e "${JMETADIR}/jail-flags" ] ; then
+  JFLAGS="`cat ${JMETADIR}/jail-flags`"
+else
+  JFLAGS=""
+fi
 
 # Finished, now make the header info
 cd ${WTMP}
@@ -61,6 +67,7 @@
 Files: $LINES
 IP: ${IP}
 HOST: ${HOST}
+JFLAGS: ${JFLAGS}
 " >${WTMP}/${IP}.header
 
 # Compress the header file

Modified: pcbsd/current/src-sh/warden/scripts/backend/importjail.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/importjail.sh	2012-10-17 09:18:54 UTC (rev 19694)
+++ pcbsd/current/src-sh/warden/scripts/backend/importjail.sh	2012-10-17 12:31:55 UTC (rev 19695)
@@ -73,39 +73,40 @@
 while read line
 do
   #Check for the file version
-  echo "$line" | grep "Ver:" >/dev/null 2>/dev/null
-  if [ "$?" = "0" ]
-  then
+  echo "$line" | grep -q "Ver:"
+  if [ $? -eq 0 ]; then
     VER="`echo $line | cut -d ' ' -f 2-10`"
   fi
 
   # Check for the OS Platform
-  echo "$line" | grep "OS:" >/dev/null 2>/dev/null
-  if [ "$?" = "0" ]
-  then
+  echo "$line" | grep -q "OS:"
+  if [ $? -eq 0 ]; then
     OS="`echo $line | cut -d ' ' -f 2-10`"
   fi
 
   # Check for the File Number 
-  echo "$line" | grep "Files:" >/dev/null 2>/dev/null
-  if [ "$?" = "0" ]
-  then
+  echo "$line" | grep -q "Files:"
+  if [ $? -eq 0 ]; then
     FILES="`echo $line | cut -d ' ' -f 2-10`"
   fi
   
   # Check for the built in IP
-  echo "$line" | grep "IP:" >/dev/null 2>/dev/null
-  if [ "$?" = "0" ]
-  then
+  echo "$line" | grep -q "IP:"
+  if [ $? -eq 0 ]; then
     FIP="`echo $line | cut -d ' ' -f 2-10`"
   fi
   
   # Check for the built in HOST
-  echo "$line" | grep "HOST:" >/dev/null 2>/dev/null
-  if [ "$?" = "0" ]
-  then
+  echo "$line" | grep -q "HOST:"
+  if [ $? -eq 0 ]; then
     FHOST="`echo $line | cut -d ' ' -f 2-10`"
   fi
+
+  # Check for jail flags
+  echo "$line" | grep -q "JFLAGS:"
+  if [ $? -eq 0 ]; then
+    JFLAGS="`echo $line | sed 's|JFLAGS: ||g'`"
+  fi
   
 done < $HEADER 
 
@@ -164,6 +165,11 @@
 # Make sure we have an IP address saved
 echo "${IP}" >"${JMETADIR}/ip"
 
+# Save the jail flags
+if [ -n "$JFLAGS" ] ; then
+   echo "$JFLAGS" > "${JMETADIR}/jail-flags"
+fi
+
 if [ "$HOST" = "OFF" -o -z "${HOST}" ] ; then
   HOST="$FHOST"
 fi



More information about the Commits mailing list