|
|
@ -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,19 +101,21 @@ 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 { |
|
|
|
phpPoolDir := path.Join(siteFolder, "php-pool") |
|
|
|
if runtime.Type == constant.RuntimePHP && runtime.Resource == constant.ResourceLocal { |
|
|
|
if err := fileOp.CreateDir(phpPoolDir, 0755); err != nil { |
|
|
|
phpPoolDir := path.Join(siteFolder, "php-pool") |
|
|
|
return err |
|
|
|
if err := fileOp.CreateDir(phpPoolDir, 0755); err != nil { |
|
|
|
} |
|
|
|
return err |
|
|
|
if err := fileOp.CreateFile(path.Join(phpPoolDir, "php-fpm.sock")); err != nil { |
|
|
|
} |
|
|
|
return err |
|
|
|
if err := fileOp.CreateFile(path.Join(phpPoolDir, "php-fpm.sock")); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if website.Type == constant.Static || website.Type == constant.Runtime { |
|
|
|
if website.Type == constant.Static || website.Type == constant.Runtime { |
|
|
@ -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 |
|
|
|
|
|
|
|
} |
|
|
|