mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-04 01:07:49 +02:00
all: implement router setup for ddwrt
This commit is contained in:
committed by
Cuong Manh Le
parent
c94be0df35
commit
8a2cdbfaa3
@@ -12,9 +12,6 @@ import (
|
||||
var errUCIEntryNotFound = errors.New("uci: Entry not found")
|
||||
|
||||
const openwrtDNSMasqConfigPath = "/tmp/dnsmasq.d/ctrld.conf"
|
||||
const openwrtDNSMasqConfigContent = `# GENERATED BY ctrld - DO NOT MODIFY
|
||||
port=0
|
||||
`
|
||||
|
||||
func setupOpenWrt() error {
|
||||
// Delete dnsmasq port if set.
|
||||
@@ -22,7 +19,7 @@ func setupOpenWrt() error {
|
||||
return err
|
||||
}
|
||||
// Disable dnsmasq as DNS server.
|
||||
if err := os.WriteFile(openwrtDNSMasqConfigPath, []byte(openwrtDNSMasqConfigContent), 0600); err != nil {
|
||||
if err := os.WriteFile(openwrtDNSMasqConfigPath, []byte(dnsMasqConfigContent), 0600); err != nil {
|
||||
return err
|
||||
}
|
||||
// Commit.
|
||||
@@ -30,7 +27,7 @@ func setupOpenWrt() error {
|
||||
return err
|
||||
}
|
||||
// Restart dnsmasq service.
|
||||
if err := restartDNSMasq(); err != nil {
|
||||
if err := openwrtRestartDNSMasq(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -42,7 +39,7 @@ func cleanupOpenWrt() error {
|
||||
return err
|
||||
}
|
||||
// Restart dnsmasq service.
|
||||
if err := restartDNSMasq(); err != nil {
|
||||
if err := openwrtRestartDNSMasq(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -66,7 +63,7 @@ func uci(args ...string) (string, error) {
|
||||
return strings.TrimSpace(stdout.String()), nil
|
||||
}
|
||||
|
||||
func restartDNSMasq() error {
|
||||
func openwrtRestartDNSMasq() error {
|
||||
if out, err := exec.Command("/etc/init.d/dnsmasq", "restart").CombinedOutput(); err != nil {
|
||||
return fmt.Errorf("%s: %w", string(out), err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user