Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Oct 2012 08:50:01 GMT
From:      Yamagi Burmeister <yamagi@yamagi.org>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: misc/173076: New Port: sysutils/jail another rc-script for jails, this time for jail.conf jails
Message-ID:  <201210270850.q9R8o1wR017806@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR misc/173076; it has been noted by GNATS.

From: Yamagi Burmeister <yamagi@yamagi.org>
To: bug-followup@FreeBSD.org, yamagi@yamagi.org
Cc:  
Subject: Re: misc/173076: New Port: sysutils/jail another rc-script for
 jails, this time for jail.conf jails
Date: Sat, 27 Oct 2012 10:43:27 +0200

 This is a multi-part message in MIME format.
 
 --Multipart=_Sat__27_Oct_2012_10_43_27_+0200_xtW69zI6H9arjAUK
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: 7bit
 
 Sorry, I forgot to remove the .git directory before creating the shar.
 New version is attached.
 
 -- 
 Homepage:  www.yamagi.org
 XMPP:      yamagi@yamagi.org
 GnuPG/GPG: 0xEFBCCBCB
 
 --Multipart=_Sat__27_Oct_2012_10_43_27_+0200_xtW69zI6H9arjAUK
 Content-Type: text/plain;
  name="jail2.txt"
 Content-Disposition: attachment;
  filename="jail2.txt"
 Content-Transfer-Encoding: 7bit
 
 # 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/Makefile
 #	jail2/pkg-descr
 #
 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/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
 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
 exit
 
 
 --Multipart=_Sat__27_Oct_2012_10_43_27_+0200_xtW69zI6H9arjAUK--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210270850.q9R8o1wR017806>