forked from TrueCloudLab/rclone
nfsmount: make the --sudo flag work for umount as well as mount
This commit is contained in:
parent
96f92b7364
commit
62b76b631c
1 changed files with 7 additions and 2 deletions
|
@ -32,7 +32,7 @@ func init() {
|
||||||
cmd.Annotations["status"] = "Experimental"
|
cmd.Annotations["status"] = "Experimental"
|
||||||
mountlib.AddRc(name, mount)
|
mountlib.AddRc(name, mount)
|
||||||
cmdFlags := cmd.Flags()
|
cmdFlags := cmd.Flags()
|
||||||
flags.BoolVarP(cmdFlags, &sudo, "sudo", "", sudo, "Use sudo to run the mount command as root.", "")
|
flags.BoolVarP(cmdFlags, &sudo, "sudo", "", sudo, "Use sudo to run the mount/umount commands as root.", "")
|
||||||
nfs.AddFlags(cmdFlags, &nfsServerOpt)
|
nfs.AddFlags(cmdFlags, &nfsServerOpt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,12 @@ func mount(VFS *vfs.VFS, mountpoint string, opt *mountlib.Options) (asyncerrors
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
out, umountErr = exec.Command("diskutil", "umount", "force", mountpoint).CombinedOutput()
|
out, umountErr = exec.Command("diskutil", "umount", "force", mountpoint).CombinedOutput()
|
||||||
} else {
|
} else {
|
||||||
out, umountErr = exec.Command("umount", "-f", mountpoint).CombinedOutput()
|
cmd := []string{}
|
||||||
|
if sudo {
|
||||||
|
cmd = append(cmd, "sudo")
|
||||||
|
}
|
||||||
|
cmd = append(cmd, "umount", "-f", mountpoint)
|
||||||
|
out, umountErr = exec.Command(cmd[0], cmd[1:]...).CombinedOutput()
|
||||||
}
|
}
|
||||||
shutdownErr := s.Shutdown()
|
shutdownErr := s.Shutdown()
|
||||||
VFS.Shutdown()
|
VFS.Shutdown()
|
||||||
|
|
Loading…
Reference in a new issue