[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

patch: ezjail_default_interface option



Hello,

a patch lying around for a couple of years, originally posted by my colleague Alex Kosiaris. Adds an ezjail_default_interface option to ezjail.conf and a "-I interface" option to ezjail-admin. Saves you the trouble of manually editing the config file of every newly created jail.

Regards,
Panagiotis

--
Panagiotis J. Christias    Network Management Center
p.christias AT noc.ntua DOT gr    National Technical Univ. of Athens, GREECE
--- ezjail-admin.orig	2010-01-15 17:15:27.000000000 +0200
+++ ezjail-admin	2010-01-19 21:59:05.000000000 +0200
@@ -43,7 +43,7 @@
 # Synopsis messages
 ezjail_usage_ezjailadmin="${ezjail_admin} v3.0\nUsage: ${ezjail_admin} [archive|config|console|create|delete|install|list|restore|update] {params}"
 ezjail_usage_install="Usage: ${ezjail_admin} install [-mMpPsS] [-h host] [-r release]"
-ezjail_usage_create="Usage: ${ezjail_admin} create [-xbi] [-f flavour] [-r jailroot] [-s size] [-c bde|eli|zfs] [-C args] [-a archive] jailname jailip"
+ezjail_usage_create="Usage: ${ezjail_admin} create [-xbi] [-f flavour] [-r jailroot] [-s size] [-c bde|eli|zfs] [-I interface] [-C args] [-a archive] jailname jailip"
 ezjail_usage_delete="Usage: ${ezjail_admin} delete [-w] jailname"
 ezjail_usage_update="Usage: ${ezjail_admin} update [-s sourcetree] [-p] (-b|-i|-u|-P)"
 ezjail_usage_config="Usage: ${ezjail_admin} config [-r run|norun] [-n newname] [-c cpuset] [-z zfs-datasets] [-f fib] [-i attach|detach|fsck] jailname"
@@ -174,6 +174,7 @@
   echo export jail_${ezjail_safename}_zfs_datasets=\"${ezjail_zfs_datasets}\"
   echo export jail_${ezjail_safename}_cpuset=\"${ezjail_cpuset}\"
   echo export jail_${ezjail_safename}_fib=\"${ezjail_fib}\"
+  echo export jail_${ezjail_safename}_interface=\"${ezjail_interface}\"
 
   ) > "${ezjail_destconf}"
 
@@ -208,6 +209,7 @@
   eval ezjail_zfs_datasets=\"\$jail_${ezjail_safename}_zfs_datasets\"
   eval ezjail_cpuset=\"\$jail_${ezjail_safename}_cpuset\"
   eval ezjail_fib=\"\$jail_${ezjail_safename}_fib\"
+  eval ezjail_interface=\"\$jail_${ezjail_safename}_interface\"
 
   ezjail_softlink=${ezjail_jaildir}/`basename -- "${ezjail_rootdir}"`
   ezjail_devicelink="${ezjail_rootdir}.device"
@@ -407,8 +409,8 @@
 ######################## ezjail-admin CREATE ########################
 create)
   # Clean variables, prevent polution
-  unset ezjail_rootdir ezjail_flavour ezjail_softlink ezjail_image ezjail_imagetype ezjail_imageparams ezjail_imagesize ezjail_device ezjail_devicelink ezjail_config ezjail_attachparams ezjail_exists ezjail_attachblocking ezjail_forceblocking ezjail_sourcedevice ezjail_rootdirempty ezjail_fromarchive ezjail_fromarchive_config
-  shift; while getopts :f:r:s:xbic:C:a:A: arg; do case ${arg} in
+  unset ezjail_rootdir ezjail_flavour ezjail_softlink ezjail_image ezjail_imagetype ezjail_imageparams ezjail_imagesize ezjail_device ezjail_devicelink ezjail_config ezjail_attachparams ezjail_exists ezjail_attachblocking ezjail_forceblocking ezjail_sourcedevice ezjail_rootdirempty ezjail_fromarchive ezjail_fromarchive_config ezjail_interface
+  shift; while getopts :f:r:s:xbic:C:a:A:I: arg; do case ${arg} in
     x) ezjail_exists="YES";;
     r) ezjail_rootdir=${OPTARG};;
     f) ezjail_flavour=${OPTARG};;
