zrepl/main.go
Christian Schwarz c69ebd3806 WIP rewrite the daemon
cmd subdir does not build on purpose, it's only left in tree to grab old
code and move it to github.com/zrepl/zrepl/daemon
2018-08-27 22:22:44 +02:00

65 lines
1.3 KiB
Go

// See cmd package.
package main
import (
"github.com/spf13/cobra"
"github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/daemon"
"log"
"os"
)
var rootCmd = &cobra.Command{
Use: "zrepl",
Short: "ZFS dataset replication",
Long: `Replicate ZFS filesystems & volumes between pools:
- push & pull mode
- automatic snapshot creation & pruning
- local / over the network
- ACLs instead of blank SSH access`,
}
var daemonCmd = &cobra.Command{
Use: "daemon",
Short: "daemon",
RunE: func(cmd *cobra.Command, args []string) error {
conf, err := config.ParseConfig(rootArgs.configFile)
if err != nil {
return err
}
return daemon.Run(conf)
},
}
var wakeupCmd = &cobra.Command{
Use: "wakeup",
Short: "wake up jobs",
RunE: func(cmd *cobra.Command, args []string) error {
conf, err := config.ParseConfig(rootArgs.configFile)
if err != nil {
return err
}
return RunWakeup(conf, args)
},
}
var rootArgs struct {
configFile string
}
func init() {
//cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().StringVar(&rootArgs.configFile, "config", "", "config file path")
rootCmd.AddCommand(daemonCmd)
rootCmd.AddCommand(wakeupCmd)
}
func main() {
if err := rootCmd.Execute(); err != nil {
log.Printf("error executing root command: %s", err)
os.Exit(1)
}
}