diff --git a/lib/common.sh b/lib/common.sh index e56b1c4..8b26fea 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -33,9 +33,9 @@ assert_we_are_connected_to_the_internets() { assert_we_have_all_dependencies() { deps=("lynx" "jq" "python3" "pip3") - if [[ "${YNHDEV_BACKEND:-}" == "incus" ]]; then + if [[ "${lxc}" == "incus" ]]; then deps+=(incus) - else + elif [[ "${lxc}" == "lxc" ]]; then deps+=(lxc lxd) fi @@ -87,7 +87,7 @@ function set_incus_remote() function check_lxc_setup() { - if [[ "${YNHDEV_BACKEND:-}" == "incus" ]]; then + if [[ "${lxc}" == "incus" ]]; then check_incus_setup else check_lxd_setup diff --git a/lib/lxc.sh b/lib/lxc.sh index 597fadf..bb5a8a8 100644 --- a/lib/lxc.sh +++ b/lib/lxc.sh @@ -3,10 +3,15 @@ # Check for LXC or Incus function switch_lxc_incus() { - if [[ "${YNHDEV_BACKEND:-}" == "incus" ]]; then - lxc=incus + if [[ -z "${YNHDEV_BACKEND:-}" ]]; then + # Autodetect because no preference was specified + if command -v incus 2>&1 >/dev/null; then + lxc="incus" + else + lxc="lxc" + fi else - lxc=lxc + lxc="${YNHDEV_BACKEND}" fi } diff --git a/package_check.sh b/package_check.sh index 3d710e4..ab45977 100755 --- a/package_check.sh +++ b/package_check.sh @@ -24,7 +24,7 @@ print_help() { -S, --storage-dir DIRECTORY Where to store temporary test files like yunohost backups -h, --help Display this help - Pass YNHDEV_BACKEND=incus to use incus instead of lxd. + Pass YNHDEV_BACKEND=incus|lxd to use a specific LXD-compatible backend. EOF exit 0