2016-06-02 18:09:14 -07:00
|
|
|
package command
|
2012-08-23 20:56:09 -07:00
|
|
|
|
|
|
|
import (
|
2019-10-25 07:44:37 -07:00
|
|
|
"fmt"
|
|
|
|
|
2019-03-16 13:43:16 -07:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/security"
|
|
|
|
"github.com/chrislusf/seaweedfs/weed/shell"
|
2019-06-05 01:30:24 -07:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/util"
|
2019-03-16 13:43:16 -07:00
|
|
|
)
|
2014-10-26 11:34:55 -07:00
|
|
|
|
2019-03-16 13:43:16 -07:00
|
|
|
var (
|
2020-04-08 23:57:15 -07:00
|
|
|
shellOptions shell.ShellOptions
|
|
|
|
shellInitialFiler *string
|
2012-08-23 20:56:09 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2013-01-17 00:56:56 -08:00
|
|
|
cmdShell.Run = runShell // break init cycle
|
2019-03-16 13:43:16 -07:00
|
|
|
shellOptions.Masters = cmdShell.Flag.String("master", "localhost:9333", "comma-separated master servers")
|
2020-04-08 23:57:15 -07:00
|
|
|
shellInitialFiler = cmdShell.Flag.String("filer", "localhost:8888", "filer host and port")
|
2012-08-23 20:56:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
var cmdShell = &Command{
|
2013-01-17 00:56:56 -08:00
|
|
|
UsageLine: "shell",
|
2019-03-16 13:43:16 -07:00
|
|
|
Short: "run interactive administrative commands",
|
|
|
|
Long: `run interactive administrative commands.
|
2012-08-23 20:56:09 -07:00
|
|
|
|
|
|
|
`,
|
|
|
|
}
|
|
|
|
|
|
|
|
func runShell(command *Command, args []string) bool {
|
2019-03-16 13:43:16 -07:00
|
|
|
|
2019-06-05 01:30:24 -07:00
|
|
|
util.LoadConfiguration("security", false)
|
2020-01-29 09:09:55 -08:00
|
|
|
shellOptions.GrpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
|
2019-03-16 13:43:16 -07:00
|
|
|
|
2020-04-08 23:57:15 -07:00
|
|
|
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 07:44:37 -07:00
|
|
|
return false
|
|
|
|
}
|
2020-04-08 23:57:15 -07:00
|
|
|
shellOptions.Directory = "/"
|
2019-10-25 07:44:37 -07:00
|
|
|
|
2019-03-16 13:43:16 -07:00
|
|
|
shell.RunShell(shellOptions)
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
2019-10-25 07:44:37 -07:00
|
|
|
}
|