Config file from URL?

While "doing stuff" I have found myself on new machines without my standard config. Luckily I put my (encrypted) config file on an easy to remember (to me) web server and I can make a local copy but that in turn means I leave my config file, possibly out of date, on random systems.

Would it be feasible to just pull the config from a remote web server when the --config option starts with a method instead of a file name?

I already use really primitive code in my own text processing scripts what just does this:

	var f io.ReadCloser
	if strings.HasPrefix(file, "http") {
		fmt.Printf("fetching file %q\n", file)
		res, err := http.Get(file)
		if err != nil {
			log.Fatal(err)
		}
		f = res.Body
		if contents.Source == "" {
			contents.Source = file
		}
	} else {
		var err error
		fmt.Printf("reading file %q\n", file)
		f, err = os.Open(file)
		if err != nil {
			log.Fatal(err)
		}
	}
	var content, _ = ioutil.ReadAll(f)
	f.Close()

Obviously in production/public code it would have to be a little more robust, but ...?

(The encryption password would still be applied using existing means)

Peter

Interesting idea!

What would you expect rclone to do when it needs to save the config file?

I note you can fetch the config file with rclone like this

rclone copyurl http://example.com/config .rclone.conf

I would think it would be "read only" - much like if the file system didn't allow writes.

I can always "wget URL" or curl too, but I was trying to avoid having any local copy to avoid littering and potential out-of-date-ness.

Peter

Your idea seems rather like setting environment variables in that respect.

Are you interested in implementing this feature?

I can certainly give it a go, but it will take somewhat longer than for those familiar with the project code!

1 Like

I think everything you can need can be done with just wget/curl + reading the file with bash to set environment variables.

Then instead you can just help ncw maybe implement logging the env variables to the debug output. MUch easier :stuck_out_tongue:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.