mirror of
https://github.com/anaganisk/digitalocean-dynamic-dns-ip.git
synced 2024-08-30 17:42:10 +00:00
change config file to be placed in home directory
This commit is contained in:
parent
05863d7a6d
commit
057713b443
@ -10,7 +10,7 @@ Requires that the record already exists in DigitalOcean's DNS.
|
||||
```bash
|
||||
git clone https://github.com/anaganisk/digitalocean-dynamic-dns-ip.git
|
||||
```
|
||||
create a file config.json and place it same directory as this script and add the following json
|
||||
create a file ".digitalocean-dynamic-ip.json"(dot prefix to hide the file) and place it user home directory and add the following json
|
||||
|
||||
```json
|
||||
{
|
||||
|
@ -6,8 +6,9 @@ import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
homedir "github.com/mitchellh/go-homedir"
|
||||
)
|
||||
|
||||
func checkError(err error) {
|
||||
@ -37,10 +38,9 @@ type DOResponse struct {
|
||||
}
|
||||
|
||||
func main() {
|
||||
// load config
|
||||
absPath, err := filepath.Abs("./config.json")
|
||||
homeDirectory, err := homedir.Dir()
|
||||
checkError(err)
|
||||
getfile, err := ioutil.ReadFile(absPath)
|
||||
getfile, err := ioutil.ReadFile(homeDirectory + "/.digitalocean-dynamic-ip.json")
|
||||
checkError(err)
|
||||
var config ClientConfig
|
||||
json.Unmarshal(getfile, &config)
|
||||
|
Loading…
Reference in New Issue
Block a user