Files
耗子 e8f7811aba feat: 重构 CLI 命令并补全缺失功能
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>
2026-08-15 19:30:11 +08:00

85 lines
2.2 KiB
Go

package command
import (
"context"
"github.com/leonelquinteros/gotext"
"github.com/urfave/cli/v3"
"github.com/acepanel/panel/v3/internal/service"
)
// RestoreCommand 数据恢复命令组
func RestoreCommand(t *gotext.Locale, cliService *service.CliService) *cli.Command {
return &cli.Command{
Name: "restore",
Usage: t.Get("Data restore"),
Commands: []*cli.Command{
{
Name: "website",
Usage: t.Get("Restore website backup"),
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Aliases: []string{"n"},
Usage: t.Get("Website name"),
Required: true,
},
&cli.StringFlag{
Name: "file",
Aliases: []string{"f"},
Usage: t.Get("Backup file (absolute path or filename under default backup path)"),
Required: true,
},
},
Action: func(ctx context.Context, cmd *cli.Command) error {
return cliService.RestoreWebsite(ctx, cmd)
},
},
{
Name: "database",
Usage: t.Get("Restore database backup"),
Flags: []cli.Flag{
&cli.StringFlag{
Name: "type",
Aliases: []string{"t"},
Usage: t.Get("Database type (mysql, postgresql, clickhouse, redis, valkey)"),
Required: true,
},
&cli.StringFlag{
Name: "name",
Aliases: []string{"n"},
Usage: t.Get("Database name"),
Required: true,
},
&cli.StringFlag{
Name: "file",
Aliases: []string{"f"},
Usage: t.Get("Backup file (absolute path or filename under default backup path)"),
Required: true,
},
},
Action: func(ctx context.Context, cmd *cli.Command) error {
return cliService.RestoreDatabase(ctx, cmd)
},
},
{
Name: "panel",
Usage: t.Get("Restore panel backup (the panel restarts automatically after restoring)"),
Flags: []cli.Flag{
&cli.StringFlag{
Name: "file",
Aliases: []string{"f"},
Usage: t.Get("Backup file (absolute path or filename under default backup path)"),
Required: true,
},
},
Action: func(ctx context.Context, cmd *cli.Command) error {
return cliService.RestorePanel(ctx, cmd)
},
},
},
}
}