2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 14:57:16 +08:00

feat: update

1. panel entrance
2. optimize cli
3. website service init
This commit is contained in:
耗子
2023-07-08 02:26:42 +08:00
parent 9034c76096
commit c4199dad4e
8 changed files with 63 additions and 18 deletions

View File

@@ -51,7 +51,7 @@ func (receiver *Panel) Handle(ctx console.Context) error {
return nil
}
settings := []models.Setting{{Key: "name", Value: "耗子Linux面板"}, {Key: "monitor", Value: "1"}, {Key: "monitor_days", Value: "30"}, {Key: "mysql_root_password", Value: ""}, {Key: "postgresql_root_password", Value: ""}}
settings := []models.Setting{{Key: "name", Value: "耗子Linux面板"}, {Key: "monitor", Value: "1"}, {Key: "monitor_days", Value: "30"}, {Key: "backup_path", Value: "/www/backup"}, {Key: "website_path", Value: "/www/wwwroot"}, {Key: "panel_entrance", Value: "/"}}
err = facades.Orm().Query().Create(&settings)
if err != nil {
color.Redln("初始化失败")
@@ -108,20 +108,8 @@ func (receiver *Panel) Handle(ctx console.Context) error {
color.Greenln("用户名: " + user.Username)
color.Greenln("密码: " + password)
nginxConf, err := os.ReadFile("/www/server/nginx/conf/nginx.conf")
if err != nil {
color.Redln("获取面板端口失败请检查Nginx主配置文件")
return nil
}
match := regexp.MustCompile(`listen\s+(\d+)`).FindStringSubmatch(string(nginxConf))
if len(match) < 2 {
color.Redln("获取面板端口失败请检查Nginx主配置文件")
return nil
}
port := match[1]
color.Greenln("面板端口: " + port)
// color.Greenln("面板端口: " + port)
color.Greenln("面板入口: " + services.NewSettingImpl().Get("panel_entrance", "/"))
case "getPort":
nginxConf, err := os.ReadFile("/www/server/nginx/conf/nginx.conf")
@@ -139,6 +127,9 @@ func (receiver *Panel) Handle(ctx console.Context) error {
port := match[1]
color.Greenln("面板端口: " + port)
case "getEntrance":
color.Greenln("面板入口: " + services.NewSettingImpl().Get("panel_entrance", "/"))
case "writePlugin":
slug := arg1
version := arg2
@@ -297,11 +288,12 @@ func (receiver *Panel) Handle(ctx console.Context) error {
color.Greenln("删除设置成功")
default:
color.Yellowln("耗子Linux面板命令行工具")
color.Yellowln(facades.Config().GetString("panel.name") + "命令行工具 - " + facades.Config().GetString("panel.version"))
color.Greenln("请使用以下命令:")
color.Greenln("panel update 更新/修复面板到最新版本")
color.Greenln("panel getInfo 重新初始化面板账号信息")
color.Greenln("panel getPort 获取面板访问端口")
color.Greenln("panel getEntrance 获取面板访问入口")
color.Greenln("panel cleanRunningTask 强制清理面板正在运行的任务")
color.Greenln("panel backup {website/mysql/postgresql} {name} {path} 备份网站/MySQL数据库/PostgreSQL数据库到指定目录")
color.Redln("以下命令请在开发者指导下使用:")

View File

@@ -5,11 +5,13 @@ import (
contractshttp "github.com/goravel/framework/contracts/http"
frameworkhttp "github.com/goravel/framework/http"
"panel/app/services"
)
func Static() contractshttp.Middleware {
return func(ctx contractshttp.Context) {
static.Serve("/", static.LocalFile("./public", false))(ctx.(*frameworkhttp.GinContext).Instance())
static.Serve(services.NewSettingImpl().Get("panel_entrance", "/"), static.LocalFile("./public", false))(ctx.(*frameworkhttp.GinContext).Instance())
ctx.Request().Next()
}

View File

@@ -1,2 +1,7 @@
// Package services 备份服务
package services
type Backup interface {
BackupWebSite(string) error
BackupDatabase(string, string) error
}

View File

@@ -1,3 +1,4 @@
// Package services 插件服务
package services
import (

View File

@@ -1,3 +1,4 @@
// Package services 设置服务
package services
import (

View File

@@ -1,3 +1,4 @@
// Package services 用户服务
package services
import (

View File

@@ -1,2 +1,45 @@
// Package services 网站服务
package services
import "panel/app/models"
type Website interface {
List() ([]models.Website, error)
}
type PanelWebsite struct {
Name string `json:"name"`
Domain string `json:"domain"`
Path string `json:"path"`
Php string `json:"php"`
Ssl string `json:"ssl"`
Remark string `json:"remark"`
Db bool `json:"db"`
DbType string `json:"db_type"`
DbName string `json:"db_name"`
DbUser string `json:"db_user"`
DbPassword string `json:"db_password"`
}
// WebsiteSetting 网站设置
type WebsiteSetting struct {
Name string `json:"name"`
Ports []string `json:"ports"`
Domains []string `json:"domains"`
Root string `json:"root"`
Path string `json:"path"`
Index string `json:"index"`
OpenBasedir bool `json:"open_basedir"`
Ssl bool `json:"ssl"`
SslCertificate string `json:"ssl_certificate"`
SslCertificateKey string `json:"ssl_certificate_key"`
HttpRedirect bool `json:"http_redirect"`
Hsts bool `json:"hsts"`
Waf bool `json:"waf"`
WafMode string `json:"waf_mode"`
WafCcDeny string `json:"waf_cc_deny"`
WafCache string `json:"waf_cache"`
Rewrite string `json:"rewrite"`
Raw string `json:"raw"`
Log string `json:"log"`
}

View File

@@ -7,7 +7,7 @@ import (
func init() {
config := facades.Config()
config.Add("panel", map[string]any{
"name": "耗子Linux面板",
"name": "耗子面板",
"version": "2.0.0",
})
}