2
0
mirror of https://github.com/linka-cloud/d2vm.git synced 2025-06-23 22:02:25 +00:00

run in docker if not root or sudo (fix #5 #9 #11)

set user permissions on image if run with sudo or in docker
run/vbox & run/hetzner: run qemu-img in docker if not available in path

Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
2022-09-13 15:02:38 +02:00
parent 43f2dd5452
commit d18e68b138
9 changed files with 129 additions and 21 deletions

View File

@ -26,8 +26,6 @@ import (
var (
Run = RunNoOut
CommandContext = exec.CommandContext
)
func SetDebug(debug bool) {
@ -39,6 +37,11 @@ func SetDebug(debug bool) {
}
}
func CommandContext(ctx context.Context, c string, args ...string) *exec.Cmd {
logrus.Debugf("$ %s %s", c, strings.Join(args, " "))
return exec.CommandContext(ctx, c, args...)
}
func RunDebug(ctx context.Context, c string, args ...string) error {
logrus.Debugf("$ %s %s", c, strings.Join(args, " "))
cmd := exec.CommandContext(ctx, c, args...)