mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-19 11:57:23 +08:00
fix: Support docker configuration modifications for snap installations (#9377)
This commit is contained in:
parent
afa643519f
commit
1f6ea9f494
6 changed files with 20 additions and 7 deletions
|
@ -396,7 +396,7 @@ func recoverBaseData(src string, itemHelper *snapRecoverHelper) error {
|
|||
itemHelper.Task.Log(i18n.GetMsgByKey("RecoverDaemonJsonEmpty"))
|
||||
return nil
|
||||
} else {
|
||||
err = itemHelper.FileOp.CopyFile(path.Join(src, "daemon.json"), "/etc/docker")
|
||||
err = itemHelper.FileOp.CopyFile(path.Join(src, "daemon.json"), path.Dir(constant.DaemonJsonPath))
|
||||
itemHelper.Task.Log(i18n.GetMsgByKey("RecoverDaemonJson"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("recover docker daemon.json failed, err: %v", err)
|
||||
|
|
|
@ -79,7 +79,7 @@ func (u *SnapshotService) SnapshotRollback(req dto.SnapshotRecover) error {
|
|||
i18n.GetWithName("SnapCopy", constant.DaemonJsonPath),
|
||||
func(t *task.Task) error {
|
||||
if FileOp.Stat(path.Join(baseDir, "daemon.json")) {
|
||||
return FileOp.CopyFile(path.Join(baseDir, "daemon.json"), "/etc/docker")
|
||||
return FileOp.CopyFile(path.Join(baseDir, "daemon.json"), path.Dir(constant.DaemonJsonPath))
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
|
|
@ -13,6 +13,6 @@ const (
|
|||
ComposeOpStop = "stop"
|
||||
ComposeOpRestart = "restart"
|
||||
ComposeOpRemove = "remove"
|
||||
|
||||
DaemonJsonPath = "/etc/docker/daemon.json"
|
||||
)
|
||||
|
||||
var DaemonJsonPath = "/etc/docker/daemon.json"
|
||||
|
|
|
@ -2,12 +2,14 @@ package hook
|
|||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/agent/app/model"
|
||||
"github.com/1Panel-dev/1Panel/agent/app/repo"
|
||||
"github.com/1Panel-dev/1Panel/agent/constant"
|
||||
"github.com/1Panel-dev/1Panel/agent/global"
|
||||
"github.com/1Panel-dev/1Panel/agent/utils/cmd"
|
||||
"github.com/1Panel-dev/1Panel/agent/utils/xpack"
|
||||
)
|
||||
|
||||
|
@ -18,6 +20,8 @@ func Init() {
|
|||
handleOllamaModelStatus()
|
||||
|
||||
loadLocalDir()
|
||||
|
||||
initDockerConf()
|
||||
}
|
||||
|
||||
func initGlobalData() {
|
||||
|
@ -109,3 +113,14 @@ func loadLocalDir() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func initDockerConf() {
|
||||
stdout, err := cmd.RunDefaultWithStdoutBashC("which docker")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
dockerPath := stdout
|
||||
if strings.Contains(dockerPath, "snap") {
|
||||
constant.DaemonJsonPath = "/var/snap/docker/current/config/daemon.json"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,8 +33,6 @@ const (
|
|||
|
||||
OneDriveRedirectURI = "http://localhost/login/authorized"
|
||||
GoogleRedirectURI = "https://localhost:8080"
|
||||
|
||||
DaemonJsonPath = "/etc/docker/daemon.json"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -167,7 +167,7 @@
|
|||
:minHeight="350"
|
||||
v-model="dockerConf"
|
||||
mode="json"
|
||||
placeholder="# The Docker configuration file does not exist or is empty (/etc/docker/daemon.json)"
|
||||
placeholder="# The Docker configuration file does not exist or is empty"
|
||||
></CodemirrorPro>
|
||||
<el-button :disabled="loading" type="primary" @click="onSaveFile" class="mt-2.5">
|
||||
{{ $t('commons.button.save') }}
|
||||
|
|
Loading…
Add table
Reference in a new issue