From d7df881da9d0ace9fa8f8ff56f8eb798a7e4124c Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Wed, 8 May 2024 17:36:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E7=BC=96=E6=8E=92?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E8=B7=B3=E8=BD=AC=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#4921)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #4895 --- backend/init/hook/hook.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/init/hook/hook.go b/backend/init/hook/hook.go index 9c58644b8..407de681e 100644 --- a/backend/init/hook/hook.go +++ b/backend/init/hook/hook.go @@ -4,6 +4,7 @@ import ( "encoding/base64" "encoding/json" "os" + "path" "strings" "github.com/1Panel-dev/1Panel/backend/app/model" @@ -63,6 +64,7 @@ func Init() { handleCronjobStatus() handleSnapStatus() loadLocalDir() + initDir() } func handleSnapStatus() { @@ -198,3 +200,13 @@ func handleUserInfo(tags string, settingRepo repo.ISettingRepo) { sudo := cmd.SudoHandleCmd() _, _ = cmd.Execf("%s sed -i '/CHANGE_USER_INFO=%v/d' /usr/local/bin/1pctl", sudo, global.CONF.System.ChangeUserInfo) } + +func initDir() { + composePath := path.Join(global.CONF.System.BaseDir, "1panel/docker/compose/") + if _, err := os.Stat(composePath); err != nil && os.IsNotExist(err) { + if err = os.MkdirAll(composePath, os.ModePerm); err != nil { + global.LOG.Errorf("mkdir %s failed, err: %v", composePath, err) + return + } + } +}