Skip to content

Commit

Permalink
commands: Allow working directory to be set when not running in chroot
Browse files Browse the repository at this point in the history
Currently Command.Dir is unsed; hook it up such that when commands are
not running in a chroot, the working directory can be set.

Signed-off-by: Christopher Obbard <[email protected]>
  • Loading branch information
obbardc committed Aug 15, 2023
1 parent f334d32 commit a998e92
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ func (cmd Command) Run(label string, cmdline ...string) error {
exe.Env = append(os.Environ(), cmd.extraEnv...)
}

// Allow working directory to be set for commands not running in chroot
if len(cmd.Dir) > 0 && cmd.ChrootMethod == CHROOT_METHOD_NONE {
exe.Dir = cmd.Dir
}

// Disable services start/stop for commands running in chroot
if cmd.ChrootMethod != CHROOT_METHOD_NONE {
services := ServiceHelper{cmd.Chroot}
Expand Down

0 comments on commit a998e92

Please sign in to comment.