mirror of
https://github.com/gravitational/teleport
synced 2024-10-21 01:34:01 +00:00
Added Exit(-1) on bad cmd args, fixed bug with SSH and Tun starting with token
This commit is contained in:
parent
4733028760
commit
4d5d0e618f
|
@ -170,7 +170,7 @@ func initSSH(t *TeleportService, cfg Config) error {
|
|||
// this means the server has not been initialized yet we are starting
|
||||
// the registering client that attempts to connect ot the auth server
|
||||
// and provision the keys
|
||||
return initRegister(t, *cfg.SSH.Token, cfg)
|
||||
return initRegister(t, *cfg.SSH.Token, cfg, initSSHEndpoint)
|
||||
}
|
||||
return initSSHEndpoint(t, cfg)
|
||||
}
|
||||
|
@ -212,7 +212,8 @@ func initSSHEndpoint(t *TeleportService, cfg Config) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func initRegister(t *TeleportService, token string, cfg Config) error {
|
||||
func initRegister(t *TeleportService, token string, cfg Config,
|
||||
initFunc func(*TeleportService, Config) error) error {
|
||||
// we are on the same server as the auth endpoint
|
||||
// and there's no token. we can handle this
|
||||
if cfg.Auth.Enabled && token == "" {
|
||||
|
@ -236,7 +237,7 @@ func initRegister(t *TeleportService, token string, cfg Config) error {
|
|||
return err
|
||||
}
|
||||
log.Infof("teleport:register registered successfully")
|
||||
return initSSHEndpoint(t, cfg)
|
||||
return initFunc(t, cfg)
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
@ -256,7 +257,7 @@ func initTun(t *TeleportService, cfg Config) error {
|
|||
// this means the server has not been initialized yet we are starting
|
||||
// the registering client that attempts to connect ot the auth server
|
||||
// and provision the keys
|
||||
return initRegister(t, *cfg.Tun.Token, cfg)
|
||||
return initRegister(t, *cfg.Tun.Token, cfg, initTunAgent)
|
||||
}
|
||||
return initTunAgent(t, cfg)
|
||||
}
|
||||
|
|
|
@ -62,12 +62,12 @@ func main() {
|
|||
srv, err := service.NewTeleport(cfg)
|
||||
if err != nil {
|
||||
fmt.Printf("error starting teleport: %v\n", err)
|
||||
return
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
||||
if err := srv.Start(); err != nil {
|
||||
log.Errorf("teleport failed to start with error: %v", err)
|
||||
return
|
||||
os.Exit(-1)
|
||||
}
|
||||
srv.Wait()
|
||||
}
|
||||
|
@ -162,7 +162,11 @@ func getFilledConfig(args []string, commandIsFirst bool) service.Config {
|
|||
|
||||
cfg.Tun.Token = tunCmd.Flag("token", "one time provisioning token for tun agent to register with authority").OverrideDefaultFromEnvar("TELEPORT_TUN_TOKEN").String()
|
||||
|
||||
kingpin.MustParse(app.Parse(args))
|
||||
_, err := app.Parse(args)
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %s, try --help\n", err.Error())
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
||||
return cfg
|
||||
|
||||
|
|
Loading…
Reference in a new issue