Skip to content

CLI 命令参考 ​

SirrMesh 提供功能完整的命令行工具,用于管理和维护邮件服务器。

基本命令 ​

sirrmeshd ​

主程序命令。

bash
sirrmeshd [command] [flags]

全局选项 ​

bash
--config string      配置文件路径 (默认 "~/.sirrmeshd/config.toml")
--debug              启用调试模式
--help, -h           显示帮助信息
--version, -v        显示版本信息

服务管理 ​

run ​

启动邮件服务器。

bash
sirrmeshd run [flags]

选项:

bash
--daemon             后台运行
--pid-file string    PID 文件路径

示例:

bash
sirrmeshd run --config /etc/sirrmeshd/config.toml

stop ​

停止运行的服务器。

bash
sirrmeshd stop

restart ​

重启服务器。

bash
sirrmeshd restart

status ​

查看服务器状态。

bash
sirrmeshd status

输出:

Status: Running
PID: 12345
Uptime: 2d 5h 32m
Connections: 42
Messages Processed: 15,234

用户管理 ​

user create ​

创建新用户。

bash
sirrmeshd user create [flags]

选项:

bash
--username string    用户名(邮箱地址)
--password string    密码
--quota string       存储配额 (如 "5GB")
--blockchain string  区块链钱包地址

示例:

bash
sirrmeshd user create \
  --username [email protected] \
  --password secretpass \
  --quota 5GB

user delete ​

删除用户。

bash
sirrmeshd user delete --username [email protected]

user list ​

列出所有用户。

bash
sirrmeshd user list [flags]

选项:

bash
--domain string      按域名过滤
--format string      输出格式 (table|json|csv)

user modify ​

修改用户信息。

bash
sirrmeshd user modify \
  --username [email protected] \
  --quota 10GB

user password ​

更改用户密码。

bash
sirrmeshd user password \
  --username [email protected] \
  --new-password newpass

域名管理 ​

domain add ​

添加新域名。

bash
sirrmeshd domain add --name example.com

domain delete ​

删除域名。

bash
sirrmeshd domain delete --name example.com

domain list ​

列出所有域名。

bash
sirrmeshd domain list

配置管理 ​

config init ​

生成默认配置文件。

bash
sirrmeshd config init > config.toml

config verify ​

验证配置文件。

bash
sirrmeshd config verify

config get ​

获取配置项。

bash
sirrmeshd config get server.hostname

config set ​

设置配置项。

bash
sirrmeshd config set server.hostname mail.example.com

DKIM 管理 ​

dkim generate ​

生成 DKIM 密钥对。

bash
sirrmeshd dkim generate \
  --domain example.com \
  --selector default \
  --bits 2048

dkim show ​

显示 DKIM 公钥记录。

bash
sirrmeshd dkim show --domain example.com

输出:

Add this TXT record to your DNS:

default._domainkey.example.com. IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBg..."

配额管理 ​

quota get ​

查看用户配额。

bash
sirrmeshd quota get --user [email protected]

输出:

User: [email protected]
Quota: 5 GB
Used: 1.23 GB (24.6%)
Available: 3.77 GB

quota set ​

设置用户配额。

bash
sirrmeshd quota set \
  --user [email protected] \
  --quota 10GB

quota list ​

列出所有用户配额使用情况。

bash
sirrmeshd quota list --sort-by used

备份和恢复 ​

backup create ​

创建备份。

bash
sirrmeshd backup create \
  --output /backups/sirrchat-$(date +%Y%m%d).tar.gz \
  --compress

选项:

bash
--user string        仅备份指定用户
--domain string      仅备份指定域名
--exclude-attachments  排除附件

backup restore ​

恢复备份。

bash
sirrmeshd backup restore \
  --input /backups/sirrchat-20250115.tar.gz

backup list ​

列出可用备份。

bash
sirrmeshd backup list --path /backups

数据库管理 ​

db migrate ​

运行数据库迁移。

bash
sirrmeshd db migrate

db ping ​

测试数据库连接。

bash
sirrmeshd db ping

db vacuum ​

优化数据库。

bash
sirrmeshd db vacuum

存储管理 ​

storage stats ​

查看存储统计。

bash
sirrmeshd storage stats

storage test ​

测试存储连接。

bash
sirrmeshd storage test --type s3

storage migrate ​

迁移存储后端。

bash
sirrmeshd storage migrate \
  --from local \
  --to s3

storage cleanup ​

清理过期数据。

bash
sirrmeshd storage cleanup \
  --older-than 2y \
  --dry-run

模块管理 ​

module list ​

列出所有模块。

bash
sirrmeshd module list

module enable ​

启用模块。

bash
sirrmeshd module enable spam-filter

module disable ​

禁用模块。

bash
sirrmeshd module disable spam-filter

module reload ​

重载模块。

bash
sirrmeshd module reload --name spam-filter

日志管理 ​

logs view ​

查看日志。

bash
sirrmeshd logs view [flags]

选项:

bash
--lines int          显示行数 (默认 100)
--follow, -f         实时跟踪
--level string       日志级别过滤
--grep string        关键词过滤

示例:

bash
sirrmeshd logs view --lines 50 --level error
sirrmeshd logs view --follow --grep "[email protected]"

监控命令 ​

stats ​

显示服务器统计。

bash
sirrmeshd stats

输出:

Server Statistics
-----------------
Uptime: 2d 5h 32m
Total Users: 1,234
Active Sessions: 42
Messages Today: 5,678
Storage Used: 125.5 GB

SMTP Statistics
---------------
Sent: 2,345
Received: 3,333
Rejected: 12

IMAP Statistics
---------------
Active Connections: 42
Commands: 12,345

health ​

健康检查。

bash
sirrmeshd health

输出:

✓ Database: OK
✓ SMTP: OK
✓ IMAP: OK
✓ Storage: OK
✓ Memory: OK (45% used)
✓ Disk: OK (32% used)

诊断工具 ​

diagnose ​

运行诊断检查。

bash
sirrmeshd diagnose

test-smtp ​

测试 SMTP 功能。

bash
sirrmeshd test-smtp \
  --from [email protected] \
  --to [email protected] \
  --subject "Test Email"

test-imap ​

测试 IMAP 功能。

bash
sirrmeshd test-imap \
  --user [email protected] \
  --password pass

Shell 补全 ​

生成 shell 补全脚本。

Bash ​

bash
sirrmeshd completion bash > /etc/bash_completion.d/sirrmeshd

Zsh ​

bash
sirrmeshd completion zsh > "${fpath[1]}/_sirrmeshd"

Fish ​

bash
sirrmeshd completion fish > ~/.config/fish/completions/sirrmeshd.fish

环境变量 ​

bash
SIRRCHAT_CONFIG      配置文件路径
SIRRCHAT_DEBUG       启用调试模式
SIRRCHAT_LOG_LEVEL   日志级别
SIRRCHAT_DATA_DIR    数据目录

更多信息:

Released under the GPL 3.0 License.