Autodetect incus/lxd unless specific YNHDEV_BACKEND

This commit is contained in:
selfhoster1312 2024-08-25 10:15:57 +02:00
parent 8db653ea9e
commit 2490e35731
3 changed files with 12 additions and 7 deletions

View file

@ -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

View file

@ -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
lxc="lxc"
fi
else
lxc="${YNHDEV_BACKEND}"
fi
}

View file

@ -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