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: If started as:
./AdGuardHome --auto-config ./AdGuardHome --import-openwrt-config
* Read `/etc/config/network`: * Read `/etc/config/network`:
@@ -1656,5 +1656,5 @@ If started as:
And service script starts AGH like this: And service script starts AGH like this:
.../AdGuardHome --auto-config .../AdGuardHome --import-openwrt-config
.../AdGuardHome .../AdGuardHome

View File

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

View File

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