summaryrefslogtreecommitdiffstats
path: root/libexec/container/stop
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2022-06-05 05:21:57 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2022-06-05 08:23:40 +0000
commit02183cf8a39fe95d999bd5a3c982f2fb10ed0dba (patch)
treef2454b0fadc3618c71c28345968265fb3aecc24a /libexec/container/stop
parentTracking container state in run files in /var/lib/compute-tools. (diff)
downloadcompute-tools-02183cf8a39fe95d999bd5a3c982f2fb10ed0dba.tar.xz
compute-tools-02183cf8a39fe95d999bd5a3c982f2fb10ed0dba.zip
Automatically restoring previous state after reboot by using last-on/last-off config options, thanks to Sakirnth Nagarasa <sakirnth@gmail.com> for the use-case and idea.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to 'libexec/container/stop')
-rwxr-xr-xlibexec/container/stop21
1 files changed, 18 insertions, 3 deletions
diff --git a/libexec/container/stop b/libexec/container/stop
index 793b323..8ca98ce 100755
--- a/libexec/container/stop
+++ b/libexec/container/stop
@@ -34,7 +34,7 @@ Parameters ()
{
OPTIONS_ALL=""
- GETOPT_LONGOPTIONS="name:,force,interactive,kill,clean,verbose,"
+ GETOPT_LONGOPTIONS="name:,force,interactive,kill,clean,stateless,verbose,"
GETOPT_OPTIONS="n:,f,i,k,v,"
PARAMETERS="$(getopt --longoptions ${GETOPT_LONGOPTIONS} --name=${COMMAND} --options ${GETOPT_OPTIONS} --shell sh -- ${@})"
@@ -84,6 +84,14 @@ Parameters ()
OPTONS_ALL="${OPTIONS_ALL} --clean"
;;
+ --stateless)
+ # internal option
+ STATELESS="true"
+ shift 1
+
+ OPTIONS_ALL="${OPTIONS_ALL} --stateless"
+ ;;
+
-v|--verbose)
VERBOSE="true"
shift 1
@@ -326,8 +334,15 @@ case "${KILL}" in
;;
esac
-mkdir -p "/var/lib/${SOFTWARE}/state"
-echo "stop" > "/var/lib/${SOFTWARE}/state/${NAME}.run"
+case "${STATELESS}" in
+ true)
+ ;;
+
+ *)
+ mkdir -p "/var/lib/${SOFTWARE}/state"
+ echo "stop" > "/var/lib/${SOFTWARE}/state/${NAME}.run"
+ ;;
+esac
case "${VERBOSE}" in
true)