package nginx import ( "fmt" "github.com/urfave/cli/v2" "gitea.micah.wiki/pandora/magic/config" ) func Nginx() *cli.Command { return &cli.Command{ Name: "nginx", Action: func(c *cli.Context) error { conf := config.Get() if len(conf.Nginx) == 0 { return fmt.Errorf("未找到nginx的配置") } current, err := ReadCurrent(c.Context, conf) if err != nil { return err } exist, err := Check(c.Context, current) if err != nil { return err } if !exist { return fmt.Errorf("在 $PATH 中未找到nginx,请自行安装,并配置在 $PATH 中") } err = Create(c.Context, current) if err != nil { return err } restart := ReadRestart(c.Context) if restart { err = ReStart(c.Context) if err != nil { return err } } return nil }, } }