diff options
| author | bndw <ben@bdw.to> | 2025-12-28 10:56:03 -0800 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2025-12-28 10:56:03 -0800 |
| commit | 7fcb9dfa87310e91b527829ece9989decb6fda64 (patch) | |
| tree | 9135e160ed99da556e7e04e1f6320c07746b27cb /internal/ssh/client.go | |
| parent | ae384f0860c7ef98cc3de1763886566dc6ca903c (diff) | |
fixed logs -f
Diffstat (limited to 'internal/ssh/client.go')
| -rw-r--r-- | internal/ssh/client.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/ssh/client.go b/internal/ssh/client.go index 1cd336c..b9c8d0f 100644 --- a/internal/ssh/client.go +++ b/internal/ssh/client.go | |||
| @@ -132,6 +132,42 @@ func (c *Client) RunSudo(cmd string) (string, error) { | |||
| 132 | return c.Run("sudo " + cmd) | 132 | return c.Run("sudo " + cmd) |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | // RunSudoStream executes a command with sudo and streams output to stdout/stderr | ||
| 136 | func (c *Client) RunSudoStream(cmd string) error { | ||
| 137 | session, err := c.client.NewSession() | ||
| 138 | if err != nil { | ||
| 139 | return err | ||
| 140 | } | ||
| 141 | defer session.Close() | ||
| 142 | |||
| 143 | session.Stdout = os.Stdout | ||
| 144 | session.Stderr = os.Stderr | ||
| 145 | |||
| 146 | if err := session.Run("sudo " + cmd); err != nil { | ||
| 147 | return fmt.Errorf("command failed: %w", err) | ||
| 148 | } | ||
| 149 | |||
| 150 | return nil | ||
| 151 | } | ||
| 152 | |||
| 153 | // RunStream executes a command and streams output to stdout/stderr | ||
| 154 | func (c *Client) RunStream(cmd string) error { | ||
| 155 | session, err := c.client.NewSession() | ||
| 156 | if err != nil { | ||
| 157 | return err | ||
| 158 | } | ||
| 159 | defer session.Close() | ||
| 160 | |||
| 161 | session.Stdout = os.Stdout | ||
| 162 | session.Stderr = os.Stderr | ||
| 163 | |||
| 164 | if err := session.Run(cmd); err != nil { | ||
| 165 | return fmt.Errorf("command failed: %w", err) | ||
| 166 | } | ||
| 167 | |||
| 168 | return nil | ||
| 169 | } | ||
| 170 | |||
| 135 | // Upload copies a local file to the remote host using scp | 171 | // Upload copies a local file to the remote host using scp |
| 136 | func (c *Client) Upload(localPath, remotePath string) error { | 172 | func (c *Client) Upload(localPath, remotePath string) error { |
| 137 | // Use external scp command for simplicity | 173 | // Use external scp command for simplicity |
