feat: add email notification and logging features

- Introduce email notification configuration options in the README
- Create a new config.sh file for managing environment variables
- Implement mail.sh for sending email notifications
- Add logging functionality to main.sh for tracking synchronization processes

These changes enhance the functionality of the script by allowing users to receive email notifications about the synchronization status and maintain logs of the operations performed. The new configuration options provide flexibility in managing email settings and improve the overall usability of the tool.
This commit is contained in:
songtianlun
2025-01-03 17:03:01 +08:00
parent bf753e1255
commit 534a9ab0e4
5 changed files with 222 additions and 224 deletions

View File

@@ -30,6 +30,22 @@
| GITEA_TOKEN | 是 | Gitea 访问令牌 | `d4209xxxxxxxxxxxxx` |
| SKIP_REPOS | 否 | 跳过的仓库列表(逗号分隔) | `repo1,repo2,repo3` |
| WORK_DIR | 否 | 临时工作目录 | `/tmp/git-mirror` |
| ENABLE_MAIL | 否 | 是否启用邮件通知 | `true` 或 `false` | `false` |
| SMTP_SERVER | 否 | SMTP 服务器地址 | `smtp.gmail.com` | - |
| SMTP_PORT | 否 | SMTP 端口 | `587` | `587` |
| SMTP_USER | 否 | SMTP 用户名 | `your-email@gmail.com` | - |
| SMTP_PASS | 否 | SMTP 密码 | `your-password` | - |
| MAIL_TO | 否 | 接收通知的邮箱 | `your-email@example.com` | - |
| MAIL_FROM | 否 | 发件人地址 | `noreply@example.com` | `$SMTP_USER` |
## 日志文件
脚本会自动创建日志文件,包含完整的运行记录:
- 默认日志目录:`/tmp/github-mirror-logs`
- 日志文件名格式:`mirror-YYYYMMDD-HHMMSS.log`
- 每次运行创建新的日志文件
- 邮件通知中包含日志最后 50 行
## 使用方法