seaweedfs/weed/command/shell.go

48 lines
1.1 KiB
Go
Raw Normal View History

package command
2012-08-24 11:56:09 +08:00
import (
2019-10-25 22:44:37 +08:00
"fmt"
"github.com/chrislusf/seaweedfs/weed/security"
"github.com/chrislusf/seaweedfs/weed/shell"
"github.com/chrislusf/seaweedfs/weed/util"
)
var (
shellOptions shell.ShellOptions
shellInitialFiler *string
2012-08-24 11:56:09 +08:00
)
func init() {
2013-01-17 16:56:56 +08:00
cmdShell.Run = runShell // break init cycle
shellOptions.Masters = cmdShell.Flag.String("master", "localhost:9333", "comma-separated master servers")
shellInitialFiler = cmdShell.Flag.String("filer", "localhost:8888", "filer host and port")
2012-08-24 11:56:09 +08:00
}
var cmdShell = &Command{
2013-01-17 16:56:56 +08:00
UsageLine: "shell",
Short: "run interactive administrative commands",
Long: `run interactive administrative commands.
2012-08-24 11:56:09 +08:00
`,
}
func runShell(command *Command, args []string) bool {
util.LoadConfiguration("security", false)
shellOptions.GrpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
var err error
shellOptions.FilerHost, shellOptions.FilerPort, err = util.ParseHostPort(*shellInitialFiler)
if err != nil {
fmt.Printf("failed to parse filer %s: %v\n", *shellInitialFiler, err)
2019-10-25 22:44:37 +08:00
return false
}
shellOptions.Directory = "/"
2019-10-25 22:44:37 +08:00
shell.RunShell(shellOptions)
return true
2019-10-25 22:44:37 +08:00
}