add env to scripts
This commit is contained in:
parent
9565fea27c
commit
6ac14b6d64
6 changed files with 17 additions and 9 deletions
|
|
@ -82,7 +82,7 @@ func NewAgentConfig() *rmm.AgentConfig {
|
|||
}
|
||||
}
|
||||
|
||||
func (a *Agent) RunScript(code string, shell string, args []string, timeout int, runasuser bool) (stdout, stderr string, exitcode int, e error) {
|
||||
func (a *Agent) RunScript(code string, shell string, args []string, timeout int, runasuser bool, envs []string) (stdout, stderr string, exitcode int, e error) {
|
||||
|
||||
content := []byte(code)
|
||||
|
||||
|
|
@ -158,6 +158,11 @@ func (a *Agent) RunScript(code string, shell string, args []string, timeout int,
|
|||
cmd.Stdout = &outb
|
||||
cmd.Stderr = &errb
|
||||
|
||||
if len(envs) > 0 {
|
||||
cmd.Env = os.Environ()
|
||||
cmd.Env = append(cmd.Env, envs...)
|
||||
}
|
||||
|
||||
if cmdErr := cmd.Start(); cmdErr != nil {
|
||||
a.Logger.Debugln(cmdErr)
|
||||
return "", cmdErr.Error(), 65, cmdErr
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue