diff sbin/ftjail @ 650:5a367d44b480

ftjail: Refactor the result checks for _get_jail_from_path
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 27 Sep 2024 21:23:19 +0200
parents b0e8b5cf5d33
children 39a7594b45f9
line wrap: on
line diff
--- a/sbin/ftjail	Fri Sep 27 21:21:34 2024 +0200
+++ b/sbin/ftjail	Fri Sep 27 21:23:19 2024 +0200
@@ -911,17 +911,26 @@
     _dir_basename="$(basename "${_directory}")"
 
     set +e
-    _jailname=$(_get_jail_from_path "${_directory}")
+    _jailname="$(_get_jail_from_path "${_directory}")"
     _res=$?
     set -e
-    if [ ${_res} -ne 3 ] ; then
-        if [ ${_res} -ne 0 ] ; then
+    case ${_res} in
+        0)
+            err "Please stop the \`${_jailname}' jail"
+            return 1
+            ;;
+        2)
+            err "Jail \`${_jailname}' is currently yet dying"
+            return 1
+            ;;
+        3)
+            true
+            ;;
+        *)
             return ${_res}
-        else
-            echo "ERROR: Please stop the \`${_jailname}' jail" >&2
-            return 1
-        fi
-    fi
+            ;;
+    esac
+        
     #
     # Check whether additional log sockets are opened at their default
     # locations. Because they hinder proper unmounting of filesystems.