Example #1
0
func (boot bootstrap) Run() (settingsService boshsettings.Service, err error) {
	err = boot.platform.SetupRuntimeConfiguration()
	if err != nil {
		err = bosherr.WrapError(err, "Setting up runtime configuration")
		return
	}

	err = boot.infrastructure.SetupSsh(boshsettings.VCAP_USERNAME)
	if err != nil {
		err = bosherr.WrapError(err, "Setting up ssh")
		return
	}

	settings, err := boot.fetchInitialSettings()
	if err != nil {
		err = bosherr.WrapError(err, "Fetching settings")
		return
	}
	settingsService = boshsettings.NewService(settings, boot.infrastructure.GetSettings)

	err = boot.setUserPasswords(settings)
	if err != nil {
		err = bosherr.WrapError(err, "Settings user password")
		return
	}

	err = boot.platform.SetupHostname(settings.AgentId)
	if err != nil {
		err = bosherr.WrapError(err, "Setting up hostname")
		return
	}

	err = boot.infrastructure.SetupNetworking(settings.Networks)
	if err != nil {
		err = bosherr.WrapError(err, "Setting up networking")
		return
	}

	err = boot.platform.SetTimeWithNtpServers(settings.Ntp)
	if err != nil {
		err = bosherr.WrapError(err, "Setting up NTP servers")
		return
	}

	ephemeralDiskPath, found := boot.infrastructure.GetEphemeralDiskPath(settings.Disks.Ephemeral)
	if !found {
		err = bosherr.New("Could not find ephemeral disk '%s'", settings.Disks.Ephemeral)
		return
	}

	err = boot.platform.SetupEphemeralDiskWithPath(ephemeralDiskPath)
	if err != nil {
		err = bosherr.WrapError(err, "Setting up ephemeral disk")
		return
	}

	if len(settings.Disks.Persistent) > 1 {
		err = errors.New("Error mounting persistent disk, there is more than one persistent disk")
		return
	}

	err = boot.platform.SetupTmpDir()
	if err != nil {
		err = bosherr.WrapError(err, "Changing ownership of /tmp")
		return
	}

	for _, devicePath := range settings.Disks.Persistent {
		err = boot.platform.MountPersistentDisk(devicePath, boot.dirProvider.StoreDir())
		if err != nil {
			err = bosherr.WrapError(err, "Mounting persistent disk")
			return
		}
	}

	err = boot.platform.SetupMonitUser()
	if err != nil {
		err = bosherr.WrapError(err, "Setting up monit user")
		return
	}

	err = boot.platform.StartMonit()
	if err != nil {
		err = bosherr.WrapError(err, "Starting monit")
		return
	}
	return
}
Example #2
0
func (boot bootstrap) Run() (settingsService boshsettings.Service, err error) {
	err = boot.platform.SetupRuntimeConfiguration()
	if err != nil {
		err = bosherr.WrapError(err, "Setting up runtime configuration")
		return
	}

	err = boot.infrastructure.SetupSsh(boot.platform, boshsettings.VCAP_USERNAME)
	if err != nil {
		err = bosherr.WrapError(err, "Setting up ssh")
		return
	}

	settings, err := boot.fetchInitialSettings()
	if err != nil {
		err = bosherr.WrapError(err, "Fetching settings")
		return
	}
	settingsService = boshsettings.NewService(settings, boot.infrastructure.GetSettings)

	err = boot.setUserPasswords(settings)
	if err != nil {
		err = bosherr.WrapError(err, "Settings user password")
		return
	}

	err = boot.platform.SetupHostname(settings.AgentId)
	if err != nil {
		err = bosherr.WrapError(err, "Setting up hostname")
		return
	}

	err = boot.infrastructure.SetupNetworking(boot.platform, settings.Networks)
	if err != nil {
		err = bosherr.WrapError(err, "Setting up networking")
		return
	}

	err = boot.platform.SetTimeWithNtpServers(settings.Ntp)
	if err != nil {
		err = bosherr.WrapError(err, "Setting up NTP servers")
		return
	}

	err = boot.platform.SetupEphemeralDiskWithPath(settings.Disks.Ephemeral)
	if err != nil {
		err = bosherr.WrapError(err, "Setting up ephemeral disk")
		return
	}

	if len(settings.Disks.Persistent) > 1 {
		err = errors.New("Error mounting persistent disk, there is more than one persistent disk")
		return
	}

	for _, devicePath := range settings.Disks.Persistent {
		err = boot.platform.MountPersistentDisk(devicePath, filepath.Join(boshsettings.VCAP_BASE_DIR, "store"))
		if err != nil {
			err = bosherr.WrapError(err, "Mounting persistent disk")
			return
		}
	}

	err = boot.platform.SetupMonitUser()
	if err != nil {
		err = bosherr.WrapError(err, "Setting up monit user")
		return
	}

	err = boot.platform.StartMonit()
	if err != nil {
		err = bosherr.WrapError(err, "Starting monit")
		return
	}
	return
}