mirror of
https://github.com/rclone/rclone
synced 2024-12-03 13:14:37 +01:00
c69cf46f06
Summary: Adding a new command to serve any remote over NFS. This is only useful for new macOS versions where FUSE mounts are not available. * Added willscot/go-nfs dependency and updated go.mod and go.sum Test Plan: ``` go run rclone.go serve nfs --http-url https://beta.rclone.org :http: ``` Test that it is serving correctly by mounting the NFS directory. ``` mkdir nfs-test mount -oport=58654,mountport=58654 localhost: nfs-test ``` Then we can list the mounted directory to see it is working. ``` ls nfs-test ```
66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
// Package serve provides the serve command.
|
|
package serve
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/rclone/rclone/cmd"
|
|
"github.com/rclone/rclone/cmd/serve/dlna"
|
|
"github.com/rclone/rclone/cmd/serve/docker"
|
|
"github.com/rclone/rclone/cmd/serve/ftp"
|
|
"github.com/rclone/rclone/cmd/serve/http"
|
|
"github.com/rclone/rclone/cmd/serve/nfs"
|
|
"github.com/rclone/rclone/cmd/serve/restic"
|
|
"github.com/rclone/rclone/cmd/serve/sftp"
|
|
"github.com/rclone/rclone/cmd/serve/webdav"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func init() {
|
|
Command.AddCommand(http.Command)
|
|
if webdav.Command != nil {
|
|
Command.AddCommand(webdav.Command)
|
|
}
|
|
if restic.Command != nil {
|
|
Command.AddCommand(restic.Command)
|
|
}
|
|
if dlna.Command != nil {
|
|
Command.AddCommand(dlna.Command)
|
|
}
|
|
if ftp.Command != nil {
|
|
Command.AddCommand(ftp.Command)
|
|
}
|
|
if sftp.Command != nil {
|
|
Command.AddCommand(sftp.Command)
|
|
}
|
|
if docker.Command != nil {
|
|
Command.AddCommand(docker.Command)
|
|
}
|
|
if nfs.Command != nil {
|
|
Command.AddCommand(nfs.Command)
|
|
}
|
|
cmd.Root.AddCommand(Command)
|
|
}
|
|
|
|
// Command definition for cobra
|
|
var Command = &cobra.Command{
|
|
Use: "serve <protocol> [opts] <remote>",
|
|
Short: `Serve a remote over a protocol.`,
|
|
Long: `Serve a remote over a given protocol. Requires the use of a
|
|
subcommand to specify the protocol, e.g.
|
|
|
|
rclone serve http remote:
|
|
|
|
Each subcommand has its own options which you can see in their help.
|
|
`,
|
|
Annotations: map[string]string{
|
|
"versionIntroduced": "v1.39",
|
|
},
|
|
RunE: func(command *cobra.Command, args []string) error {
|
|
if len(args) == 0 {
|
|
return errors.New("serve requires a protocol, e.g. 'rclone serve http remote:'")
|
|
}
|
|
return errors.New("unknown protocol")
|
|
},
|
|
}
|