From 814f41f62be1187cb6bd6dd9845e7d9f71275320 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 24 Oct 2022 01:46:37 +0200 Subject: [PATCH] Implement ynh_lxc_is_stopped --- lib/ynh_lxd | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/ynh_lxd b/lib/ynh_lxd index 94b190a..644508d 100644 --- a/lib/ynh_lxd +++ b/lib/ynh_lxd @@ -68,6 +68,28 @@ ynh_lxc_is_started () { fi } +# Check if an LXC container is stopped +# +# usage: ynh_lxc_is_stopped --name=name +# | arg: -n, --name= - name of the LXC +# +# Requires YunoHost version *.*.* or higher. +ynh_lxc_is_stopped () { + # Declare an array to define the options of this helper. + local legacy_args=n + local -A args_array=([n]=name=) + local name + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + if [ "$(ynh_lxc_status --name=$name)" == Stopped ] + then + return 0 + else + return 1 + fi +} + # Stopping an LXC container # # usage: ynh_lxc_stop --name=name