mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 18:35:51 +02:00
feat(wip): docker ui only
This commit is contained in:
parent
c62fd25b2e
commit
d4a4ed1e1c
43 changed files with 1269 additions and 372 deletions
28
internal/nginx/exec.go
Normal file
28
internal/nginx/exec.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package nginx
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os/exec"
|
||||
|
||||
"github.com/0xJacky/Nginx-UI/internal/docker"
|
||||
"github.com/0xJacky/Nginx-UI/settings"
|
||||
)
|
||||
|
||||
func execShell(cmd string) (stdOut string, stdErr error) {
|
||||
return execCommand("/bin/sh", "-c", cmd)
|
||||
}
|
||||
|
||||
func execCommand(name string, cmd ...string) (stdOut string, stdErr error) {
|
||||
switch settings.NginxSettings.RunningInAnotherContainer() {
|
||||
case true:
|
||||
cmd = append([]string{name}, cmd...)
|
||||
stdOut, stdErr = docker.Exec(context.Background(), cmd)
|
||||
case false:
|
||||
bytes, err := exec.Command(name, cmd...).CombinedOutput()
|
||||
stdOut = string(bytes)
|
||||
if err != nil {
|
||||
stdErr = err
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue