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 Jan 10, 2024
1 parent b214c9a commit ee08ed0
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 @@ -254,6 +254,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 ee08ed0

Please sign in to comment.