|
@@ -11,22 +11,18 @@ import (
|
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-var configFile = flag.String("config", "", "path to config file")
|
|
|
|
|
-var homePath = flag.String("homepath", "", "path to grafana install/home path, defaults to working directory")
|
|
|
|
|
-
|
|
|
|
|
func runDbCommand(command func(commandLine CommandLine) error) func(context *cli.Context) {
|
|
func runDbCommand(command func(commandLine CommandLine) error) func(context *cli.Context) {
|
|
|
return func(context *cli.Context) {
|
|
return func(context *cli.Context) {
|
|
|
|
|
+ cmd := &contextCommandLine{context}
|
|
|
|
|
|
|
|
- flag.Parse()
|
|
|
|
|
setting.NewConfigContext(&setting.CommandLineArgs{
|
|
setting.NewConfigContext(&setting.CommandLineArgs{
|
|
|
- Config: *configFile,
|
|
|
|
|
- HomePath: *homePath,
|
|
|
|
|
|
|
+ Config: cmd.String("config"),
|
|
|
|
|
+ HomePath: cmd.String("homepath"),
|
|
|
Args: flag.Args(),
|
|
Args: flag.Args(),
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
sqlstore.NewEngine()
|
|
sqlstore.NewEngine()
|
|
|
|
|
|
|
|
- cmd := &contextCommandLine{context}
|
|
|
|
|
if err := command(cmd); err != nil {
|
|
if err := command(cmd); err != nil {
|
|
|
logger.Errorf("\n%s: ", color.RedString("Error"))
|
|
logger.Errorf("\n%s: ", color.RedString("Error"))
|
|
|
logger.Errorf("%s\n\n", err)
|
|
logger.Errorf("%s\n\n", err)
|
|
@@ -95,6 +91,16 @@ var adminCommands = []cli.Command{
|
|
|
Name: "reset-admin-password",
|
|
Name: "reset-admin-password",
|
|
|
Usage: "reset-admin-password <new password>",
|
|
Usage: "reset-admin-password <new password>",
|
|
|
Action: runDbCommand(resetPasswordCommand),
|
|
Action: runDbCommand(resetPasswordCommand),
|
|
|
|
|
+ Flags: []cli.Flag{
|
|
|
|
|
+ cli.StringFlag{
|
|
|
|
|
+ Name: "homepath",
|
|
|
|
|
+ Usage: "path to grafana install/home path, defaults to working directory",
|
|
|
|
|
+ },
|
|
|
|
|
+ cli.StringFlag{
|
|
|
|
|
+ Name: "config",
|
|
|
|
|
+ Usage: "path to config file",
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
|
|
|