[PC-BSD Commits] r17745 - in pcbsd/current/src-sh/warden: linux-installs scripts/backend
svn at pcbsd.org
svn at pcbsd.org
Mon Jul 16 06:25:08 PDT 2012
Author: kris
Date: 2012-07-16 13:25:08 +0000 (Mon, 16 Jul 2012)
New Revision: 17745
Modified:
pcbsd/current/src-sh/warden/linux-installs/debian-6-squeeze
pcbsd/current/src-sh/warden/linux-installs/gentoo-stage3-i486
pcbsd/current/src-sh/warden/scripts/backend/createjail.sh
pcbsd/current/src-sh/warden/scripts/backend/startjail.sh
pcbsd/current/src-sh/warden/scripts/backend/stopjail.sh
Log:
Add ability to set custom jail start / stop exec, and flags. Use them for
the linux jail scripts now
Modified: pcbsd/current/src-sh/warden/linux-installs/debian-6-squeeze
===================================================================
--- pcbsd/current/src-sh/warden/linux-installs/debian-6-squeeze 2012-07-16 13:21:47 UTC (rev 17744)
+++ pcbsd/current/src-sh/warden/linux-installs/debian-6-squeeze 2012-07-16 13:25:08 UTC (rev 17745)
@@ -24,4 +24,7 @@
mv ${jDIR}/sbin/umount ${jDIR}/sbin/umount.prev
ln -s /bin/true ${jDIR}/sbin/umount
+# Setup some custom start / stop stuff
+echo "-l -u root" > ${3}/jail-flags
+
exit $err
Modified: pcbsd/current/src-sh/warden/linux-installs/gentoo-stage3-i486
===================================================================
--- pcbsd/current/src-sh/warden/linux-installs/gentoo-stage3-i486 2012-07-16 13:21:47 UTC (rev 17744)
+++ pcbsd/current/src-sh/warden/linux-installs/gentoo-stage3-i486 2012-07-16 13:25:08 UTC (rev 17745)
@@ -111,4 +111,9 @@
mv ${jDIR}/bin/umount ${jDIR}/bin/umount.prev
ln -s /bin/true ${jDIR}/bin/umount
+# Setup some custom start / stop stuff
+echo "/sbin/rc default" > ${3}/jail-start
+echo "/sbin/rc shutdown" > ${3}/jail-stop
+echo "-l -u root" > ${3}/jail-flags
+
exit $err
Modified: pcbsd/current/src-sh/warden/scripts/backend/createjail.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/createjail.sh 2012-07-16 13:21:47 UTC (rev 17744)
+++ pcbsd/current/src-sh/warden/scripts/backend/createjail.sh 2012-07-16 13:25:08 UTC (rev 17745)
@@ -14,7 +14,7 @@
fi
touch "${JMETADIR}/linuxjail"
- sh ${LINUX_JAIL_SCRIPT} "${JDIR}/${IP}" "${IP}"
+ sh ${LINUX_JAIL_SCRIPT} "${JDIR}/${IP}" "${IP}" "${JMETADIR}"
if [ $? -ne 0 ] ; then
echo "Failed running ${LINUX_JAIL_SCRIPT}"
exit 1
Modified: pcbsd/current/src-sh/warden/scripts/backend/startjail.sh
===================================================================
--- pcbsd/current/src-sh/warden/scripts/backend/startjail.sh 2012-07-16 13:21:47 UTC (rev 17744)
+++ pcbsd/current/src-sh/warden/scripts/backend/startjail.sh 2012-07-16 13:25:08 UTC (rev 17745)
@@ -107,18 +107,37 @@
fi
done
-jail -c name=${HOST} path=${JDIR}/${IP} host.hostname=${HOST} ${_ipflags} persist
+jFlags=""
+# Grab any additional jail flags
+if [ -e "${JMETADIR}/jail-flags" ] ; then
+ jFlags=`cat ${JMETADIR}/jail-flags`
+fi
+# Start the jail now
+jail -c name=${HOST} path=${JDIR}/${IP} host.hostname=${HOST} ${_ipflags} ${jFlags} persist
+
JID="`jls | grep ${JDIR}/${IP} | tr -s " " | cut -d " " -f 2`"
if [ "$LINUXJAIL" = "YES" ] ; then
- # Check for different init styles
- if [ -e "${JDIR}/${IP}/etc/init.d/rc" ] ; then
- jexec ${JID} /bin/sh /etc/init.d/rc 3 2>&1
- elif [ -e "${JDIR}/${IP}/etc/rc" ] ; then
- jexec ${JID} /bin/sh /etc/rc 3 2>&1
+ # If we have a custom startup script
+ if [ -e "${JMETADIR}/jail-startup" ] ; then
+ sCmd=`cat ${JMETADIR}/jail-startup`
+ jexec ${JID} ${sCmd} 2>&1
+ else
+ # Check for different init styles
+ if [ -e "${JDIR}/${IP}/etc/init.d/rc" ] ; then
+ jexec ${JID} /bin/sh /etc/init.d/rc 3 2>&1
+ elif [ -e "${JDIR}/${IP}/etc/rc" ] ; then
+ jexec ${JID} /bin/sh /etc/rc 3 2>&1
+ fi
fi
else
- jexec ${JID} /bin/sh /etc/rc 2>&1
+ # If we have a custom startup script
+ if [ -e "${JMETADIR}/jail-startup" ] ; then
+ sCmd=`cat ${JMETADIR}/jail-startup`
+ jexec ${JID} ${sCmd} 2>&1
+ else
+ 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 2012-07-16 13:21:47 UTC (rev 17744)
+++ pcbsd/current/src-sh/warden/scripts/backend/stopjail.sh 2012-07-16 13:25:08 UTC (rev 17745)
@@ -85,11 +85,17 @@
if [ -e "${JMETADIR}/linuxjail" ] ; then LINUXJAIL="YES" ; fi
if [ "$LINUXJAIL" = "YES" ] ; then
- # Check for different init styles
- if [ -e "${JDIR}/${IP}/etc/init.d/rc" ] ; then
- jexec ${JID} /bin/sh /etc/init.d/rc 0 2>&1
- elif [ -e "${JDIR}/${IP}/etc/rc" ] ; then
- jexec ${JID} /bin/sh /etc/rc 0 2>&1
+ # If we have a custom stop script
+ if [ -e "${JMETADIR}/jail-stop" ] ; then
+ sCmd=`cat ${JMETADIR}/jail-stop`
+ jexec ${JID} ${sCmd} 2>&1
+ else
+ # Check for different init styles
+ if [ -e "${JDIR}/${IP}/etc/init.d/rc" ] ; then
+ jexec ${JID} /bin/sh /etc/init.d/rc 0 2>&1
+ elif [ -e "${JDIR}/${IP}/etc/rc" ] ; then
+ jexec ${JID} /bin/sh /etc/rc 0 2>&1
+ fi
fi
sleep 3
@@ -98,7 +104,13 @@
umount -f ${JDIR}/${IP}/dev 2>/dev/null
umount -f ${JDIR}/${IP}/lib/init/rw 2>/dev/null
else
- jexec ${JID} /bin/sh /etc/rc.shutdown >/dev/null 2>/dev/null
+ # If we have a custom stop script
+ if [ -e "${JMETADIR}/jail-stop" ] ; then
+ sCmd=`cat ${JMETADIR}/jail-stop`
+ jexec ${JID} ${sCmd} 2>&1
+ else
+ jexec ${JID} /bin/sh /etc/rc.shutdown >/dev/null 2>/dev/null
+ fi
fi
umount -f ${JDIR}/${IP}/dev >/dev/null 2>/dev/null
More information about the Commits
mailing list