From nobody@FreeBSD.org  Mon Dec 31 08:10:21 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 025F039D
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 31 Dec 2012 08:10:21 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id DBDA78FC13
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 31 Dec 2012 08:10:20 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id qBV8AKc8060591
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 31 Dec 2012 08:10:20 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id qBV8AKE2060590;
	Mon, 31 Dec 2012 08:10:20 GMT
	(envelope-from nobody)
Message-Id: <201212310810.qBV8AKE2060590@red.freebsd.org>
Date: Mon, 31 Dec 2012 08:10:20 GMT
From: Yamagi Burmeister <yamagi@yamagi.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [NEW PORT]: sysutils/jail2 - another jail rc-script, this time for jail.conf jails
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         174856
>Category:       ports
>Synopsis:       [NEW PORT]: sysutils/jail2 - another jail rc-script, this time for jail.conf jails
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lme
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 31 08:20:00 UTC 2012
>Closed-Date:    Sun Jan 20 15:31:14 UTC 2013
>Last-Modified:  Sun Jan 20 15:40:00 UTC 2013
>Originator:     Yamagi Burmeister
>Release:        FreeBSD 9.1
>Organization:
>Environment:
FreeBSD happy.home.yamagi.org 9.1-RELEASE FreeBSD 9.1-RELEASE #0 r243792M: Sun Dec  2 17:53:10 CET 2012     root@happy.home.yamagi.org:/usr/obj/usr/src/sys/HAPPY  amd64
>Description:
jail2 is an alternative rc script for jails, relying on jail.conf
instead of rc.conf variables. Additionally, ZFS integration is provided.
In contrast to the default jail rc script this one can run inside jails,
allowing the configuration of hierarchical jails.
>How-To-Repeat:
-
>Fix:
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	jail2
#	jail2/files
#	jail2/files/jail2.in
#	jail2/pkg-descr
#	jail2/Makefile
#
echo c - jail2
mkdir -p jail2 > /dev/null 2>&1
echo c - jail2/files
mkdir -p jail2/files > /dev/null 2>&1
echo x - jail2/files/jail2.in
sed 's/^X//' >jail2/files/jail2.in << '16a6c5557e83ea0912b4b8ab95367891'
X#!/bin/sh
X
X# Alternative rc script for jails. This script relies on
X# /etc/jail.conf instead of rc.conf variables. Usage:
X#
X# jail2_enable	   -> Enables the script
X# jail2_list	   -> List of jails to be started. The names
X#				      must match the names in /etc/jail.conf
X# jail2_$name_zfs  -> List of ZFS datasets to connect to the
X#					  jail $name.
X#
X# To manage ZFS datasets within a jail the dataset must have
X# set the parameter "jailed" to 1. Additionally the jail must
X# have set the proberties "allow.mount", "allow.mount.zfs"
X# and "enforce_statfs" to value lesser than 2.
X
X# PROVIDE: jail
X# REQUIRE: LOGIN cleanvar
X# BEFORE: securelevel
X# KEYWORD: shutdown
X
X. /etc/rc.subr
X
Xname="jail2"
Xrcvar=jail2_enable
X
Xstart_cmd="jail2_start"
Xstop_cmd="jail2_stop"
X
Xjail2_start()
X{
X	echo -n "Starting jails: "
X
X	for _j in ${jail2_list}; do
X		echo -n "${_j} "
X
X		if [ -e /var/run/jail_${_j}.id ]; then
X			echo "${_j} already exists"
X			continue
X		fi
X
X		jail -c -i -J /var/run/jail_${_j}.id ${_j} > /dev/null 2>&1
X
X		eval _zfs=\"\${jail2_${_j}_zfs:-}\"
X		_jid=`jls -j ${_j} jid 2>/dev/null`
X
X		if [ -n "${_zfs}" ]; then
X			for _ds in ${_zfs}; do
X				_jailed=`zfs get -H jailed ${_ds} 2>/dev/null | awk '{ print $3 }'`
X				if [ "${_jailed}" = "on" ]; then
X					echo "zfs jail "${_jid}" ${_ds} 2>/dev/null"
X					zfs jail "${_jid}" ${_ds} 2>/dev/null
X				fi
X			done
X		fi
X	done
X
X	echo
X}
X
Xjail2_stop()
X{
X	echo -n "Stopping jails: "
X
X	for _j in ${jail2_list}; do
X     	echo -n "${_j} "
X
X		if [ ! -e /var/run/jail_${_j}.id ]; then
X			echo "${_j} doesn't exists"
X			continue
X		fi
X
X		eval _zfs=\"\${jail2_${_j}_zfs:-}\"
X		_jid=`jls -j ${_j} jid 2>/dev/null`
X
X		jail -r -q ${_j} > /dev/null 2>&1
X		rm /var/run/jail_${_j}.id
X
X		if [ -n "${_zfs}" ]; then
X			for _ds in ${_zfs}; do
X				_jailed=`zfs get -H jailed ${_ds} 2>/dev/null | awk '{ print $3 }'`
X				if [ "${_jailed}" = "on" ]; then
X					echo "zfs unjail "${_jid}" ${_ds} 2>/dev/null"
X					zfs unjail "${_jid}" ${_ds} 2>/dev/null
X				fi
X			done
X		fi
X	done
X
X	echo
X}
X
Xload_rc_config $name
X: ${jail2_enable="NO"}
X
Xcmd="$1"
Xif [ $# -gt 0 ]; then
X	shift
Xfi
Xif [ -n "$*" ]; then
X	jail2_list="$*"
Xfi
X
Xrun_rc_command "${cmd}"
16a6c5557e83ea0912b4b8ab95367891
echo x - jail2/pkg-descr
sed 's/^X//' >jail2/pkg-descr << 'ed4ba63968e8f4533a155b7c0e7567d1'
Xjail2 is an alternative rc script for jails, relying on jail.conf
Xinstead of rc.conf variables. Additionally, ZFS integration is provided.
XIn contrast to the default jail rc script this one can run inside jails,
Xallowing the configuration of hierarchical jails.
ed4ba63968e8f4533a155b7c0e7567d1
echo x - jail2/Makefile
sed 's/^X//' >jail2/Makefile << '244169e487ff8dd224c47b19f508f4f0'
X# New ports collection makefile for:	jail2
X# Date created:	   21 October 2012
X# Whom:		   Yamagi Burmeister <yamagi@yamagi.org>
X#
X# $FreeBSD$
X#
X
XPORTNAME=	jail2
XPORTVERSION=	1.0
XCATEGORIES=	sysutils
XMASTER_SITES=	#
XDISTFILES=	#
X
XMAINTAINER=	yamagi@yamagi.org
XCOMMENT=	Jail startup/shutdown script with jail.conf support
X
XNO_BUILD=	yes
XNO_INSTALL=	yes
X
XUSE_RC_SUBR=	jail2
X
X.include <bsd.port.mk>
244169e487ff8dd224c47b19f508f4f0
exit 

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->lme 
Responsible-Changed-By: lme 
Responsible-Changed-When: Sun Jan 20 11:25:30 UTC 2013 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=174856 
State-Changed-From-To: open->closed 
State-Changed-By: lme 
State-Changed-When: Sun Jan 20 15:31:13 UTC 2013 
State-Changed-Why:  
Committed. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=174856 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/174856: commit references a PR
Date: Sun, 20 Jan 2013 15:31:17 +0000 (UTC)

 Author: lme
 Date: Sun Jan 20 15:31:04 2013
 New Revision: 310695
 URL: http://svnweb.freebsd.org/changeset/ports/310695
 
 Log:
   jail2 is an alternative rc script for jails, relying on jail.conf
   instead of rc.conf variables. Additionally, ZFS integration is provided.
   In contrast to the default jail rc script this one can run inside jails,
   allowing the configuration of hierarchical jails.
   
   PR:		ports/174856
 
 Added:
   head/sysutils/jail2/
   head/sysutils/jail2/Makefile   (contents, props changed)
   head/sysutils/jail2/files/
   head/sysutils/jail2/files/jail2.in   (contents, props changed)
   head/sysutils/jail2/pkg-descr   (contents, props changed)
 Modified:
   head/sysutils/Makefile
 
 Modified: head/sysutils/Makefile
 ==============================================================================
 --- head/sysutils/Makefile	Sun Jan 20 15:22:12 2013	(r310694)
 +++ head/sysutils/Makefile	Sun Jan 20 15:31:04 2013	(r310695)
 @@ -400,6 +400,7 @@
      SUBDIR += isomd5sum
      SUBDIR += ispman
      SUBDIR += istatd
 +    SUBDIR += jail2
      SUBDIR += jailadmin
      SUBDIR += jailctl
      SUBDIR += jailer
 
 Added: head/sysutils/jail2/Makefile
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/sysutils/jail2/Makefile	Sun Jan 20 15:31:04 2013	(r310695)
 @@ -0,0 +1,17 @@
 +# $FreeBSD$
 +
 +PORTNAME=	jail2
 +PORTVERSION=	1.0
 +CATEGORIES=	sysutils
 +MASTER_SITES=	#
 +DISTFILES=	#
 +
 +MAINTAINER=	yamagi@yamagi.org
 +COMMENT=	Jail startup/shutdown script with jail.conf support
 +
 +NO_BUILD=	yes
 +NO_INSTALL=	yes
 +
 +USE_RC_SUBR=	jail2
 +
 +.include <bsd.port.mk>
 
 Added: head/sysutils/jail2/files/jail2.in
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/sysutils/jail2/files/jail2.in	Sun Jan 20 15:31:04 2013	(r310695)
 @@ -0,0 +1,104 @@
 +#!/bin/sh
 +
 +# Alternative rc script for jails. This script relies on
 +# /etc/jail.conf instead of rc.conf variables. Usage:
 +#
 +# jail2_enable	   -> Enables the script
 +# jail2_list	   -> List of jails to be started. The names
 +#				      must match the names in /etc/jail.conf
 +# jail2_$name_zfs  -> List of ZFS datasets to connect to the
 +#					  jail $name.
 +#
 +# To manage ZFS datasets within a jail the dataset must have
 +# set the parameter "jailed" to 1. Additionally the jail must
 +# have set the proberties "allow.mount", "allow.mount.zfs"
 +# and "enforce_statfs" to value lesser than 2.
 +
 +# PROVIDE: jail
 +# REQUIRE: LOGIN cleanvar
 +# BEFORE: securelevel
 +# KEYWORD: shutdown
 +
 +. /etc/rc.subr
 +
 +name="jail2"
 +rcvar=jail2_enable
 +
 +start_cmd="jail2_start"
 +stop_cmd="jail2_stop"
 +
 +jail2_start()
 +{
 +	echo -n "Starting jails: "
 +
 +	for _j in ${jail2_list}; do
 +		echo -n "${_j} "
 +
 +		if [ -e /var/run/jail_${_j}.id ]; then
 +			echo "${_j} already exists"
 +			continue
 +		fi
 +
 +		jail -c -i -J /var/run/jail_${_j}.id ${_j} > /dev/null 2>&1
 +
 +		eval _zfs=\"\${jail2_${_j}_zfs:-}\"
 +		_jid=`jls -j ${_j} jid 2>/dev/null`
 +
 +		if [ -n "${_zfs}" ]; then
 +			for _ds in ${_zfs}; do
 +				_jailed=`zfs get -H jailed ${_ds} 2>/dev/null | awk '{ print $3 }'`
 +				if [ "${_jailed}" = "on" ]; then
 +					echo "zfs jail "${_jid}" ${_ds} 2>/dev/null"
 +					zfs jail "${_jid}" ${_ds} 2>/dev/null
 +				fi
 +			done
 +		fi
 +	done
 +
 +	echo
 +}
 +
 +jail2_stop()
 +{
 +	echo -n "Stopping jails: "
 +
 +	for _j in ${jail2_list}; do
 +     	echo -n "${_j} "
 +
 +		if [ ! -e /var/run/jail_${_j}.id ]; then
 +			echo "${_j} doesn't exists"
 +			continue
 +		fi
 +
 +		eval _zfs=\"\${jail2_${_j}_zfs:-}\"
 +		_jid=`jls -j ${_j} jid 2>/dev/null`
 +
 +		jail -r -q ${_j} > /dev/null 2>&1
 +		rm /var/run/jail_${_j}.id
 +
 +		if [ -n "${_zfs}" ]; then
 +			for _ds in ${_zfs}; do
 +				_jailed=`zfs get -H jailed ${_ds} 2>/dev/null | awk '{ print $3 }'`
 +				if [ "${_jailed}" = "on" ]; then
 +					echo "zfs unjail "${_jid}" ${_ds} 2>/dev/null"
 +					zfs unjail "${_jid}" ${_ds} 2>/dev/null
 +				fi
 +			done
 +		fi
 +	done
 +
 +	echo
 +}
 +
 +load_rc_config $name
 +: ${jail2_enable="NO"}
 +
 +cmd="$1"
 +if [ $# -gt 0 ]; then
 +	shift
 +fi
 +if [ -n "$*" ]; then
 +	jail2_list="$*"
 +fi
 +
 +run_rc_command "${cmd}"
 
 Added: head/sysutils/jail2/pkg-descr
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/sysutils/jail2/pkg-descr	Sun Jan 20 15:31:04 2013	(r310695)
 @@ -0,0 +1,4 @@
 +jail2 is an alternative rc script for jails, relying on jail.conf
 +instead of rc.conf variables. Additionally, ZFS integration is provided.
 +In contrast to the default jail rc script this one can run inside jails,
 +allowing the configuration of hierarchical jails.
 _______________________________________________
 svn-ports-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-ports-all
 To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
 
>Unformatted:
