mirror of
https://github.com/joohoi/acme-dns.git
synced 2025-07-16 18:58:14 +07:00
Cmd line flag -c
for config location (#108)
Add command line parsing and a flag `-c` to specify where the config file should be loaded from.
This commit is contained in:

committed by
Joona Hoikkala

parent
d66ccffaf6
commit
db2a6bc288
@ -115,7 +115,7 @@ See the INSTALL section for information on how to do this.
|
|||||||
|
|
||||||
2) Install acme-dns: `go get github.com/joohoi/acme-dns/...`. This will install acme-dns to `~/go/bin/acme-dns`.
|
2) Install acme-dns: `go get github.com/joohoi/acme-dns/...`. This will install acme-dns to `~/go/bin/acme-dns`.
|
||||||
|
|
||||||
3) Edit config.cfg to suit your needs (see [configuration](#configuration)). `acme-dns` will read the configuration file from `/etc/acme-dns/config.cfg` or `./config.cfg`.
|
3) Edit config.cfg to suit your needs (see [configuration](#configuration)). `acme-dns` will read the configuration file from `/etc/acme-dns/config.cfg` or `./config.cfg`, or a location specified with the `-c` flag.
|
||||||
|
|
||||||
4) If your system has systemd, you can optionally install acme-dns as a service so that it will start on boot and be tracked by systemd. This also allows us to add the `CAP_NET_BIND_SERVICE` capability so that acme-dns can be run by a user other than root.
|
4) If your system has systemd, you can optionally install acme-dns as a service so that it will start on boot and be tracked by systemd. This also allows us to add the `CAP_NET_BIND_SERVICE` capability so that acme-dns can be run by a user other than root.
|
||||||
|
|
||||||
@ -300,6 +300,9 @@ header_name = "X-Forwarded-For"
|
|||||||
|
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
- unreleased
|
||||||
|
- New
|
||||||
|
- Command line flag `-c` to specify location of config file.
|
||||||
- v0.5
|
- v0.5
|
||||||
- New
|
- New
|
||||||
- Configurable certificate cache directory
|
- Configurable certificate cache directory
|
||||||
|
9
main.go
9
main.go
@ -4,6 +4,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"flag"
|
||||||
stdlog "log"
|
stdlog "log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@ -18,11 +19,13 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
// Created files are not world writable
|
// Created files are not world writable
|
||||||
syscall.Umask(0077)
|
syscall.Umask(0077)
|
||||||
|
configPtr := flag.String("c", "/etc/acme-dns/config.cfg", "config file location")
|
||||||
|
flag.Parse()
|
||||||
// Read global config
|
// Read global config
|
||||||
var err error
|
var err error
|
||||||
if fileIsAccessible("/etc/acme-dns/config.cfg") {
|
if fileIsAccessible(*configPtr) {
|
||||||
log.WithFields(log.Fields{"file": "/etc/acme-dns/config.cfg"}).Info("Using config file")
|
log.WithFields(log.Fields{"file": *configPtr}).Info("Using config file")
|
||||||
Config, err = readConfig("/etc/acme-dns/config.cfg")
|
Config, err = readConfig(*configPtr)
|
||||||
} else if fileIsAccessible("./config.cfg") {
|
} else if fileIsAccessible("./config.cfg") {
|
||||||
log.WithFields(log.Fields{"file": "./config.cfg"}).Info("Using config file")
|
log.WithFields(log.Fields{"file": "./config.cfg"}).Info("Using config file")
|
||||||
Config, err = readConfig("./config.cfg")
|
Config, err = readConfig("./config.cfg")
|
||||||
|
Reference in New Issue
Block a user