34 lines
1.4 KiB
Go
34 lines
1.4 KiB
Go
package edgecmd
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
"iop/packages/go/hostsetup"
|
|
)
|
|
|
|
func setupCmd() *cobra.Command {
|
|
var opts hostsetup.SetupOptions
|
|
c := &cobra.Command{
|
|
Use: "setup",
|
|
Short: "Prepare host environment and systemd unit for iop-edge",
|
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
|
if isConfigExplicit(cmd) {
|
|
opts.ConfigPath = configFlagValue(cmd)
|
|
} else {
|
|
opts.ConfigPath = "/etc/iop/edge.yaml"
|
|
}
|
|
return hostsetup.Run(cmd.Context(), hostsetup.EdgeSpec(), opts, cmd.OutOrStdout())
|
|
},
|
|
}
|
|
c.Flags().StringVar(&opts.BinaryPath, "binary", "", "path to iop-edge binary (defaults to current executable)")
|
|
c.Flags().StringVar(&opts.DataDir, "data-dir", "", "data directory (defaults to spec)")
|
|
c.Flags().StringVar(&opts.UnitPath, "unit", "", "systemd unit path (defaults to spec)")
|
|
c.Flags().StringVar(&opts.User, "user", "", "service user")
|
|
c.Flags().StringVar(&opts.Group, "group", "", "service group")
|
|
c.Flags().BoolVar(&opts.Enable, "enable", false, "enable the systemd unit")
|
|
c.Flags().BoolVar(&opts.Start, "start", false, "start the systemd unit")
|
|
c.Flags().BoolVar(&opts.Restart, "restart", false, "restart the systemd unit")
|
|
c.Flags().BoolVar(&opts.DryRun, "dry-run", false, "print plan and previews without making changes")
|
|
c.Flags().BoolVar(&opts.OverwriteConfig, "overwrite-config", false, "overwrite an existing config file")
|
|
return c
|
|
}
|