mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-12-05 10:28:59 +08:00
34 lines
963 B
Go
34 lines
963 B
Go
package app
|
|
|
|
import (
|
|
"github.com/1Panel-dev/1Panel/backend/utils/docker"
|
|
"path"
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
"github.com/1Panel-dev/1Panel/backend/global"
|
|
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
|
)
|
|
|
|
func Init() {
|
|
constant.DataDir = global.CONF.System.DataDir
|
|
constant.ResourceDir = path.Join(constant.DataDir, "resource")
|
|
constant.AppResourceDir = path.Join(constant.ResourceDir, "apps")
|
|
constant.AppInstallDir = path.Join(constant.DataDir, "apps")
|
|
constant.RuntimeDir = path.Join(constant.DataDir, "runtime")
|
|
|
|
dirs := []string{constant.DataDir, constant.ResourceDir, constant.AppResourceDir, constant.AppInstallDir, global.CONF.System.Backup, constant.RuntimeDir}
|
|
|
|
fileOp := files.NewFileOp()
|
|
for _, dir := range dirs {
|
|
createDir(fileOp, dir)
|
|
}
|
|
|
|
_ = docker.CreateDefaultDockerNetwork()
|
|
}
|
|
|
|
func createDir(fileOp files.FileOp, dirPath string) {
|
|
if !fileOp.Stat(dirPath) {
|
|
_ = fileOp.CreateDir(dirPath, 0755)
|
|
}
|
|
}
|