mirror of
https://github.com/wweir/sower.git
synced 2024-04-21 12:42:15 +00:00
26 lines
507 B
Go
26 lines
507 B
Go
// +build linux
|
|
|
|
package conf
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os/exec"
|
|
"time"
|
|
)
|
|
|
|
func Init() {
|
|
flag.StringVar(&Conf.Router.FlushDNSCmd, "flush_dns", "", "flush dns command")
|
|
}
|
|
|
|
func execute(cmd string) error {
|
|
ctx, cancel := context.WithTimeout(context.TODO(), 5*time.Second)
|
|
defer cancel()
|
|
|
|
out, err := exec.CommandContext(ctx, "sh", "-c", Conf.Router.FlushDNSCmd).CombinedOutput()
|
|
if err != nil {
|
|
return fmt.Errorf("cmd: %s, err: %s, output: %s", Conf.Router.FlushDNSCmd, err, out)
|
|
}
|
|
return nil
|
|
}
|