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.tomlstop
停止运行的服务器。
bash
sirrmeshd stoprestart
重启服务器。
bash
sirrmeshd restartstatus
查看服务器状态。
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 5GBuser 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 10GBuser password
更改用户密码。
bash
sirrmeshd user password \
--username [email protected] \
--new-password newpass域名管理
domain add
添加新域名。
bash
sirrmeshd domain add --name example.comdomain delete
删除域名。
bash
sirrmeshd domain delete --name example.comdomain list
列出所有域名。
bash
sirrmeshd domain list配置管理
config init
生成默认配置文件。
bash
sirrmeshd config init > config.tomlconfig verify
验证配置文件。
bash
sirrmeshd config verifyconfig get
获取配置项。
bash
sirrmeshd config get server.hostnameconfig set
设置配置项。
bash
sirrmeshd config set server.hostname mail.example.comDKIM 管理
dkim generate
生成 DKIM 密钥对。
bash
sirrmeshd dkim generate \
--domain example.com \
--selector default \
--bits 2048dkim 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 GBquota set
设置用户配额。
bash
sirrmeshd quota set \
--user [email protected] \
--quota 10GBquota 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.gzbackup list
列出可用备份。
bash
sirrmeshd backup list --path /backups数据库管理
db migrate
运行数据库迁移。
bash
sirrmeshd db migratedb ping
测试数据库连接。
bash
sirrmeshd db pingdb vacuum
优化数据库。
bash
sirrmeshd db vacuum存储管理
storage stats
查看存储统计。
bash
sirrmeshd storage statsstorage test
测试存储连接。
bash
sirrmeshd storage test --type s3storage migrate
迁移存储后端。
bash
sirrmeshd storage migrate \
--from local \
--to s3storage cleanup
清理过期数据。
bash
sirrmeshd storage cleanup \
--older-than 2y \
--dry-run模块管理
module list
列出所有模块。
bash
sirrmeshd module listmodule enable
启用模块。
bash
sirrmeshd module enable spam-filtermodule disable
禁用模块。
bash
sirrmeshd module disable spam-filtermodule 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,345health
健康检查。
bash
sirrmeshd health输出:
✓ Database: OK
✓ SMTP: OK
✓ IMAP: OK
✓ Storage: OK
✓ Memory: OK (45% used)
✓ Disk: OK (32% used)诊断工具
diagnose
运行诊断检查。
bash
sirrmeshd diagnosetest-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 passShell 补全
生成 shell 补全脚本。
Bash
bash
sirrmeshd completion bash > /etc/bash_completion.d/sirrmeshdZsh
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 数据目录更多信息: