conf/116416: [patch] per-jail rc.conf(5) style configuration
file in /etc/jail/
Jeremie Le Hen
jeremie at le-hen.org
Mon Sep 17 08:30:15 PDT 2007
The following reply was made to PR conf/116416; it has been noted by GNATS.
From: Jeremie Le Hen <jeremie at le-hen.org>
To: FreeBSD-gnats-submit at freebsd.org
Cc: Jeremie Le Hen <jeremie at le-hen.org>
Subject: Re: conf/116416: [patch] per-jail rc.conf(5) style configuration file in /etc/jail/
Date: Mon, 17 Sep 2007 17:22:29 +0200 (CEST)
>Submitter-Id: current-users
>Originator: Jeremie Le Hen <jeremie at le-hen.org>
>Confidential: no
>Synopsis: Re: conf/116416: [patch] per-jail rc.conf(5) style configuration file in /etc/jail/
>Severity: non-critical
>Priority: low
>Category: conf
>Class: change-request
>Release: FreeBSD 7.0-CURRENT
>Environment:
FreeBSD 7.0-CURRENT
>Description:
This patch improves the previous one in that if $jail_list is empty,
the rc.d script will deduce it from the content of /etc/jail/.
This is even more easier to add/remove jail inside a script.
>Fix:
--- etc_jail.diff begins here ---
Index: jail
===================================================================
RCS file: /home/ncvs/src/etc/rc.d/jail,v
retrieving revision 1.37
diff -u -p -u -r1.37 jail
--- jail 24 May 2007 06:01:06 -0000 1.37
+++ jail 17 Sep 2007 15:14:34 -0000
@@ -14,6 +14,8 @@ name="jail"
rcvar=`set_rcvar`
start_cmd="jail_start"
stop_cmd="jail_stop"
+start_precmd="jail_prestart"
+jails_confdir="/etc/jail"
# init_variables _j
# Initialize the various jail variables for jail _j.
@@ -27,6 +29,14 @@ init_variables()
return
fi
+ if [ -f "$jails_confdir/$_j" ]; then
+ eval `awk -v j="$_j" \
+ '/^[[:blank:]]*[a-zA-Z_][a-zA-Z0-9_]*=/ {
+ sub(/^[[:blank:]]+/, "")
+ print sprintf("jail_%s_%s", j, $0)
+ }' "$jails_confdir/$_j"`
+ fi
+
eval _rootdir=\"\$jail_${_j}_rootdir\"
_devdir="${_rootdir}/dev"
_fdescdir="${_devdir}/fd"
@@ -267,6 +277,17 @@ jail_mount_fstab()
mount -a -F "${_fstab}"
}
+# jail_prestart
+# If jail_list is empty, compute it from $jails_confdir.
+jail_prestart()
+{
+ [ -z "$jail_list" ] || return 0
+ [ -d "$jails_confdir" ] || return 0
+
+ jail_list=`ls "$jails_confdir"`
+ return 0
+}
+
jail_start()
{
echo -n 'Configuring jails:'
--- etc_jail.diff ends here ---
More information about the freebsd-bugs
mailing list