[catalyst] Add flag to disable NUC reboot server.

This can be used by builds that do not build zedboot.zbi.

Change-Id: I79a8771ea5dfc68e127326814aa19aab0c186dcd
diff --git a/cmd/catalyst/catalyst_test.go b/cmd/catalyst/catalyst_test.go
index e292bd1..2f5f115 100644
--- a/cmd/catalyst/catalyst_test.go
+++ b/cmd/catalyst/catalyst_test.go
@@ -120,7 +120,7 @@
 // Test that NUC server does not start up when port environment variable isn't set.
 func TestNUCServerNonexistence(t *testing.T) {
 	var devices []*devicePkg.DeviceTarget
-	srv, err := runNUCServer(context.Background(), devices)
+	srv, err := runNUCServer(context.Background(), devices, false)
 	if srv != nil {
 		t.Errorf("NUC server was created without port set.")
 	} else if err != nil {
@@ -128,11 +128,24 @@
 	}
 }
 
+// Test that NUC server is disabled when flag is set and port environment variable is set.
+func TestNUCServerDisabled(t *testing.T) {
+	var devices []*devicePkg.DeviceTarget
+	os.Setenv(portEnvVar, "8000")
+	srv, err := runNUCServer(context.Background(), devices, true)
+	if srv != nil {
+		t.Errorf("NUC server was created without port set.")
+	} else if err != nil {
+		t.Errorf("%v\n", err)
+	}
+	os.Setenv(portEnvVar, "")
+}
+
 // Test that NUC server is started up when port environment variable is set.
 func TestNUCServerExistence(t *testing.T) {
 	var devices []*devicePkg.DeviceTarget
 	os.Setenv(portEnvVar, "8000")
-	srv, err := runNUCServer(context.Background(), devices)
+	srv, err := runNUCServer(context.Background(), devices, false)
 	os.Setenv(portEnvVar, "")
 	if srv == nil {
 		t.Errorf("NUC server was not created even with port var set.")
@@ -152,7 +165,7 @@
 		createMockDevice("dummy2", "00:00:00:00:01", cmd),
 	}
 	os.Setenv(portEnvVar, "8000")
-	srv, err := runNUCServer(context.Background(), devices)
+	srv, err := runNUCServer(context.Background(), devices, false)
 	os.Setenv(portEnvVar, "")
 	if srv == nil {
 		t.Errorf("NUC server was not created even with port var set.")
diff --git a/cmd/catalyst/main.go b/cmd/catalyst/main.go
index 473574b..6b3541c 100644
--- a/cmd/catalyst/main.go
+++ b/cmd/catalyst/main.go
@@ -35,15 +35,17 @@
 )
 
 var (
-	imagesManifest   string
-	deviceConfigPath string
-	bootserverPath   string
+	imagesManifest      string
+	deviceConfigPath    string
+	bootserverPath      string
+	disableRebootServer bool
 )
 
 func init() {
 	flag.StringVar(&imagesManifest, "images", "", "Path to the images manifest json")
 	flag.StringVar(&deviceConfigPath, "config", "", "Path to the device config file")
 	flag.StringVar(&bootserverPath, "bootserver", "", "Path to the bootserver binary")
+	flag.BoolVar(&disableRebootServer, "disable-reboot-server", false, "Disables the NUC soft reboot server")
 }
 
 // Runs a subprocess and sets up a handler that propagates SIGTERM on context cancel.
@@ -77,10 +79,10 @@
 	return cmd.ProcessState.ExitCode()
 }
 
-func runNUCServer(ctx context.Context, devices []*devicePkg.DeviceTarget) (*http.Server, error) {
+func runNUCServer(ctx context.Context, devices []*devicePkg.DeviceTarget, disabled bool) (*http.Server, error) {
 	// Parse the port from the environment variable.
 	portStr := os.Getenv(portEnvVar)
-	if portStr == "" {
+	if portStr == "" || disabled {
 		return nil, nil
 	}
 	port, err := strconv.Atoi(portStr)
@@ -239,8 +241,9 @@
 		}
 	}
 
-	// Set up a NUC server. If the port environment variable is not set, this is a no-op.
-	srv, err := runNUCServer(ctx, devices)
+	// Set up a NUC server. If the port environment variable is not set, or if
+	// the disableRebootServer flag is set, this is a no-op.
+	srv, err := runNUCServer(ctx, devices, disableRebootServer)
 	if err != nil {
 		return failureExitCode, err
 	}