v0.3.0
* Getting environment variables and passwords from Vault (not tested yet) * Vault configuration to config (not tested yet) * Ability to run scripts from file on local machine on the remote host * Ability to get ouput in the notification of a list for individual commands or all commands * Make SSH connections close after all commands have been run; reuse previous connections if needed
This commit is contained in:
3
cmd/.gitignore
vendored
3
cmd/.gitignore
vendored
@ -1 +1,2 @@
|
||||
*.yaml
|
||||
*.yaml
|
||||
*.yml
|
@ -12,9 +12,9 @@ import (
|
||||
|
||||
var (
|
||||
backupCmd = &cobra.Command{
|
||||
Use: "backup [--lists=list1,list2]",
|
||||
Use: "backup [--lists=list1,list2,... | -l list1, list2,...]",
|
||||
Short: "Runs commands defined in config file.",
|
||||
Long: "Backup executes commands defined in config file.\nUse the --lists flag to execute the specified commands. If not specified, all lists will be executed.",
|
||||
Long: "Backup executes commands defined in config file.\nUse the --lists or -l flag to execute the specified lists. If not flag is not given, all lists will be executed.",
|
||||
Run: Backup,
|
||||
}
|
||||
)
|
||||
@ -34,7 +34,7 @@ func Backup(cmd *cobra.Command, args []string) {
|
||||
|
||||
config := backy.ReadConfig(backyConfOpts)
|
||||
|
||||
config.RunBackyConfig("", backyConfOpts)
|
||||
config.RunListConfig("", backyConfOpts)
|
||||
for _, host := range config.Hosts {
|
||||
if host.SshClient != nil {
|
||||
host.SshClient.Close()
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
var (
|
||||
cronCmd = &cobra.Command{
|
||||
Use: "cron [flags]",
|
||||
Short: "Runs command lists defined in config file.",
|
||||
Short: "Starts a scheduler that runs lists defined in config file.",
|
||||
Long: `Cron starts a scheduler that executes command lists at the time defined in config file.`,
|
||||
Run: cron,
|
||||
}
|
||||
@ -19,6 +19,6 @@ func cron(cmd *cobra.Command, args []string) {
|
||||
|
||||
opts := backy.NewOpts(cfgFile, backy.UseCron())
|
||||
opts.InitConfig()
|
||||
|
||||
backy.ReadConfig(opts).Cron()
|
||||
backy.ReadConfig(opts)
|
||||
opts.Cron()
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ import (
|
||||
var (
|
||||
execCmd = &cobra.Command{
|
||||
Use: "exec command ...",
|
||||
Short: "Runs commands defined in config file.",
|
||||
Long: `Exec executes commands defined in config file.`,
|
||||
Short: "Runs commands defined in config file in order given.",
|
||||
Long: `Exec executes commands defined in config file in order given.`,
|
||||
Run: execute,
|
||||
}
|
||||
)
|
||||
|
@ -7,29 +7,35 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const versionStr = "0.2.4"
|
||||
const versionStr = "0.3.0"
|
||||
|
||||
var (
|
||||
versionCmd = &cobra.Command{
|
||||
Use: "version [flags]",
|
||||
Short: "Prints the version and exits.",
|
||||
Short: "Prints the version and exits",
|
||||
Long: "Prints the version and exits. No arguments just prints the version number only.",
|
||||
Run: version,
|
||||
}
|
||||
numOnly bool
|
||||
vPre bool
|
||||
)
|
||||
|
||||
func version(cmd *cobra.Command, args []string) {
|
||||
func init() {
|
||||
versionCmd.PersistentFlags().BoolVarP(&numOnly, "num", "n", true, "Output the version number only.")
|
||||
versionCmd.PersistentFlags().BoolVarP(&vPre, "vpre", "V", false, "Output the version with v prefixed.")
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().BoolVarP(&numOnly, "num", "n", true, "Output the version number only.")
|
||||
cmd.PersistentFlags().BoolVarP(&vPre, "vpre", "V", false, "Output the version with v prefixed.")
|
||||
func version(cmd *cobra.Command, args []string) {
|
||||
|
||||
if numOnly && !vPre {
|
||||
fmt.Printf("%s\n", versionStr)
|
||||
} else if vPre {
|
||||
fmt.Printf("v%s", versionStr)
|
||||
} else if vPre && !numOnly {
|
||||
fmt.Printf("v%s\n", versionStr)
|
||||
} else {
|
||||
fmt.Printf("Backy version: %s", versionStr)
|
||||
if vPre && numOnly {
|
||||
fmt.Println("vpre flag and num flag both detected!")
|
||||
}
|
||||
fmt.Printf("Backy version: %s\n", versionStr)
|
||||
}
|
||||
|
||||
os.Exit(0)
|
||||
|
Reference in New Issue
Block a user