diff --git a/src/go/app/startup.go b/src/go/app/startup.go index ca883040..bf05233e 100644 --- a/src/go/app/startup.go +++ b/src/go/app/startup.go @@ -99,6 +99,15 @@ func (this Startup) PreStart(ctx context.Context, exp *types.Experiment) error { continue } + // Check to see if a scenario exists for this experiment and if it + // contains a "startup" app. If so, store it for later use + var startupApp ifaces.ScenarioApp + for _, app := range exp.Apps() { + if app.Name() == "startup" { + startupApp = app + } + } + switch strings.ToLower(node.Hardware().OSType()) { case "linux", "rhel", "centos": var ( @@ -138,6 +147,26 @@ func (this Startup) PreStart(ctx context.Context, exp *types.Experiment) error { if err := tmpl.CreateFileFromTemplate("linux_interfaces.tmpl", node, ifaceFile); err != nil { return fmt.Errorf("generating linux interfaces script: %w", err) } + + if startupApp != nil { + for _, host := range startupApp.Hosts() { + if host.Hostname() == node.General().Hostname() { + + var domainFile = startupDir + "/" + node.General().Hostname() + "-domain.sh" + + node.AddInject( + domainFile, + "/etc/phenix/startup/4_domain-start.sh", + "0755", "", + ) + + if err := tmpl.CreateFileFromTemplate("linux_domain.tmpl", host.Metadata(), domainFile); err != nil { + return fmt.Errorf("generating linux domain script: %w", err) + } + } + } + } + case "windows": startupFile := startupDir + "/" + node.General().Hostname() + "-startup.ps1" @@ -178,15 +207,12 @@ func (this Startup) PreStart(ctx context.Context, exp *types.Experiment) error { Metadata: make(map[string]interface{}), } - // Check to see if a scenario exists for this experiment and if it - // contains a "startup" app. If so, see if this node has a metadata entry + // If startup app exists, see if this node has a metadata entry // in the scenario app configuration. - for _, app := range exp.Apps() { - if app.Name() == "startup" { - for _, host := range app.Hosts() { - if host.Hostname() == node.General().Hostname() { - data.Metadata = host.Metadata() - } + if startupApp != nil { + for _, host := range startupApp.Hosts() { + if host.Hostname() == node.General().Hostname() { + data.Metadata = host.Metadata() } } } diff --git a/src/go/tmpl/templates/linux_domain.tmpl b/src/go/tmpl/templates/linux_domain.tmpl new file mode 100644 index 00000000..ae7c7cd2 --- /dev/null +++ b/src/go/tmpl/templates/linux_domain.tmpl @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "{{ .domain_controller.password }}" | realm join --user={{ .domain_controller.username }} {{ .domain_controller.domain }}