You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
885 B

6 years ago
  1. package main
  2. import (
  3. "flag"
  4. "fmt"
  5. "os"
  6. "strings"
  7. "github.com/chrislusf/seaweedfs/weed/command"
  8. )
  9. var (
  10. options = flag.String("o", "", "comma separated options rw,uid=xxx,gid=xxx")
  11. )
  12. func main() {
  13. flag.Parse()
  14. device := flag.Arg(0)
  15. mountPoint := flag.Arg(1)
  16. fmt.Printf("source: %v\n", device)
  17. fmt.Printf("target: %v\n", mountPoint)
  18. maybeSetupPath()
  19. parts := strings.SplitN(device, "/", 2)
  20. filer, filerPath := parts[0], parts[1]
  21. command.RunMount(
  22. filer, "/"+filerPath, mountPoint, "", "000", "",
  23. 4, true, 0, 1000000)
  24. }
  25. func maybeSetupPath() {
  26. // sudo mount -av may not include PATH in some linux, e.g., Ubuntu
  27. hasPathEnv := false
  28. for _, e := range os.Environ() {
  29. if strings.HasPrefix(e, "PATH=") {
  30. hasPathEnv = true
  31. }
  32. fmt.Println(e)
  33. }
  34. if !hasPathEnv {
  35. os.Setenv("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
  36. }
  37. }