]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm-remote/info/info.go
Move implementation of cmd/safcm-remote/ to remote/
[safcm/safcm.git] / cmd / safcm-remote / info / info.go
diff --git a/cmd/safcm-remote/info/info.go b/cmd/safcm-remote/info/info.go
deleted file mode 100644 (file)
index 15bf048..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-// MsgInfoReq: collect information about the remote host
-
-// Copyright (C) 2021  Simon Ruderich
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-package info
-
-import (
-       "fmt"
-       "runtime"
-
-       "ruderich.org/simon/safcm"
-       "ruderich.org/simon/safcm/cmd/safcm-remote/log"
-       "ruderich.org/simon/safcm/cmd/safcm-remote/run"
-)
-
-type Info struct {
-       req  safcm.MsgInfoReq
-       resp safcm.MsgInfoResp
-
-       cmd    *run.Cmd
-       logger *log.Logger
-}
-
-func Handle(req safcm.MsgInfoReq,
-       runner run.Runner, fun log.LogFunc) safcm.MsgInfoResp {
-
-       i := Info{
-               req:    req,
-               logger: log.NewLogger(fun),
-       }
-       i.cmd = run.NewCmd(runner, i.logger)
-
-       err := i.handle()
-       if err != nil {
-               i.resp.Error = fmt.Sprintf("%v", err)
-       }
-       return i.resp
-}
-
-func (i *Info) handle() error {
-       i.resp.Goos = runtime.GOOS
-       i.resp.Goarch = runtime.GOARCH
-
-       for _, x := range i.req.DetectGroups {
-               stdout, _, err := i.cmd.Run("detect group",
-                       "/bin/sh", "-c", x)
-               if err != nil {
-                       return err
-               }
-               i.resp.Output = append(i.resp.Output, string(stdout))
-       }
-
-       return nil
-}