@@ -419,6 +421,7 @@
     b) ezjail_forceblocking="YES";;
     i) : ${ezjail_imagetype="simple"};;
     s) ezjail_imagesize=${OPTARG};;
+    I) ezjail_interface="${OPTARG}";;
     ?) exerr ${ezjail_usage_create};;
   esac; done; shift $(( ${OPTIND} - 1 ))
 
@@ -488,6 +491,9 @@
     [ -e "${ezjail_softlink}" ] && ezjail_softlink=`mktemp -u "${ezjail_softlink}.XXXXXX"`
   fi
 
+  # if no interface specified on command line, use default interface (should we do any sanity checks?)
+  : ${ezjail_interface=${ezjail_default_interface}}
+
   # if no flavour specified on command line, use default flavour
   : ${ezjail_flavour=${ezjail_default_flavour}}
 
--- ezjail.conf.sample.orig	2010-01-14 04:11:03.000000000 +0200
+++ ezjail.conf.sample	2010-01-19 21:49:33.000000000 +0200
@@ -32,6 +32,9 @@
 # This is the flavour used by default when setting up a new jail
 # ezjail_default_flavour=""
 
+# Default interface used by newly created jails
+# ezjail_default_interface=""
+
 # This is the default location where ezjail archives its jails to
 # ezjail_archivedir=`pwd -P`
 
--- man1/ezjail-admin.1.orig	2010-01-15 16:05:42.000000000 +0200
+++ man1/ezjail-admin.1	2010-01-19 21:17:35.000000000 +0200
@@ -7,7 +7,7 @@
 
 .T
 .B ezjail-admin create
-[-f flavour] [-r jailroot] [-s imagesize] [-ibx] [-c bde|eli|zfs] [-C attachargs] [-a archive]\fI hostname jailip
+[-f flavour] [-r jailroot] [-s imagesize] [-ibx] [-c bde|eli|zfs] [-I interface] [-C attachargs] [-a archive]\fI hostname jailip
 
 .T
 .B ezjail-admin console\fR [-f] [-e command]\fI jailname
@@ -28,7 +28,7 @@
 .B ezjail-admin restore\fR [-f] [-d archivedir]\fI (archive|jailname)...
 
 .T
-.B ezjail-admin update\fR [-s sourcetree] [-i] [-pP]
+.B ezjail-admin update\fR [-s sourcetree] [-i] [-pP] [-u]
 
 .SH DESCRIPTION
 The \fBezjail-admin\fR tool is used to manage the ezjail environment
@@ -113,6 +113,9 @@
 \fIflavour\fR is a directory tree under ezjail's root dir (default:
 \fI/usr/jails/flavours\fR). See \fBFLAVOURS\fR below for more details.
 
+Using the -I \fIinterface\fR option you can define a network interface
+to be used by the newly created jail.
+
 Options for newly created jails are read from \fBezjail.conf\fR; refer to
 ezjail.conf(5) for more information.
 .SH ezjail-admin console
@@ -203,6 +206,9 @@
 If the -P option is given, \fBonly the ports tree will be updated,\fR so this can
 be done while jails are running.
 
+If the -u option is given, \fBonly the basejail will be updated using
+freebsd-update,\fR so this can be done while jails are running.
+
 If the -i (install only) option is given, \fBezjail-admin update\fR performs a
 \fImake installworld,\fR otherwise \fImake world\fR is invoked.
 
--- man5/ezjail.conf.5.orig	2010-01-14 04:11:03.000000000 +0200
+++ man5/ezjail.conf.5	2010-01-19 21:42:17.000000000 +0200
@@ -117,6 +117,11 @@
 Controls which flavour should be used for newly created jails.
 .br
 .I default: none
+.TP
+.B ezjail_default_interface (str)
+Controls which network interface should be used by newly created jails.
+.br
+.I default: none
 .SH ZFS OPTIONS
 .TP
 .B ezjail_use_zfs (bool)