mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-22 21:36:24 +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"))
|
itemHelper.Task.Log(i18n.GetMsgByKey("RecoverDaemonJsonEmpty"))
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} 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"))
|
itemHelper.Task.Log(i18n.GetMsgByKey("RecoverDaemonJson"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("recover docker daemon.json failed, err: %v", err)
|
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),
|
i18n.GetWithName("SnapCopy", constant.DaemonJsonPath),
|
||||||
func(t *task.Task) error {
|
func(t *task.Task) error {
|
||||||
if FileOp.Stat(path.Join(baseDir, "daemon.json")) {
|
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
|
return nil
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,6 +13,6 @@ const (
|
||||||
ComposeOpStop = "stop"
|
ComposeOpStop = "stop"
|
||||||
ComposeOpRestart = "restart"
|
ComposeOpRestart = "restart"
|
||||||
ComposeOpRemove = "remove"
|
ComposeOpRemove = "remove"
|
||||||
|
|
||||||
DaemonJsonPath = "/etc/docker/daemon.json"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var DaemonJsonPath = "/etc/docker/daemon.json"
|
||||||
|
|
|
@ -2,12 +2,14 @@ package hook
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
"github.com/1Panel-dev/1Panel/agent/app/dto"
|
||||||
"github.com/1Panel-dev/1Panel/agent/app/model"
|
"github.com/1Panel-dev/1Panel/agent/app/model"
|
||||||
"github.com/1Panel-dev/1Panel/agent/app/repo"
|
"github.com/1Panel-dev/1Panel/agent/app/repo"
|
||||||
"github.com/1Panel-dev/1Panel/agent/constant"
|
"github.com/1Panel-dev/1Panel/agent/constant"
|
||||||
"github.com/1Panel-dev/1Panel/agent/global"
|
"github.com/1Panel-dev/1Panel/agent/global"
|
||||||
|
"github.com/1Panel-dev/1Panel/agent/utils/cmd"
|
||||||
"github.com/1Panel-dev/1Panel/agent/utils/xpack"
|
"github.com/1Panel-dev/1Panel/agent/utils/xpack"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,6 +20,8 @@ func Init() {
|
||||||
handleOllamaModelStatus()
|
handleOllamaModelStatus()
|
||||||
|
|
||||||
loadLocalDir()
|
loadLocalDir()
|
||||||
|
|
||||||
|
initDockerConf()
|
||||||
}
|
}
|
||||||
|
|
||||||
func initGlobalData() {
|
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"
|
OneDriveRedirectURI = "http://localhost/login/authorized"
|
||||||
GoogleRedirectURI = "https://localhost:8080"
|
GoogleRedirectURI = "https://localhost:8080"
|
||||||
|
|
||||||
DaemonJsonPath = "/etc/docker/daemon.json"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -167,7 +167,7 @@
|
||||||
:minHeight="350"
|
:minHeight="350"
|
||||||
v-model="dockerConf"
|
v-model="dockerConf"
|
||||||
mode="json"
|
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>
|
></CodemirrorPro>
|
||||||
<el-button :disabled="loading" type="primary" @click="onSaveFile" class="mt-2.5">
|
<el-button :disabled="loading" type="primary" @click="onSaveFile" class="mt-2.5">
|
||||||
{{ $t('commons.button.save') }}
|
{{ $t('commons.button.save') }}
|
||||||
|
|
Loading…
Add table
Reference in a new issue