[PC-BSD Commits] r19582 - in pcbsd/current/src-sh/warden: bin scripts/backend
svn at pcbsd.org
svn at pcbsd.org
Tue Oct 2 15:55:34 PDT 2012
Author: kris
Date: 2012-10-02 22:55:34 +0000 (Tue, 02 Oct 2012)
New Revision: 19582
Modified:
pcbsd/current/src-sh/warden/bin/warden
pcbsd/current/src-sh/warden/scripts/backend/createjail.sh
Log:
Add support to "warden create" for "--archive <file>" to be used. This allows
us to create a new jail, but with a user-supplied tar archive of a specific
world environment, or previous FreeBSD jail.
Modified: pcbsd/current/src-sh/warden/bin/warden
===================================================================
--- pcbsd/current/src-sh/warden/bin/warden 2012-10-02 22:40:57 UTC (rev 19581)
+++ pcbsd/current/src-sh/warden/bin/warden 2012-10-02 22:55:34 UTC (rev 19582)
@@ -480,6 +480,7 @@
--startauto (Start this jail at system boot)
--portjail (Make this a portjail)
--linuxjail <installscript> (Make this a linux jail and use supplied script for installation)
+ --archive <tar archive> (Use specified tar file for jail creation - BSD jails only!)
Usage:
@@ -802,6 +803,13 @@
if [ -z "$1" ] ; then exit_err "No linux setup script specified!"; fi
LINUX_JAIL_SCRIPT="$1" ; export LINUX_JAIL_SCRIPT
;;
+ --archive) shift
+ if [ -z "$1" ] ; then exit_err "No archive file specified!"; fi
+ ARCHIVE_FILE="$1"
+ if [ ! -e "$ARCHIVE_FILE" ] ; then
+ exit_err "No such file: $ARCHIVE_FILE"
+ fi
+ ;;
esac
shift
done
@@ -810,7 +818,7 @@
if [ -e "${JDIR}/${IP}" ]; then exit_err "A jail with this IP already exists!"; fi
# Passed all tests, create the jail now
- ${PROGDIR}/scripts/backend/createjail.sh "${IP}" "${HOST}" "${SRC}" "${PORTS}" "${AUTO}" "${PORTJAIL}" "${LINUXJAIL}"
+ ${PROGDIR}/scripts/backend/createjail.sh "${IP}" "${HOST}" "${SRC}" "${PORTS}" "${AUTO}" "${PORTJAIL}" "${LINUXJAIL}" "${ARCHIVE_FILE}"
;;
delete) require_root
Modified: pcbsd/current/src-sh/warden/scripts/backend/createjail.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/createjail.sh 2012-10-02 22:40:57 UTC (rev 19581)
+++ pcbsd/current/src-sh/warden/scripts/backend/createjail.sh 2012-10-02 22:55:34 UTC (rev 19582)
@@ -63,7 +63,13 @@
STARTUP="${5}"
PORTJAIL="${6}"
LINUXJAIL="${7}"
+ARCHIVEFILE="${8}"
+# See if we are overriding the default archive file
+if [ ! -z "$ARCHIVEFILE" ] ; then
+ WORLDCHROOT="$ARCHIVEFILE"
+fi
+
if [ -z "$IP" -o -z "${HOST}" -o -z "$SOURCE" -o -z "${PORTS}" -o -z "${STARTUP}" ]
then
echo "ERROR: Missing required data!"
@@ -144,16 +150,18 @@
# Create an empty fstab
touch "${JDIR}/${IP}/etc/fstab"
-# Setup rc.conf
-echo "portmap_enable=\"NO\"
+# If this isn't a fresh jail, we can skip to not clobber existing setup
+if [ -z "$ARCHIVEFILE" ] ; then
+ # Setup rc.conf
+ echo "portmap_enable=\"NO\"
sshd_enable=\"YES\"
sendmail_enable=\"NO\"
hostname=\"${HOST}\"
devfs_enable=\"YES\"
devfs_system_ruleset=\"devfsrules_common\"" > "${JDIR}/${IP}/etc/rc.conf"
-# Create the host for this device
-echo "# : src/etc/hosts,v 1.16 2003/01/28 21:29:23 dbaker Exp $
+ # Create the host for this device
+ echo "# : src/etc/hosts,v 1.16 2003/01/28 21:29:23 dbaker Exp $
#
# Host Database
#
@@ -169,15 +177,18 @@
127.0.0.1 localhost localhost.localdomain ${HOST}
${IP} ${HOST}" > "${JDIR}/${IP}/etc/hosts"
-# Copy resolv.conf
-cp /etc/resolv.conf "${JDIR}/${IP}/etc/resolv.conf"
+ # Copy resolv.conf
+ cp /etc/resolv.conf "${JDIR}/${IP}/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
+ # 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
touch "${JMETADIR}/autostart"
fi
More information about the Commits
mailing list