mirror of
https://github.com/gregtwallace/apc-p15-tool.git
synced 2025-07-25 16:12:56 +00:00
ssh: breakout ups ssh to its own package
This was done for clearer separation of function. A subsequent update will (hopefully) make the SSL command more robust so it works for both NMC2 and NMC3. The method for sending shell commands was also updated to use an interactive shell instead. This allows capturing responses of the commands which will be needed to deduce if devices are NMC2 or NMC3.
This commit is contained in:
parent
41efc56c62
commit
06c9263bc4
11 changed files with 444 additions and 284 deletions
pkg/apcssh
24
pkg/apcssh/cmd_restartwebui.go
Normal file
24
pkg/apcssh/cmd_restartwebui.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
package apcssh
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// RestartWebUI sends the APC command to restart the web ui
|
||||
// WARNING: Sending a command directly after this one will cause issues.
|
||||
// This command will cause SSH to also restart after a slight delay, therefore
|
||||
// any command right after this will start to run but then get stuck / fail
|
||||
// somewhere in the middle.
|
||||
func (cli *Client) RestartWebUI() error {
|
||||
result, err := cli.cmd("reboot -Y")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if strings.ToLower(result.code) != "e000" {
|
||||
return fmt.Errorf("apcssh: failed to restart web ui (%s: %s)", result.code, result.codeText)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue