Files
dock/te消息转发
2026-01-22 20:56:39 +08:00

59 lines
1.6 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# =================配置部分=================
# 部署目录 (默认在当前用户的 home 目录下创建 telegram-monitor)
# 如果需要修改路径,请更改下面的 BASE_DIR 变量
BASE_DIR="$HOME/telegram-monitor"
# 配置文件名称 (以容器命名)
COMPOSE_FILE="telegram-monitor.yml"
# =========================================
echo "🚀 开始部署 Telegram Monitor..."
# 1. 创建文件夹
if [ ! -d "$BASE_DIR" ]; then
echo "📂 创建目录: $BASE_DIR"
mkdir -p "$BASE_DIR/data"
else
echo "📂 目录已存在: $BASE_DIR"
fi
# 进入目录
cd "$BASE_DIR"
# 2. 生成 telegram-monitor.yml 文件
echo "📝 正在生成配置文件: $COMPOSE_FILE"
cat > $COMPOSE_FILE <<EOF
version: '3.8'
services:
telegram-monitor:
image: ghcr.io/riniba/telegrammonitor:latest
container_name: telegram-monitor
restart: unless-stopped
ports:
- "5005:5005"
volumes:
- ./data:/app
environment:
- ASPNETCORE_ENVIRONMENT=Production
EOF
# 3. 启动容器
echo "🐳 正在拉取镜像并启动服务..."
# 检查是否安装了 docker compose (新版) 还是 docker-compose (旧版)
if docker compose version >/dev/null 2>&1; then
docker compose -f $COMPOSE_FILE up -d
elif docker-compose version >/dev/null 2>&1; then
docker-compose -f $COMPOSE_FILE up -d
else
echo "❌ 未检测到 Docker Compose请先安装 Docker。"
exit 1
fi
echo ""
echo "✅ 部署完成!"
echo "📂 数据目录位于: $BASE_DIR/data"
echo "📄 配置文件位于: $BASE_DIR/$COMPOSE_FILE"
echo "🌍 访问地址: http://服务器IP:5005"