mirror of
https://github.com/kopia/kopia.git
synced 2026-03-12 19:26:25 -04:00
This will launch 'rclone webdav server' passing random TLS certificate and username/password and serve predefined rclone remote path. This is very experimental, use with caution. Fixes #313. Additional / required changes: * blob: (experimental) support for rclone provider * server: refactored TLS utilities to separate package * webdav: add support for specifying trusted TLS certificate fingerprint * kopia-ui: added rclone support
49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"io/ioutil"
|
|
|
|
"gopkg.in/alecthomas/kingpin.v2"
|
|
|
|
"github.com/kopia/kopia/repo/blob"
|
|
"github.com/kopia/kopia/repo/blob/rclone"
|
|
)
|
|
|
|
func init() {
|
|
var (
|
|
opt rclone.Options
|
|
connectFlat bool
|
|
embedRCloneConfigFile string
|
|
)
|
|
|
|
RegisterStorageConnectFlags(
|
|
"rclone",
|
|
"an rclone-based provided",
|
|
func(cmd *kingpin.CmdClause) {
|
|
cmd.Flag("remote-path", "Rclone remote:path").Required().StringVar(&opt.RemotePath)
|
|
cmd.Flag("flat", "Use flat directory structure").BoolVar(&connectFlat)
|
|
cmd.Flag("rclone-exe", "Path to rclone binary").StringVar(&opt.RCloneExe)
|
|
cmd.Flag("rclone-args", "Pass additional parameters to rclone").StringsVar(&opt.RCloneArgs)
|
|
cmd.Flag("rclone-env", "Pass additional environment (key=value) to rclone").StringsVar(&opt.RCloneEnv)
|
|
cmd.Flag("embed-rclone-config", "Embed the provider RClone config").ExistingFileVar(&embedRCloneConfigFile)
|
|
},
|
|
func(ctx context.Context, isNew bool) (blob.Storage, error) {
|
|
if connectFlat {
|
|
opt.DirectoryShards = []int{}
|
|
}
|
|
|
|
if embedRCloneConfigFile != "" {
|
|
cfg, err := ioutil.ReadFile(embedRCloneConfigFile) //nolint:gosec
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
opt.EmbeddedConfig = string(cfg)
|
|
}
|
|
|
|
return rclone.New(ctx, &opt)
|
|
},
|
|
)
|
|
}
|