2021-07-21 14:54:30 +12:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
case ${PASS} in
|
|
|
|
ubuntu-server-minimal.ubuntu-server)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2024-01-18 10:45:59 +00:00
|
|
|
# The unminimize script will try to install the lxd snap using the shim script
|
|
|
|
# /usr/sbin/lxd from the lxd-installer package.
|
|
|
|
# We can't do that at this stage so just neuter the lxd command (the snap
|
2021-07-21 14:54:30 +12:00
|
|
|
# will get properly seeded by generic machinery).
|
2024-01-22 12:41:41 +00:00
|
|
|
if [ -f "/usr/sbin/lxd" ]; then
|
2024-01-22 12:48:55 +00:00
|
|
|
dpkg-divert --add --divert /usr/sbin/lxd.REAL --rename /usr/sbin/lxd
|
2024-01-18 10:45:59 +00:00
|
|
|
ln -s /bin/true /usr/sbin/lxd
|
|
|
|
yes | /usr/local/sbin/unminimize
|
|
|
|
# unminimize also uninstalls lxd-installer package
|
2024-01-22 12:48:55 +00:00
|
|
|
# and also removed `/usr/sbin/lxd` as a result, so we don't need to restore, but
|
|
|
|
# we do need to remove the mock we used as part of dpkg-divert
|
|
|
|
# first we need to remove the diversion
|
|
|
|
dpkg-divert --remove --no-rename /usr/sbin/lxd
|
|
|
|
# now remove the renamed file that we originally diverted to
|
|
|
|
rm -v /usr/sbin/lxd.REAL
|
2024-01-18 10:45:59 +00:00
|
|
|
else
|
2024-01-22 12:44:08 +00:00
|
|
|
# if /usr/sbin/lxd doesn't exist then lxd-installer package isn't installed.
|
|
|
|
# Instead, we can mock the command to avoid the unminimize script failing
|
2024-01-18 10:45:59 +00:00
|
|
|
ln -s /bin/true /usr/sbin/lxd
|
|
|
|
yes | /usr/local/sbin/unminimize
|
2024-01-22 12:44:08 +00:00
|
|
|
# as the lxd-installer package was not installed and thus not removed by `unminimize`
|
|
|
|
# the mock /usr/sbin/lxd will still be present, so we need to remove it
|
2024-01-22 12:45:57 +00:00
|
|
|
rm -v /usr/sbin/lxd
|
2024-01-18 10:45:59 +00:00
|
|
|
fi
|