summaryrefslogtreecommitdiffstats
path: root/src/go/plugin/go.d/modules/ap/init.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/go/plugin/go.d/modules/ap/init.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/go/plugin/go.d/modules/ap/init.go b/src/go/plugin/go.d/modules/ap/init.go
new file mode 100644
index 000000000..6031f6caa
--- /dev/null
+++ b/src/go/plugin/go.d/modules/ap/init.go
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package ap
+
+import (
+ "errors"
+ "os"
+ "os/exec"
+ "strings"
+)
+
+func (a *AP) validateConfig() error {
+ if a.BinaryPath == "" {
+ return errors.New("no iw binary path specified")
+ }
+ return nil
+}
+
+func (a *AP) initIwExec() (iwBinary, error) {
+ binPath := a.BinaryPath
+
+ if !strings.HasPrefix(binPath, "/") {
+ path, err := exec.LookPath(binPath)
+ if err != nil {
+ return nil, err
+ }
+ binPath = path
+ }
+
+ if _, err := os.Stat(binPath); err != nil {
+ return nil, err
+ }
+
+ iw := newIwExec(binPath, a.Timeout.Duration())
+
+ return iw, nil
+}