X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=cmd%2Fsafcm-remote%2Fmain.go;h=ab0bfae917286283e59bcb16af1c2ffabe15432a;hb=5d6cc7f14a4bacc36bf3a23cd735a75ad4a90f1d;hp=64889c5a16180a06387754f8e68071439d913eed;hpb=77197f737073b551e216e55e30c41ebac53a0219;p=safcm%2Fsafcm.git diff --git a/cmd/safcm-remote/main.go b/cmd/safcm-remote/main.go index 64889c5..ab0bfae 100644 --- a/cmd/safcm-remote/main.go +++ b/cmd/safcm-remote/main.go @@ -1,4 +1,4 @@ -// Helper copied to the remote hosts to run commands and deploy configuration +// Helper copied to the remote host to run commands and deploy configuration // Copyright (C) 2021 Simon Ruderich // @@ -22,6 +22,8 @@ import ( "log" "os" + "golang.org/x/term" + "ruderich.org/simon/safcm" "ruderich.org/simon/safcm/cmd/safcm-remote/ainsl" "ruderich.org/simon/safcm/cmd/safcm-remote/info" @@ -30,9 +32,9 @@ import ( ) func usage() { - log.Fatalf("usage: %[1]s sync\n"+ - "usage: %[1]s ainsl [options] ", - os.Args[0]) + log.Fatalf("usage: %[1]s sync\n"+ + "usage: %[1]s ainsl [options] ", + os.Args[0]) } func main() { @@ -62,6 +64,12 @@ func main() { } func mainLoop() error { + if term.IsTerminal(int(os.Stdin.Fd())) || + term.IsTerminal(int(os.Stdout.Fd())) { + return fmt.Errorf("sync should only be called from `safcm` " + + "(redirect stdin/stdout to circumvent this check)") + } + conn := safcm.NewGobConn(os.Stdin, os.Stdout) var logLevel safcm.LogLevel