func checkAction(c *cli.Context) { conf, err := config.New() if err != nil { log.Fatal(err) } if !conf.Local { client, err := client.NewClient(BackendAddr()) if err != nil { log.Fatal(err) } var agentConfig *backuper.AgentConfig err = client.GetConfig(&agentConfig) if err != nil { log.Fatal(err) } conf.Write(agentConfig) scheduler, err := schedule.New() if err != nil { log.Fatal(err) } if err := scheduler.UpdateBackup(agentConfig.Period); err != nil { log.Println(err) } if conf.Agent.StartNow { log.Println("StartNow") backupAction(c) conf.Agent.StartNow = !conf.Agent.StartNow conf.Write(agentConfig) } } }
func initAction(c *cli.Context) { checkUID(c.Command.Name) scheduler, err := schedule.New() if err != nil { log.Fatal(err) } if err := scheduler.UpdateCheck(); err != nil { log.Fatal(err) } if c.Args().First() == "local" { // conf := config.Config{Local: true} conf, _ := config.New() conf.Local = true conf.Write(true) } else { if err := initServer(c); err != nil { log.Fatal(err) } } fmt.Println("Success! This server is ready to backup.") }