mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 16:34:30 +01:00
0bfa9811f7
If a GET or HEAD request is receivied with a URL parameter of fs then it will be served from that remote.
43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
package rcd
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/ncw/rclone/cmd"
|
|
"github.com/ncw/rclone/fs/rc/rcflags"
|
|
"github.com/ncw/rclone/fs/rc/rcserver"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func init() {
|
|
cmd.Root.AddCommand(commandDefintion)
|
|
}
|
|
|
|
var commandDefintion = &cobra.Command{
|
|
Use: "rcd <path to files to serve>*",
|
|
Short: `Run rclone listening to remote control commands only.`,
|
|
Long: `
|
|
This runs rclone so that it only listents to remote control commands.
|
|
|
|
This is useful if you are controlling rclone via the rc API.
|
|
|
|
If you pass in a path to a directory, rclone will serve that directory
|
|
for GET requests on the URL passed in. It will also open the URL in
|
|
the browser when rclone is run.
|
|
`,
|
|
Run: func(command *cobra.Command, args []string) {
|
|
cmd.CheckArgs(0, 1, command, args)
|
|
if rcflags.Opt.Enabled {
|
|
log.Fatalf("Don't supply --rc flag when using rcd")
|
|
}
|
|
// Start the rc
|
|
rcflags.Opt.Enabled = true
|
|
if len(args) > 0 {
|
|
rcflags.Opt.Files = args[0]
|
|
}
|
|
rcserver.Start(&rcflags.Opt)
|
|
// Run the rc forever
|
|
select {}
|
|
},
|
|
}
|