From 13968d16f6fc06c5ca958b6489b29c8b1ed18a19 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 19 Nov 2012 10:36:52 +0100 Subject: [PATCH] change __jail to boolean, fixes #128 Signed-off-by: Nico Schottelius --- cdist/conf/type/__jail/gencode-remote | 23 ++++++----------------- cdist/conf/type/__jail/man.text | 22 +++++++++++----------- cdist/conf/type/__jail/parameter/boolean | 3 +++ cdist/conf/type/__jail/parameter/optional | 3 --- 4 files changed, 20 insertions(+), 31 deletions(-) create mode 100644 cdist/conf/type/__jail/parameter/boolean diff --git a/cdist/conf/type/__jail/gencode-remote b/cdist/conf/type/__jail/gencode-remote index 4aff6509..56a1b643 100755 --- a/cdist/conf/type/__jail/gencode-remote +++ b/cdist/conf/type/__jail/gencode-remote @@ -34,15 +34,8 @@ fi state="$(cat "$__object/parameter/state")" -if [ -f "$__object/parameter/started" ]; then - started="$(cat "$__object/parameter/started")" -else - if [ ! "$state" = "present" ]; then - started="false" - else - started="true" - fi -fi +started="false" +[ -f "$__object/parameter/started" -a "$state" = "present" ] && started="true" if [ -f "$__object/parameter/ip" ]; then ip="$(cat "$__object/parameter/ip")" @@ -66,8 +59,8 @@ if [ -f "$__object/parameter/interface" ]; then interface="$(cat "$__object/parameter/interface")" fi -if [ -f "$__object/parameter/devfs-enable" ]; then - devfsenable="$(cat "$__object/parameter/devfs-enable")" +if [ -f "$__object/parameter/devfs-disable" ]; then + devfsenable="false" else devfsenable="true" fi @@ -82,12 +75,12 @@ fi # is pointless. Treat this as an error. if [ -n "$devfsruleset" -a "$devfsenable" = "false" ]; then exec >&2 - echo "Can't have --devfs-ruleset defined without --devfs-enable true." + echo "Can't have --devfs-ruleset defined without --devfs-disable" exit 1 fi if [ -f "$__object/parameter/onboot" ]; then - onboot="$(cat "$__object/parameter/onboot")" + onboot="true" fi if [ -f "$__object/parameter/jaildir" ]; then @@ -357,7 +350,3 @@ else # The jail does not currently exist exit 0 fi fi - -# Debug -#set +x - diff --git a/cdist/conf/type/__jail/man.text b/cdist/conf/type/__jail/man.text index 8682effe..62b6e02e 100644 --- a/cdist/conf/type/__jail/man.text +++ b/cdist/conf/type/__jail/man.text @@ -27,9 +27,6 @@ OPTIONAL PARAMETERS name:: The name of the jail. Default is to use the object_id as the jail name. -started:: - Either "true" or "false." Defaults to true. - ip:: The ifconfig style IP/netmask combination to use for the jail guest. If the state parameter is "present," this parameter is required. @@ -41,23 +38,26 @@ interface:: The name of the physical interface on the jail server to bind the jail to. Defaults to the first interface found in the output of ifconfig -l. -devfs-enable:: - Whether to allow devfs mounting within the jail. Must be "true" or "false." - Defaults to true. - devfs-ruleset:: The name of the devfs ruleset to associate with the jail. Defaults to "jailrules." This ruleset must be copied to the server via another type. To use this option, devfs-enable must be "true." -onboot:: - Whether to add the jail to rc.conf's jail_list variable. Must be either - "true" or "false." Defaults to false. - jaildir:: The location on the remote server to use for hosting jail filesystems. Defaults to /usr/jail. +BOOLEAN PARAMETERS +------------------ +started:: + Whether to start jail + +devfs-disable:: + Whether to disallow devfs mounting within the jail + +onboot:: + Whether to add the jail to rc.conf's jail_list variable. + CAVEATS ------- diff --git a/cdist/conf/type/__jail/parameter/boolean b/cdist/conf/type/__jail/parameter/boolean new file mode 100644 index 00000000..1dd61f6b --- /dev/null +++ b/cdist/conf/type/__jail/parameter/boolean @@ -0,0 +1,3 @@ +onboot +started +devfs-disable diff --git a/cdist/conf/type/__jail/parameter/optional b/cdist/conf/type/__jail/parameter/optional index 1b5f0810..08ecd469 100644 --- a/cdist/conf/type/__jail/parameter/optional +++ b/cdist/conf/type/__jail/parameter/optional @@ -1,10 +1,7 @@ name -started ip hostname interface -devfs-enable devfs-ruleset -onboot jaildir jailbase