let shell be passed in via cli
This commit is contained in:
parent
06ff140507
commit
6658d29123
@ -15,7 +15,7 @@
|
||||
in {
|
||||
tsvnstat = pkgs.buildGoModule {
|
||||
pname = "tsvnstat";
|
||||
version = "v0.0.4";
|
||||
version = "v0.0.5";
|
||||
src = ./.;
|
||||
|
||||
vendorSha256 = "sha256-RNhu1gQ62Hg8Fhiw9uIS+b4YaAHtZMaqbelMKv+oZjM=";
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -x
|
||||
|
||||
for i in $@; do
|
||||
vnstati --style 1 -L -s -o ${i}-s.png $i
|
||||
vnstati --style 1 -L --fivegraph 576 218 -o ${i}-5g.png $i
|
||||
|
8
main.go
8
main.go
@ -52,6 +52,7 @@ func main() {
|
||||
name := flag.String("name", "", "name of service")
|
||||
dir := flag.String("dir", tmpDir, "directory containing vnstat images")
|
||||
key := flag.String("key", "", "path to file containing the api key")
|
||||
shell := flag.String("sh", "/bin/sh", "path to interpreter")
|
||||
flag.Parse()
|
||||
|
||||
s := &tsnet.Server{
|
||||
@ -79,7 +80,6 @@ func main() {
|
||||
|
||||
go func() {
|
||||
for {
|
||||
time.Sleep(10 * time.Second)
|
||||
log.Printf("running %q in %q", tmpFile.Name(), tmpDir)
|
||||
|
||||
ifaces, err := net.Interfaces()
|
||||
@ -87,12 +87,12 @@ func main() {
|
||||
log.Fatal("can't get interfaces...", err)
|
||||
}
|
||||
|
||||
var ifNames []string
|
||||
cmd := []string{tmpFile.Name()}
|
||||
for _, intf := range ifaces {
|
||||
ifNames = append(ifNames, intf.Name)
|
||||
cmd = append(cmd, intf.Name)
|
||||
}
|
||||
|
||||
genCmd := exec.Command(tmpFile.Name(), ifNames...)
|
||||
genCmd := exec.Command(*shell, cmd...)
|
||||
genCmd.Dir = *dir
|
||||
out, err := genCmd.Output()
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user