package daemon import ( "context" "fmt" "code.betamike.com/micropelago/pmux/pmuxlib" ) func (d *daemon) newPmuxConfig() (pmuxlib.Config, error) { nebulaPmuxProcConfig, err := nebulaPmuxProcConfig( d.opts.EnvVars.RuntimeDirPath, d.binDirPath, d.hostBootstrap, d.config, ) if err != nil { return pmuxlib.Config{}, fmt.Errorf("generating nebula config: %w", err) } dnsmasqPmuxProcConfig, err := dnsmasqPmuxProcConfig( d.opts.EnvVars.RuntimeDirPath, d.binDirPath, d.hostBootstrap, d.config, ) if err != nil { return pmuxlib.Config{}, fmt.Errorf( "generating dnsmasq config: %w", err, ) } garagePmuxProcConfigs, err := garagePmuxProcConfigs( d.opts.EnvVars.RuntimeDirPath, d.binDirPath, d.hostBootstrap, d.config, ) if err != nil { return pmuxlib.Config{}, fmt.Errorf( "generating garage children configs: %w", err, ) } return pmuxlib.Config{ Processes: append( []pmuxlib.ProcessConfig{ nebulaPmuxProcConfig, dnsmasqPmuxProcConfig, }, garagePmuxProcConfigs..., ), }, nil } func (d *daemon) postPmuxInit(ctx context.Context) error { d.logger.Info(ctx, "waiting for nebula VPN to come online") if err := waitForNebula(ctx, d.hostBootstrap); err != nil { return fmt.Errorf("waiting for nebula to start: %w", err) } d.logger.Info(ctx, "waiting for garage instances to come online") if err := d.waitForGarage(ctx); err != nil { return fmt.Errorf("waiting for garage to start: %w", err) } if len(d.config.Storage.Allocations) > 0 { err := until(ctx, func(ctx context.Context) error { err := garageApplyLayout(ctx, d.logger, d.hostBootstrap, d.config) if err != nil { d.logger.Error(ctx, "applying garage layout", err) return err } return nil }) if err != nil { return fmt.Errorf("applying garage layout: %w", err) } } if !d.opts.SkipHostBootstrapPush { if err := until(ctx, func(ctx context.Context) error { if err := d.putGarageBoostrapHost(ctx); err != nil { d.logger.Error(ctx, "updating host info in garage", err) return err } return nil }); err != nil { return fmt.Errorf("updating host info in garage: %w", err) } } return nil }