[lxc-devel] [lxd-pkg-ubuntu/dpm-cosmic] Allow skipping snap installation in preinst when lxd is not activated yet
rbalint on Github
lxc-bot at linuxcontainers.org
Fri Apr 5 14:22:35 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 384 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190405/bb945c3f/attachment.bin>
-------------- next part --------------
From 26e3b3e3d67e64adc2615c01f493c8b1bad33e0c Mon Sep 17 00:00:00 2001
From: Balint Reczey <balint.reczey at canonical.com>
Date: Fri, 5 Apr 2019 13:05:21 +0200
Subject: [PATCH] Allow skipping snap installation in preinst when lxd is not
activated yet
LP: #1821924
Signed-off-by: Balint Reczey <balint.reczey at canonical.com>
---
debian/lxd.preinst | 81 ++++++++++++++++++++++++-----------------
debian/lxd.templates | 6 ++-
debian/po/templates.pot | 11 +++++-
lxc | 6 +++
lxd | 6 +++
5 files changed, 74 insertions(+), 36 deletions(-)
diff --git a/debian/lxd.preinst b/debian/lxd.preinst
index ea0ec51b0..e61309932 100644
--- a/debian/lxd.preinst
+++ b/debian/lxd.preinst
@@ -16,6 +16,7 @@ case "$1" in
# Check store connectivity
echo "==> Checking connectivity with the snap store"
COUNT=0
+ SKIP=false
while :; do
snap info lxd >/dev/null 2>&1 && break
@@ -41,6 +42,14 @@ case "$1" in
if [ "${RET}" = "Abort" ]; then
echo "===> Aborting at user request"
exit 1
+ elif [ "${RET}" = "Skip" ]; then
+ if ! [ -e "/var/lib/lxd/server.crt" ]; then
+ echo "===> Skipping at user request"
+ SKIP=true
+ break
+ else
+ echo "===> Skipping is not allowed, lxd is activated on the system"
+ fi
fi
if [ "${COUNT}" = "0" ]; then
@@ -51,48 +60,53 @@ case "$1" in
COUNT=$((COUNT+1))
done
- # Set the default track
- db_get lxd/snap-track
- if [ -z "${RET}" ]; then
- if [ -e "/etc/os-release" ] && grep -q " LTS " /etc/os-release; then
- db_set lxd/snap-track "3.0"
+ if ! $SKIP; then
+
+ # Set the default track
+ db_get lxd/snap-track
+ if [ -z "${RET}" ]; then
+ if [ -e "/etc/os-release" ] && grep -q " LTS " /etc/os-release; then
+ db_set lxd/snap-track "3.0"
+ fi
+
+ db_fset lxd/snap-track seen false
fi
- db_fset lxd/snap-track seen false
- fi
+ # Prompt about track
+ db_input high lxd/snap-track || true
+ db_go
- # Prompt about track
- db_input high lxd/snap-track || true
- db_go
+ # Get the track
+ db_get lxd/snap-track
+ track=${RET}
- # Get the track
- db_get lxd/snap-track
- track=${RET}
+ # Workaround for broken systems
+ mkdir -p /lib/modules
- # Workaround for broken systems
- mkdir -p /lib/modules
+ # Extract the OS release
+ RELEASE="18.10"
+ if [ -e "/etc/os-release" ]; then
+ RELEASE=$(. /etc/os-release && echo "${VERSION_ID}")
+ fi
- # Extract the OS release
- RELEASE="18.10"
- if [ -e "/etc/os-release" ]; then
- RELEASE=$(. /etc/os-release && echo "${VERSION_ID}")
- fi
+ # Install the snap
+ echo "==> Installing the LXD snap from the ${track} track for ubuntu-${RELEASE}"
+ if [ "${track}" = "latest" ]; then
+ snap install lxd --channel="stable/ubuntu-${RELEASE}"
+ else
+ snap install lxd --channel="${track}/stable/ubuntu-${RELEASE}"
+ fi
- # Install the snap
- echo "==> Installing the LXD snap from the ${track} track for ubuntu-${RELEASE}"
- if [ "${track}" = "latest" ]; then
- snap install lxd --channel="stable/ubuntu-${RELEASE}"
- else
- snap install lxd --channel="${track}/stable/ubuntu-${RELEASE}"
- fi
+ if [ -e "/var/lib/lxd/server.crt" ]; then
+ echo "==> Waiting for LXD to be online (10min timeout)"
+ /snap/bin/lxd waitready --timeout=600
- if [ -e "/var/lib/lxd/server.crt" ]; then
- echo "==> Waiting for LXD to be online (10min timeout)"
- /snap/bin/lxd waitready --timeout=600
+ echo "==> Running migration from Deb to Snap"
+ export LXD_PREINST=1
+ /snap/bin/lxd.migrate --yes
+ fi
- echo "==> Running migration from Deb to Snap"
- export LXD_PREINST=1
- /snap/bin/lxd.migrate --yes
+ echo "=> Snap installation complete"
fi
echo "==> Cleaning up leftovers"
@@ -106,7 +120,6 @@ case "$1" in
rm -rf --one-file-system /var/lib/lxd
rm -rf --one-file-system /var/log/lxd
- echo "=> Snap installation complete"
;;
abort-upgrade|abort-remove|abort-deconfigure)
diff --git a/debian/lxd.templates b/debian/lxd.templates
index d8f530ade..5798cafe7 100644
--- a/debian/lxd.templates
+++ b/debian/lxd.templates
@@ -13,7 +13,7 @@ _Description: Upgrade to the LXD snap
Template: lxd/snap-no-connectivity
Type: select
-Choices: Retry, Abort
+Choices: Retry, Abort, Skip
_Description: Unable to reach the snap store
Your system is unable to reach the snap store, please make sure you're
connected to the Internet and update any firewall or proxy settings as
@@ -23,6 +23,10 @@ _Description: Unable to reach the snap store
.
Aborting will cause the upgrade to fail and will require it to be re-attempted
once snapd is functional on the system.
+ .
+ Skipping will let the package upgrade to continue, but the lxd commands
+ will not be functional until the lxd snap is installed. Skipping is allowed
+ only when lxd is not activated on the system.
Template: lxd/snap-track
Type: select
diff --git a/debian/po/templates.pot b/debian/po/templates.pot
index 2e5ccdefd..3d1c56869 100644
--- a/debian/po/templates.pot
+++ b/debian/po/templates.pot
@@ -9,7 +9,7 @@ msgstr ""
"Project-Id-Version: lxd\n"
"Report-Msgid-Bugs-To: lxd at packages.debian.org\n"
"POT-Creation-Date: 2018-09-13 10:25-0400\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"PO-Revision-Date: 2019-04-05 13:08+0200\n"
"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
"Language-Team: LANGUAGE <LL at li.org>\n"
"Language: \n"
@@ -76,6 +76,15 @@ msgid ""
"attempted once snapd is functional on the system."
msgstr ""
+#. Type: select
+#. Description
+#: ../lxd.templates:2001
+msgid ""
+"Skipping will let the package upgrade to continue, but the lxd commands will "
+"not be functional until the lxd snap is installed. Skipping is allowed "
+"only when lxd is not activated on the system."
+msgstr ""
+
#. Type: select
#. Description
#: ../lxd.templates:3001
diff --git a/lxc b/lxc
index 96b1888d7..aa63bda08 100755
--- a/lxc
+++ b/lxc
@@ -1,2 +1,8 @@
#!/bin/sh
+if ! [ -x /snap/bin/lxc ]; then
+ echo "Command '$0' requires the lxd snap to be installed." >2
+ echo "Please install it with:" >2
+ echo "" >2
+ echo "snap install lxd # version 3.11" >2
+fi
exec /snap/bin/lxc "$@"
diff --git a/lxd b/lxd
index bf0a587c4..6890d2732 100755
--- a/lxd
+++ b/lxd
@@ -1,2 +1,8 @@
#!/bin/sh
+if ! [ -x /snap/bin/lxd ]; then
+ echo "Command '$0' requires the lxd snap to be installed." >2
+ echo "Please install it with:" >2
+ echo "" >2
+ echo "snap install lxd # version 3.11" >2
+fi
exec /snap/bin/lxd "$@"
More information about the lxc-devel
mailing list