mirror of
https://github.com/tnb-labs/panel.git
synced 2026-08-29 02:10:58 +08:00
e8f7811aba
website create 未传网站类型导致必然失败,补全类型、代理地址、 数据库、备注等参数,并在进入 biz 层前统一走验证器校验。 新增命令: - firewall status/on/off/list/port - cert list/renew - restore panel - website cert/list,user create/delete - backup list,app list,cron list/run/status - database list-server 调整: - 密码取值改为参数 > ACEPANEL_PASSWORD > 交互输入(不回显) - 补 bind-domain/bind-ip/bind-ua 的 on 子命令 - 新增全局 --json,接入全部 list 命令 - port 支持 flag 写法,info 支持 -u 指定用户 - 位置参数命令补 ArgsUsage 修复: - cutoff clear 清理远程日志时目录与上传路径不一致,导致远程切割 日志从未被清理,ClearStorageExpired 改为接收目标目录 - restore 缺少 panel 分支,从 FixPanel 抽出 restorePanel 复用 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
192 lines
5.1 KiB
Go
192 lines
5.1 KiB
Go
package command
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/leonelquinteros/gotext"
|
|
"github.com/urfave/cli/v3"
|
|
|
|
"github.com/acepanel/panel/v3/internal/service"
|
|
)
|
|
|
|
// WebsiteCommand 网站管理命令组
|
|
func WebsiteCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command {
|
|
|
|
return &cli.Command{
|
|
Name: "website",
|
|
Usage: t.Get("Website management"),
|
|
Commands: []*cli.Command{
|
|
{
|
|
Name: "create",
|
|
Usage: t.Get("Create new website"),
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "type",
|
|
Usage: t.Get("Website type (proxy, static, php)"),
|
|
Aliases: []string{"t"},
|
|
Value: "static",
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "name",
|
|
Usage: t.Get("Website name"),
|
|
Aliases: []string{"n"},
|
|
Required: true,
|
|
},
|
|
&cli.StringSliceFlag{
|
|
Name: "domains",
|
|
Usage: t.Get("List of domains associated with the website"),
|
|
Aliases: []string{"d"},
|
|
Required: true,
|
|
},
|
|
&cli.StringSliceFlag{
|
|
Name: "listens",
|
|
Usage: t.Get("List of listening addresses associated with the website"),
|
|
Aliases: []string{"l"},
|
|
Value: []string{"80"},
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "path",
|
|
Usage: t.Get("Path where the website is hosted (default path if not filled)"),
|
|
Aliases: []string{"p"},
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "proxy",
|
|
Usage: t.Get("Address to proxy to (required for proxy type)"),
|
|
},
|
|
&cli.UintFlag{
|
|
Name: "php",
|
|
Usage: t.Get("PHP version used by the website (not used if not filled, php type only)"),
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "db",
|
|
Usage: t.Get("Create a database of the given type (mysql, postgresql), not created if not filled"),
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "db-name",
|
|
Usage: t.Get("Database name (website name if not filled)"),
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "db-user",
|
|
Usage: t.Get("Database username (website name if not filled)"),
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "db-password",
|
|
Usage: t.Get("Database password (randomly generated if not filled)"),
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "remark",
|
|
Usage: t.Get("Website remark"),
|
|
},
|
|
},
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.WebsiteCreate(ctx, cmd)
|
|
},
|
|
},
|
|
{
|
|
Name: "remove",
|
|
Usage: t.Get("Remove website (keep website directory and database)"),
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "name",
|
|
Usage: t.Get("Website name"),
|
|
Aliases: []string{"n"},
|
|
Required: true,
|
|
},
|
|
},
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.WebsiteRemove(ctx, cmd)
|
|
},
|
|
},
|
|
{
|
|
Name: "delete",
|
|
Usage: t.Get("Delete website (including website directory, database with the same name)"),
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "name",
|
|
Usage: t.Get("Website name"),
|
|
Aliases: []string{"n"},
|
|
Required: true,
|
|
},
|
|
},
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.WebsiteDelete(ctx, cmd)
|
|
},
|
|
},
|
|
{
|
|
Name: "list",
|
|
Usage: t.Get("List all websites"),
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.WebsiteList(ctx, cmd)
|
|
},
|
|
},
|
|
{
|
|
Name: "cert",
|
|
Usage: t.Get("Update website certificate from files"),
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "name",
|
|
Usage: t.Get("Website name"),
|
|
Aliases: []string{"n"},
|
|
Required: true,
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "cert",
|
|
Usage: t.Get("Certificate file path (fullchain)"),
|
|
Aliases: []string{"c"},
|
|
Required: true,
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "key",
|
|
Usage: t.Get("Private key file path"),
|
|
Aliases: []string{"k"},
|
|
Required: true,
|
|
},
|
|
},
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.WebsiteCert(ctx, cmd)
|
|
},
|
|
},
|
|
{
|
|
Name: "write",
|
|
Usage: t.Get("Write website data to the panel database only, without creating directories and config files (use only under guidance)"),
|
|
Hidden: true,
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "name",
|
|
Usage: t.Get("Website name"),
|
|
Aliases: []string{"n"},
|
|
Required: true,
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "type",
|
|
Usage: t.Get("Website type (proxy, static, php)"),
|
|
Aliases: []string{"t"},
|
|
Value: "static",
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "path",
|
|
Usage: t.Get("Path where the website is hosted (default path if not filled)"),
|
|
Aliases: []string{"p"},
|
|
},
|
|
&cli.BoolFlag{
|
|
Name: "status",
|
|
Usage: t.Get("Website status"),
|
|
Value: true,
|
|
},
|
|
&cli.BoolFlag{
|
|
Name: "ssl",
|
|
Usage: t.Get("Whether the website has SSL enabled"),
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "remark",
|
|
Usage: t.Get("Website remark"),
|
|
},
|
|
},
|
|
Action: func(ctx context.Context, cmd *cli.Command) error {
|
|
return cliService.WebsiteWrite(ctx, cmd)
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|