This commit is contained in:
Simon Zolin 2020-03-20 16:29:42 +03:00
parent 33a98aa937
commit dced8a5a83
3 changed files with 9 additions and 8 deletions

View file

@ -1604,7 +1604,7 @@ To replace dnsmasq we have to read system configuration files and update (create
If started as:
./AdGuardHome --auto-config
./AdGuardHome --import-openwrt-config
* Read `/etc/config/network`:
@ -1656,5 +1656,5 @@ If started as:
And service script starts AGH like this:
.../AdGuardHome --auto-config
.../AdGuardHome --import-openwrt-config
.../AdGuardHome

View file

@ -456,7 +456,8 @@ type options struct {
pidFile string // File name to save PID to
checkConfig bool // Check configuration and exit
disableUpdate bool // If set, don't check for updates
hasAutoConfig bool // 'auto-config' argument is specified
hasImportOpenwrtConfig bool // 'import-openwrt-config' argument is specified
// service control action (see service.ControlAction array + "status" command)
serviceControlAction string
@ -496,8 +497,8 @@ func loadOptions() options {
{"pidfile", "", "Path to a file where PID is stored", func(value string) { o.pidFile = value }, nil},
{"check-config", "", "Check configuration and exit", nil, func() { o.checkConfig = true }},
{"no-check-update", "", "Don't check for updates", nil, func() { o.disableUpdate = true }},
{"auto-config", "", "Create or update YAML configuration file from OpenWRT system configuration", nil, func() {
o.hasAutoConfig = true
{"import-openwrt-config", "", "Create or update YAML configuration file from OpenWRT system configuration", nil, func() {
o.hasImportOpenwrtConfig = true
}},
{"verbose", "v", "Enable verbose output", nil, func() { o.verbose = true }},
{"version", "", "Show the version and exit", nil, func() {
@ -555,8 +556,8 @@ func loadOptions() options {
log.SetLevel(log.DEBUG)
}
if o.hasAutoConfig {
err := autoConfig(o.configFilename)
if o.hasImportOpenwrtConfig {
err := importOpenwrtConfig(o.configFilename)
if err != nil {
log.Fatalf("%s", err)
}

View file

@ -284,7 +284,7 @@ func (oc *openwrtConfig) Process() error {
}
// Read system configuration files and write our configuration files
func autoConfig(configFn string) error {
func importOpenwrtConfig(configFn string) error {
oc := openwrtConfig{}
err := oc.Process()
if err != nil {