From 02183cf8a39fe95d999bd5a3c982f2fb10ed0dba Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 5 Jun 2022 07:21:57 +0200 Subject: Automatically restoring previous state after reboot by using last-on/last-off config options, thanks to Sakirnth Nagarasa for the use-case and idea. Signed-off-by: Daniel Baumann --- libexec/container/stop | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'libexec/container/stop') 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) -- cgit v1.2.3