Skip to content

Commit

Permalink
Added conf.json example and removed from project
Browse files Browse the repository at this point in the history
  • Loading branch information
robsgh committed May 30, 2022
1 parent a40c4f7 commit 05f9c3e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
conf.json
/nsddns
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ Configuration is done through the `conf.json` file. As the name implies, it is a

The `conf.json` file must live in the same directory as the binary.

### Example `conf.json`

```json
{
"domain": "example.com",
"host": "test",
"apikey": "1234abcd"
}
```

## Usage

Running `./nsddns` will grab the user settings supplied in `conf.json` and start the automation. There are no flags currently; all user configuration
Expand Down
5 changes: 0 additions & 5 deletions conf.json

This file was deleted.

10 changes: 8 additions & 2 deletions nsddns.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"log"
"net/http"
"os"
"path/filepath"
)

/* GLOBAL VARS */
Expand Down Expand Up @@ -184,8 +185,13 @@ func getCurrentIP() (currentIP string) {

// Load a configuration file from conf.json in the same directory
func loadConfig() NSDDNSConfig {
// load the conf.json file
configFile, err := os.Open("conf.json")
// load the conf.json file that should be in the same dir as the executable
execPath, err := os.Executable()
if err != nil {
log.Fatalln("could not determine current working dir:", err.Error())
}
cwd := filepath.Dir(execPath)
configFile, err := os.Open(cwd + "/conf.json")
if err != nil {
log.Fatalln("could not open conf.json:", err.Error())
}
Expand Down

0 comments on commit 05f9c3e

Please sign in to comment.