#!/bin/sh

set -eux

. /etc/os-release
echo "Executing test on ${NAME:-Unknown} version ${VERSION_ID:-n/a}"

echo "Check which lxd-installer version we have installed"
dpkg -l | grep -wF lxd-installer

if ! snap list lxd; then
    echo "Manually install LXD snap from default channel"
    snap install lxd
fi

echo "Check that lxc command works"
lxc --version

echo "Disable LXD snap"
snap disable lxd

echo "Verify LXD snap is disabled"
snap list lxd | grep -wF disabled

echo "Report list of installed snaps:"
snap list

echo "Check that lxc command doesn't work"
! lxc --version

echo "Verify LXD snap is still disabled"
snap list lxd | grep -wF disabled
