From 6658d291232dbb6d8e38cae367ef56b4f518a340 Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Thu, 17 Nov 2022 13:23:39 -0700 Subject: [PATCH] let shell be passed in via cli --- flake.nix | 2 +- generate_images.sh | 2 ++ main.go | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index 01542a2..5ef6ea1 100644 --- a/flake.nix +++ b/flake.nix @@ -15,7 +15,7 @@ in { tsvnstat = pkgs.buildGoModule { pname = "tsvnstat"; - version = "v0.0.4"; + version = "v0.0.5"; src = ./.; vendorSha256 = "sha256-RNhu1gQ62Hg8Fhiw9uIS+b4YaAHtZMaqbelMKv+oZjM="; diff --git a/generate_images.sh b/generate_images.sh index cbd550b..fb67042 100755 --- a/generate_images.sh +++ b/generate_images.sh @@ -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 diff --git a/main.go b/main.go index 1b09f11..7e8b4c7 100644 --- a/main.go +++ b/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 {