|
|
@ -2,6 +2,7 @@ package service
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/utils/cmd"
|
|
|
|
"path"
|
|
|
|
"path"
|
|
|
|
"strconv"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
@ -58,8 +59,6 @@ func createIndexFile(website *model.Website, runtime *model.Runtime) error {
|
|
|
|
if runtime.Type == constant.RuntimePHP {
|
|
|
|
if runtime.Type == constant.RuntimePHP {
|
|
|
|
indexPath = path.Join(indexFolder, "index.php")
|
|
|
|
indexPath = path.Join(indexFolder, "index.php")
|
|
|
|
indexContent = string(nginx_conf.IndexPHP)
|
|
|
|
indexContent = string(nginx_conf.IndexPHP)
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -74,6 +73,11 @@ func createIndexFile(website *model.Website, runtime *model.Runtime) error {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if runtime.Resource == constant.ResourceAppstore {
|
|
|
|
|
|
|
|
if err := chownRootDir(indexFolder); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if err := fileOp.WriteFile(indexPath, strings.NewReader(indexContent), 0755); err != nil {
|
|
|
|
if err := fileOp.WriteFile(indexPath, strings.NewReader(indexContent), 0755); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -97,13 +101,14 @@ func createWebsiteFolder(nginxInstall model.AppInstall, website *model.Website,
|
|
|
|
if err := fileOp.CreateFile(path.Join(siteFolder, "log", "error.log")); err != nil {
|
|
|
|
if err := fileOp.CreateFile(path.Join(siteFolder, "log", "error.log")); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := fileOp.CreateDir(path.Join(siteFolder, "index"), 0755); err != nil {
|
|
|
|
if err := fileOp.CreateDir(path.Join(siteFolder, "index"), 0775); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := fileOp.CreateDir(path.Join(siteFolder, "ssl"), 0755); err != nil {
|
|
|
|
if err := fileOp.CreateDir(path.Join(siteFolder, "ssl"), 0755); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if website.Type == constant.Runtime && runtime.Type == constant.RuntimePHP && runtime.Resource == constant.ResourceLocal {
|
|
|
|
if website.Type == constant.Runtime {
|
|
|
|
|
|
|
|
if runtime.Type == constant.RuntimePHP && runtime.Resource == constant.ResourceLocal {
|
|
|
|
phpPoolDir := path.Join(siteFolder, "php-pool")
|
|
|
|
phpPoolDir := path.Join(siteFolder, "php-pool")
|
|
|
|
if err := fileOp.CreateDir(phpPoolDir, 0755); err != nil {
|
|
|
|
if err := fileOp.CreateDir(phpPoolDir, 0755); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
@ -112,6 +117,7 @@ func createWebsiteFolder(nginxInstall model.AppInstall, website *model.Website,
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if website.Type == constant.Static || website.Type == constant.Runtime {
|
|
|
|
if website.Type == constant.Static || website.Type == constant.Runtime {
|
|
|
|
if err := createIndexFile(website, runtime); err != nil {
|
|
|
|
if err := createIndexFile(website, runtime); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
@ -505,3 +511,11 @@ func checkIsLinkApp(website model.Website) bool {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func chownRootDir(path string) error {
|
|
|
|
|
|
|
|
_, err := cmd.ExecWithTimeOut(fmt.Sprintf("chown -R 1000:1000 %s", path), 1*time.Second)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|