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