summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2016-07-18 13:48:17 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2016-08-04 13:35:54 +0000
commit143d09ef2447e2eb8a21693b6bf9df459367f2aa (patch)
tree36d6ee959177ca24d759c1ad2db715b45ce105eb
parentAdding error message in container start command if container is locked. (diff)
downloadcompute-tools-143d09ef2447e2eb8a21693b6bf9df459367f2aa.tar.xz
compute-tools-143d09ef2447e2eb8a21693b6bf9df459367f2aa.zip
Adding -f, --force option to container start command to remove stray lock files.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
-rwxr-xr-xlib/container/start23
-rw-r--r--share/man/container-start.1.txt3
2 files changed, 21 insertions, 5 deletions
diff --git a/lib/container/start b/lib/container/start
index 7e11121..b8803b2 100755
--- a/lib/container/start
+++ b/lib/container/start
@@ -28,8 +28,8 @@ SYSTEMCTL="true"
Parameters ()
{
- LONG_OPTIONS="name:,nspawn,start,"
- OPTIONS="n:,"
+ LONG_OPTIONS="name:,force,nspawn,start,"
+ OPTIONS="n:f,"
PARAMETERS="$(getopt --longoptions ${LONG_OPTIONS} --name=${COMMAND} --options ${OPTIONS} --shell sh -- ${@})"
@@ -49,6 +49,11 @@ Parameters ()
shift 2
;;
+ -f|--force)
+ FORCE="true"
+ shift 1
+ ;;
+
--nspawn)
# internal option
SYSTEMCTL="false"
@@ -77,7 +82,7 @@ Parameters ()
Usage ()
{
- echo "Usage: container ${COMMAND} -n|--name NAME" >&2
+ echo "Usage: container ${COMMAND} -n|--name NAME [-f|--force]" >&2
exit 1
}
@@ -109,8 +114,16 @@ esac
if [ -e "${MACHINES}/.#${NAME}.lck" ]
then
- echo "'${NAME}': container is locked" >&2
- exit 1
+ case "${FORCE}" in
+ true)
+ rm -f "${MACHINES}/.#${NAME}.lck"
+ ;;
+
+ *)
+ echo "'${NAME}': container is locked" >&2
+ exit 1
+ ;;
+ esac
fi
HOST_ARCHITECTURE="$(dpkg --print-architecture)"
diff --git a/share/man/container-start.1.txt b/share/man/container-start.1.txt
index 313587d..bf1d8de 100644
--- a/share/man/container-start.1.txt
+++ b/share/man/container-start.1.txt
@@ -44,6 +44,9 @@ The following container options are available:
*-n, --name='NAME'*::
Specify container name.
+*-f, --force'*::
+ Removing stray lock file if existing.
+
EXAMPLES
--------