2022-11-21 11:27:56 +08:00
|
|
|
package app
|
|
|
|
|
|
|
|
import (
|
2023-03-22 18:22:29 +08:00
|
|
|
"github.com/1Panel-dev/1Panel/backend/utils/docker"
|
2023-01-29 16:38:34 +08:00
|
|
|
"path"
|
|
|
|
|
2022-11-21 11:27:56 +08:00
|
|
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
2023-01-29 16:38:34 +08:00
|
|
|
"github.com/1Panel-dev/1Panel/backend/global"
|
2022-11-21 11:27:56 +08:00
|
|
|
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Init() {
|
2023-01-29 16:38:34 +08:00
|
|
|
constant.DataDir = global.CONF.System.DataDir
|
|
|
|
constant.ResourceDir = path.Join(constant.DataDir, "resource")
|
2022-11-21 11:27:56 +08:00
|
|
|
constant.AppResourceDir = path.Join(constant.ResourceDir, "apps")
|
2023-01-29 16:38:34 +08:00
|
|
|
constant.AppInstallDir = path.Join(constant.DataDir, "apps")
|
2023-03-30 16:47:47 +08:00
|
|
|
constant.RuntimeDir = path.Join(constant.DataDir, "runtime")
|
2022-11-21 11:27:56 +08:00
|
|
|
|
2023-05-16 17:31:47 +08:00
|
|
|
constant.LocalAppResourceDir = path.Join(constant.AppResourceDir, "local")
|
|
|
|
constant.LocalAppInstallDir = path.Join(constant.AppInstallDir, "local")
|
|
|
|
constant.RemoteAppResourceDir = path.Join(constant.AppResourceDir, "remote")
|
|
|
|
|
|
|
|
dirs := []string{constant.DataDir, constant.ResourceDir, constant.AppResourceDir, constant.AppInstallDir,
|
|
|
|
global.CONF.System.Backup, constant.RuntimeDir, constant.LocalAppResourceDir, constant.RemoteAppResourceDir}
|
2022-11-21 11:27:56 +08:00
|
|
|
|
|
|
|
fileOp := files.NewFileOp()
|
|
|
|
for _, dir := range dirs {
|
|
|
|
createDir(fileOp, dir)
|
|
|
|
}
|
|
|
|
|
2023-03-22 18:22:29 +08:00
|
|
|
_ = docker.CreateDefaultDockerNetwork()
|
2022-11-21 11:27:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func createDir(fileOp files.FileOp, dirPath string) {
|
|
|
|
if !fileOp.Stat(dirPath) {
|
|
|
|
_ = fileOp.CreateDir(dirPath, 0755)
|
|
|
|
}
|
|
|
|
}
|