[lxc-devel] [lxd/master] lxc: Don't print first-use on init/launch

stgraber on Github lxc-bot at linuxcontainers.org
Thu Sep 26 21:30:19 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190926/601d120e/attachment.bin>
-------------- next part --------------
From e388884d422e548159c8f755b84a6ac9779be2f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 26 Sep 2019 17:29:33 -0400
Subject: [PATCH] lxc: Don't print first-use on init/launch
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #6248

Signed-off-by: St├ęphane Graber <stgraber at ubuntu.com>
---
 lxc/main.go | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lxc/main.go b/lxc/main.go
index c63d040273..b0eed20ef0 100644
--- a/lxc/main.go
+++ b/lxc/main.go
@@ -335,11 +335,20 @@ func (c *cmdGlobal) PreRun(cmd *cobra.Command, args []string) error {
 			}
 		}
 
+		flush := false
 		if runInit {
 			fmt.Fprintf(os.Stderr, i18n.G("If this is your first time running LXD on this machine, you should also run: lxd init")+"\n")
+			flush = true
 		}
 
-		fmt.Fprintf(os.Stderr, i18n.G("To start your first container, try: lxc launch ubuntu:18.04")+"\n\n")
+		if !shared.StringInSlice(cmd.Name(), []string{"init", "launch"}) {
+			fmt.Fprintf(os.Stderr, i18n.G("To start your first container, try: lxc launch ubuntu:18.04")+"\n")
+			flush = true
+		}
+
+		if flush {
+			fmt.Fprintf(os.Stderr, "\n")
+		}
 	}
 
 	// Set the user agent


More information about the lxc-devel mailing list