summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2021-06-06 05:52:09 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2021-06-06 05:57:52 +0000
commit384a991b23fe765a2ed8249f1f3e73488ded9556 (patch)
tree592fa7bf91a2b1ab6eeb53c5e6cd4f2f7043aca9
parentRemoving undesirable --verbose option when calling mmdebstrap in debconf cont... (diff)
downloadcompute-tools-384a991b23fe765a2ed8249f1f3e73488ded9556.tar.xz
compute-tools-384a991b23fe765a2ed8249f1f3e73488ded9556.zip
Allowing to specify cnt.start=force in container config to ease fencing with pacemaker/corosync.
This should be generalized as a generic container program behaviour to look at users command line options *and* container configuration files. Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
-rwxr-xr-xlibexec/container/create10
-rwxr-xr-xlibexec/container/start6
-rw-r--r--share/config/container.conf.in1
-rw-r--r--share/man/container-create.1.txt3
4 files changed, 18 insertions, 2 deletions
diff --git a/libexec/container/create b/libexec/container/create
index 418bc35..af85007 100755
--- a/libexec/container/create
+++ b/libexec/container/create
@@ -32,7 +32,7 @@ CONFIG_TEMPLATE="/usr/share/${SOFTWARE}/config/container.conf.in"
Parameters ()
{
- GETOPT_LONGOPTIONS="name:,cnt.container-server:,cnt.overlay:,cnt.overlay-options:,bind:,bind-ro:,capability:,drop-capability:,script:,verbose,"
+ GETOPT_LONGOPTIONS="name:,cnt.container-server:,cnt.overlay:,cnt.overlay-options:,start:,bind:,bind-ro:,capability:,drop-capability:,script:,verbose,"
GETOPT_OPTIONS="n:,b:,c:,d:,s:,v,"
PARAMETERS="$(getopt --longoptions ${GETOPT_LONGOPTIONS} --name=${COMMAND} --options ${GETOPT_OPTIONS} --shell sh -- ${@})"
@@ -73,6 +73,11 @@ Parameters ()
shift 2
;;
+ --cnt.start)
+ CNT_START="${2}"
+ shift 2
+ ;;
+
-b|--bind)
BIND="${2}"
shift 2
@@ -118,7 +123,7 @@ Parameters ()
Usage ()
{
- echo "Usage: ${PROGRAM} ${COMMAND} -n|--name NAME [--cnt.container-server=true|false|FQDN] [--cnt.overlay=DIRECTORY_LOWER:DIRECTORY_UPPER:DIRECTORY_WORK:DIRECTORY_MERGED] [--cnt.overlay-options=OPTION[,OPTION]] [-b|--bind DIRECTORY:DIRECTORY[:OPTIONS]] [--bind-ro DIRECTORY:DIRECTORY[:OPTIONS]] [-c|--capability CAPABILITY[,CAPABILITY]] [-d|--drop-capability DROP_CAPABILITY[,DROP_CAPABILITY]] [-s|--script SCRIPT] [-v|--verbose] [-- SCRIPT_OPTIONS]" >&2
+ echo "Usage: ${PROGRAM} ${COMMAND} -n|--name NAME [--cnt.container-server=true|false|FQDN] [--cnt.overlay=DIRECTORY_LOWER:DIRECTORY_UPPER:DIRECTORY_WORK:DIRECTORY_MERGED] [--cnt.overlay-options=OPTION[,OPTION]] [--cnt.start=OPTION[,OPTION]] [-b|--bind DIRECTORY:DIRECTORY[:OPTIONS]] [--bind-ro DIRECTORY:DIRECTORY[:OPTIONS]] [-c|--capability CAPABILITY[,CAPABILITY]] [-d|--drop-capability DROP_CAPABILITY[,DROP_CAPABILITY]] [-s|--script SCRIPT] [-v|--verbose] [-- SCRIPT_OPTIONS]" >&2
exit 1
}
@@ -248,6 +253,7 @@ sed -e "s|@CNT_AUTO@|${CNT_AUTO}|g" \
-e "s|@CNT_NETWORK_BRIDGE@|${CNT_NETWORK_BRIDGE}|g" \
-e "s|@CNT_OVERLAY@|${CNT_OVERLAY}|g" \
-e "s|@CNT_OVERLAY_OPTIONS@|${CNT_OVERLAY_OPTIONS}|g" \
+ -e "s|@CNT_START@|${CNT_START}|g" \
-e "s|@NAME@|${NAME}|g" \
-e "s|@BIND@|${BIND}|g" \
-e "s|@BIND_RO@|${BIND_RO}|g" \
diff --git a/libexec/container/start b/libexec/container/start
index 089aa7d..08c3611 100755
--- a/libexec/container/start
+++ b/libexec/container/start
@@ -131,6 +131,12 @@ then
exit 1
fi
+# options
+if grep -Eqs "^ *cnt.start=" "${CONFIG}/${NAME}.conf" | grep -qs force
+then
+ FORCE="true"
+fi
+
case "${START}" in
false)
STATE="$(machinectl show ${NAME} 2>&1 | awk -FState= '/^State=/ { print $2 }')"
diff --git a/share/config/container.conf.in b/share/config/container.conf.in
index d930803..3ab014d 100644
--- a/share/config/container.conf.in
+++ b/share/config/container.conf.in
@@ -6,6 +6,7 @@ cnt.container-server=@CNT_CONTAINER_SERVER@
cnt.network-bridge=@CNT_NETWORK_BRIDGE@
cnt.overlay=@CNT_OVERLAY@
cnt.overlay-options=@CNT_OVERLAY_OPTIONS@
+cnt.start=@CNT_START@
bind=@BIND@
bind-ro=@BIND_RO@
boot=@BOOT@
diff --git a/share/man/container-create.1.txt b/share/man/container-create.1.txt
index c49ac9c..4de8171 100644
--- a/share/man/container-create.1.txt
+++ b/share/man/container-create.1.txt
@@ -70,6 +70,9 @@ The following container-create options are available:
*--cnt.overlay-options='OPTION1,OPTION2[;OPTION3,OPTION4]'*::
Specify container overlay mount options, see Documentation/filesystems/overlayfs.txt.
+*--cnt.start='OPTION1[,OPTION2,...]'*::
+ Specify container start options, see container-start(1).
+
SCRIPTS
-------