let shell be passed in via cli

This commit is contained in:
Aaron Bieber 2022-11-17 13:23:39 -07:00
parent 06ff140507
commit 6658d29123
No known key found for this signature in database
3 changed files with 7 additions and 5 deletions

View File

@ -15,7 +15,7 @@
in {
tsvnstat = pkgs.buildGoModule {
pname = "tsvnstat";
version = "v0.0.4";
version = "v0.0.5";
src = ./.;
vendorSha256 = "sha256-RNhu1gQ62Hg8Fhiw9uIS+b4YaAHtZMaqbelMKv+oZjM=";

View File

@ -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

View File

@ -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 {