shell.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package command
  2. import (
  3. "fmt"
  4. "github.com/chrislusf/seaweedfs/weed/security"
  5. "github.com/chrislusf/seaweedfs/weed/shell"
  6. "github.com/chrislusf/seaweedfs/weed/util"
  7. )
  8. var (
  9. shellOptions shell.ShellOptions
  10. shellInitialFilerUrl *string
  11. )
  12. func init() {
  13. cmdShell.Run = runShell // break init cycle
  14. shellOptions.Masters = cmdShell.Flag.String("master", "localhost:9333", "comma-separated master servers")
  15. shellInitialFilerUrl = cmdShell.Flag.String("filer.url", "http://localhost:8888/", "initial filer url")
  16. }
  17. var cmdShell = &Command{
  18. UsageLine: "shell",
  19. Short: "run interactive administrative commands",
  20. Long: `run interactive administrative commands.
  21. `,
  22. }
  23. func runShell(command *Command, args []string) bool {
  24. util.LoadConfiguration("security", false)
  25. shellOptions.GrpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
  26. var filerPwdErr error
  27. shellOptions.FilerHost, shellOptions.FilerPort, shellOptions.Directory, filerPwdErr = util.ParseFilerUrl(*shellInitialFilerUrl)
  28. if filerPwdErr != nil {
  29. fmt.Printf("failed to parse url filer.url=%s : %v\n", *shellInitialFilerUrl, filerPwdErr)
  30. return false
  31. }
  32. shell.RunShell(shellOptions)
  33. return true
  34. }