mirror of
https://github.com/andrey271192/PCAtelegram_web.git
synced 2026-09-20 11:55:32 +00:00
refactor: rename project to PCAtelegram_web
This commit is contained in:
142
lib/backup.sh
Normal file → Executable file
142
lib/backup.sh
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# goTelegram Pro v2.5.0 — backup and restore (i18n-aware)
|
||||
# PCAtelegram_web v2.5.0 — backup and restore (i18n-aware)
|
||||
|
||||
# ── Создание бекапа ──────────────────────────────────────────────────────────
|
||||
create_backup() {
|
||||
@@ -12,9 +12,9 @@ create_backup() {
|
||||
mkdir -p "$output_dir"
|
||||
while true; do
|
||||
if [ "$suffix" -eq 0 ]; then
|
||||
backup_name="gotelegram_backup_${timestamp}"
|
||||
backup_name="pcatelegram_web_backup_${timestamp}"
|
||||
else
|
||||
backup_name="gotelegram_backup_${timestamp}_${suffix}"
|
||||
backup_name="pcatelegram_web_backup_${timestamp}_${suffix}"
|
||||
fi
|
||||
tmp_dir="/tmp/${backup_name}"
|
||||
if [ ! -e "$tmp_dir" ] && \
|
||||
@@ -34,20 +34,20 @@ create_backup() {
|
||||
cp "$TELEMT_CONFIG" "$tmp_dir/config.toml"
|
||||
fi
|
||||
|
||||
# goTelegram Pro конфиг
|
||||
if [ -f "$GOTELEGRAM_CONFIG" ]; then
|
||||
cp "$GOTELEGRAM_CONFIG" "$tmp_dir/gotelegram.json"
|
||||
# PCAtelegram_web конфиг
|
||||
if [ -f "$PCATELEGRAM_WEB_CONFIG" ]; then
|
||||
cp "$PCATELEGRAM_WEB_CONFIG" "$tmp_dir/pcatelegram_web.json"
|
||||
fi
|
||||
if [ -f "$GOTELEGRAM_DIR/disabled_users.json" ]; then
|
||||
cp "$GOTELEGRAM_DIR/disabled_users.json" "$tmp_dir/disabled_users.json" 2>/dev/null
|
||||
if [ -f "$PCATELEGRAM_WEB_DIR/disabled_users.json" ]; then
|
||||
cp "$PCATELEGRAM_WEB_DIR/disabled_users.json" "$tmp_dir/disabled_users.json" 2>/dev/null
|
||||
fi
|
||||
if [ -f "$GOTELEGRAM_DIR/backup_schedule.json" ]; then
|
||||
cp "$GOTELEGRAM_DIR/backup_schedule.json" "$tmp_dir/backup_schedule.json" 2>/dev/null
|
||||
if [ -f "$PCATELEGRAM_WEB_DIR/backup_schedule.json" ]; then
|
||||
cp "$PCATELEGRAM_WEB_DIR/backup_schedule.json" "$tmp_dir/backup_schedule.json" 2>/dev/null
|
||||
fi
|
||||
|
||||
# Language marker (i18n)
|
||||
if [ -f "$GOTELEGRAM_DIR/.language" ]; then
|
||||
cp "$GOTELEGRAM_DIR/.language" "$tmp_dir/.language"
|
||||
if [ -f "$PCATELEGRAM_WEB_DIR/.language" ]; then
|
||||
cp "$PCATELEGRAM_WEB_DIR/.language" "$tmp_dir/.language"
|
||||
fi
|
||||
|
||||
# nginx конфиг (stealth mode)
|
||||
@@ -76,12 +76,12 @@ create_backup() {
|
||||
fi
|
||||
|
||||
# Custom templates and catalog
|
||||
if [ -d "$GOTELEGRAM_DIR/custom_templates" ]; then
|
||||
if [ -d "$PCATELEGRAM_WEB_DIR/custom_templates" ]; then
|
||||
mkdir -p "$tmp_dir/custom_templates"
|
||||
cp -a "$GOTELEGRAM_DIR/custom_templates/." "$tmp_dir/custom_templates/" 2>/dev/null
|
||||
cp -a "$PCATELEGRAM_WEB_DIR/custom_templates/." "$tmp_dir/custom_templates/" 2>/dev/null
|
||||
fi
|
||||
if [ -f "$GOTELEGRAM_DIR/templates_catalog.json" ]; then
|
||||
cp "$GOTELEGRAM_DIR/templates_catalog.json" "$tmp_dir/templates_catalog.json" 2>/dev/null
|
||||
if [ -f "$PCATELEGRAM_WEB_DIR/templates_catalog.json" ]; then
|
||||
cp "$PCATELEGRAM_WEB_DIR/templates_catalog.json" "$tmp_dir/templates_catalog.json" 2>/dev/null
|
||||
fi
|
||||
|
||||
# Bot state (.env has BotFather token, so encrypted backups are strongly recommended)
|
||||
@@ -100,14 +100,14 @@ create_backup() {
|
||||
fi
|
||||
|
||||
# Traffic history
|
||||
if [ -f "$GOTELEGRAM_DIR/stats_history.csv" ]; then
|
||||
cp "$GOTELEGRAM_DIR/stats_history.csv" "$tmp_dir/stats_history.csv" 2>/dev/null
|
||||
if [ -f "$PCATELEGRAM_WEB_DIR/stats_history.csv" ]; then
|
||||
cp "$PCATELEGRAM_WEB_DIR/stats_history.csv" "$tmp_dir/stats_history.csv" 2>/dev/null
|
||||
fi
|
||||
if [ -f "$GOTELEGRAM_DIR/user_stats_history.csv" ]; then
|
||||
cp "$GOTELEGRAM_DIR/user_stats_history.csv" "$tmp_dir/user_stats_history.csv" 2>/dev/null
|
||||
if [ -f "$PCATELEGRAM_WEB_DIR/user_stats_history.csv" ]; then
|
||||
cp "$PCATELEGRAM_WEB_DIR/user_stats_history.csv" "$tmp_dir/user_stats_history.csv" 2>/dev/null
|
||||
fi
|
||||
if [ -f "$GOTELEGRAM_DIR/shared-443.json" ]; then
|
||||
cp "$GOTELEGRAM_DIR/shared-443.json" "$tmp_dir/shared-443.json" 2>/dev/null
|
||||
if [ -f "$PCATELEGRAM_WEB_DIR/shared-443.json" ]; then
|
||||
cp "$PCATELEGRAM_WEB_DIR/shared-443.json" "$tmp_dir/shared-443.json" 2>/dev/null
|
||||
fi
|
||||
|
||||
# Метаданные
|
||||
@@ -124,7 +124,7 @@ create_backup() {
|
||||
cat > "$tmp_dir/metadata.json" << EOMETA
|
||||
{
|
||||
"backup_version": "1.6",
|
||||
"gotelegram_version": "$GOTELEGRAM_VERSION",
|
||||
"pcatelegram_web_version": "$PCATELEGRAM_WEB_VERSION",
|
||||
"created_at": "$(date -Iseconds)",
|
||||
"hostname": "$(hostname)",
|
||||
"ip": "$ip",
|
||||
@@ -201,7 +201,7 @@ restore_backup() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
local tmp_dir="/tmp/gotelegram_restore_$$"
|
||||
local tmp_dir="/tmp/pcatelegram_web_restore_$$"
|
||||
mkdir -p "$tmp_dir"
|
||||
|
||||
# Расшифровываем если нужно
|
||||
@@ -212,7 +212,7 @@ restore_backup() {
|
||||
read -rs password
|
||||
echo ""
|
||||
fi
|
||||
tar_file="/tmp/gotelegram_restore_$$.tar.gz"
|
||||
tar_file="/tmp/pcatelegram_web_restore_$$.tar.gz"
|
||||
openssl enc -aes-256-cbc -d -pbkdf2 -in "$backup_file" -out "$tar_file" -pass "pass:${password}" 2>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
log_error "$(_t_or backup_bad_pass 'Неверный пароль или повреждённый файл')"
|
||||
@@ -233,25 +233,25 @@ restore_backup() {
|
||||
|
||||
# Находим папку бекапа
|
||||
local backup_dir
|
||||
backup_dir=$(find "$tmp_dir" -maxdepth 1 -type d -name "gotelegram_backup_*" | head -1)
|
||||
backup_dir=$(find "$tmp_dir" -maxdepth 1 -type d -name "pcatelegram_web_backup_*" | head -1)
|
||||
[ -z "$backup_dir" ] && backup_dir="$tmp_dir"
|
||||
|
||||
# Legacy bot backups before v2.5.0 stored absolute paths directly in tar:
|
||||
# opt/gotelegram/config.json and etc/telemt/config.toml.
|
||||
# opt/pcatelegram_web/config.json and etc/telemt/config.toml.
|
||||
if [ ! -f "$backup_dir/config.toml" ] && [ -f "$tmp_dir/etc/telemt/config.toml" ]; then
|
||||
cp "$tmp_dir/etc/telemt/config.toml" "$backup_dir/config.toml" 2>/dev/null || true
|
||||
fi
|
||||
if [ ! -f "$backup_dir/gotelegram.json" ] && [ -f "$tmp_dir/opt/gotelegram/config.json" ]; then
|
||||
cp "$tmp_dir/opt/gotelegram/config.json" "$backup_dir/gotelegram.json" 2>/dev/null || true
|
||||
if [ ! -f "$backup_dir/pcatelegram_web.json" ] && [ -f "$tmp_dir/opt/pcatelegram_web/config.json" ]; then
|
||||
cp "$tmp_dir/opt/pcatelegram_web/config.json" "$backup_dir/pcatelegram_web.json" 2>/dev/null || true
|
||||
fi
|
||||
if [ ! -f "$backup_dir/disabled_users.json" ] && [ -f "$tmp_dir/opt/gotelegram/disabled_users.json" ]; then
|
||||
cp "$tmp_dir/opt/gotelegram/disabled_users.json" "$backup_dir/disabled_users.json" 2>/dev/null || true
|
||||
if [ ! -f "$backup_dir/disabled_users.json" ] && [ -f "$tmp_dir/opt/pcatelegram_web/disabled_users.json" ]; then
|
||||
cp "$tmp_dir/opt/pcatelegram_web/disabled_users.json" "$backup_dir/disabled_users.json" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Проверяем метаданные
|
||||
if [ -f "$backup_dir/metadata.json" ]; then
|
||||
local bk_version bk_mode bk_ip bk_lang bk_date
|
||||
bk_version=$(jq -r '.gotelegram_version // "unknown"' "$backup_dir/metadata.json")
|
||||
bk_version=$(jq -r '.pcatelegram_web_version // "unknown"' "$backup_dir/metadata.json")
|
||||
bk_mode=$(jq -r '.mode // "unknown"' "$backup_dir/metadata.json")
|
||||
bk_ip=$(jq -r '.ip // "unknown"' "$backup_dir/metadata.json")
|
||||
bk_lang=$(jq -r '.language // "-"' "$backup_dir/metadata.json")
|
||||
@@ -280,24 +280,24 @@ restore_backup() {
|
||||
log_success "$(_t_or backup_restored_telemt 'telemt конфиг восстановлен')"
|
||||
fi
|
||||
|
||||
# Восстанавливаем goTelegram Pro конфиг
|
||||
if [ -f "$backup_dir/gotelegram.json" ]; then
|
||||
mkdir -p "$GOTELEGRAM_DIR"
|
||||
cp "$backup_dir/gotelegram.json" "$GOTELEGRAM_CONFIG"
|
||||
log_success "$(_t_or backup_restored_gotelegram 'GoTelegram конфиг восстановлен')"
|
||||
# Восстанавливаем PCAtelegram_web конфиг
|
||||
if [ -f "$backup_dir/pcatelegram_web.json" ]; then
|
||||
mkdir -p "$PCATELEGRAM_WEB_DIR"
|
||||
cp "$backup_dir/pcatelegram_web.json" "$PCATELEGRAM_WEB_CONFIG"
|
||||
log_success "$(_t_or backup_restored_pcatelegram_web 'PCAtelegram_web конфиг восстановлен')"
|
||||
fi
|
||||
if [ -f "$backup_dir/disabled_users.json" ]; then
|
||||
mkdir -p "$GOTELEGRAM_DIR"
|
||||
cp "$backup_dir/disabled_users.json" "$GOTELEGRAM_DIR/disabled_users.json"
|
||||
chmod 600 "$GOTELEGRAM_DIR/disabled_users.json" 2>/dev/null || true
|
||||
mkdir -p "$PCATELEGRAM_WEB_DIR"
|
||||
cp "$backup_dir/disabled_users.json" "$PCATELEGRAM_WEB_DIR/disabled_users.json"
|
||||
chmod 600 "$PCATELEGRAM_WEB_DIR/disabled_users.json" 2>/dev/null || true
|
||||
fi
|
||||
if [ -f "$backup_dir/backup_schedule.json" ]; then
|
||||
mkdir -p "$GOTELEGRAM_DIR"
|
||||
cp "$backup_dir/backup_schedule.json" "$GOTELEGRAM_DIR/backup_schedule.json" 2>/dev/null
|
||||
chmod 600 "$GOTELEGRAM_DIR/backup_schedule.json" 2>/dev/null || true
|
||||
mkdir -p "$PCATELEGRAM_WEB_DIR"
|
||||
cp "$backup_dir/backup_schedule.json" "$PCATELEGRAM_WEB_DIR/backup_schedule.json" 2>/dev/null
|
||||
chmod 600 "$PCATELEGRAM_WEB_DIR/backup_schedule.json" 2>/dev/null || true
|
||||
if command -v jq >/dev/null 2>&1; then
|
||||
local restored_schedule
|
||||
restored_schedule=$(jq -r '.frequency // "off"' "$GOTELEGRAM_DIR/backup_schedule.json" 2>/dev/null || echo "off")
|
||||
restored_schedule=$(jq -r '.frequency // "off"' "$PCATELEGRAM_WEB_DIR/backup_schedule.json" 2>/dev/null || echo "off")
|
||||
case "$restored_schedule" in
|
||||
off|daily|weekly|monthly) set_backup_schedule "$restored_schedule" >/dev/null 2>&1 || true ;;
|
||||
esac
|
||||
@@ -306,8 +306,8 @@ restore_backup() {
|
||||
|
||||
# Восстанавливаем language marker (i18n)
|
||||
if [ -f "$backup_dir/.language" ]; then
|
||||
mkdir -p "$GOTELEGRAM_DIR"
|
||||
cp "$backup_dir/.language" "$GOTELEGRAM_DIR/.language"
|
||||
mkdir -p "$PCATELEGRAM_WEB_DIR"
|
||||
cp "$backup_dir/.language" "$PCATELEGRAM_WEB_DIR/.language"
|
||||
log_success "$(_t_or backup_restored_lang 'Язык интерфейса восстановлен')"
|
||||
fi
|
||||
|
||||
@@ -347,23 +347,23 @@ restore_backup() {
|
||||
|
||||
# Восстанавливаем custom templates/catalog/statistics
|
||||
if [ -d "$backup_dir/custom_templates" ]; then
|
||||
mkdir -p "$GOTELEGRAM_DIR/custom_templates"
|
||||
cp -a "$backup_dir/custom_templates/." "$GOTELEGRAM_DIR/custom_templates/" 2>/dev/null
|
||||
mkdir -p "$PCATELEGRAM_WEB_DIR/custom_templates"
|
||||
cp -a "$backup_dir/custom_templates/." "$PCATELEGRAM_WEB_DIR/custom_templates/" 2>/dev/null
|
||||
log_success "Пользовательские шаблоны восстановлены"
|
||||
fi
|
||||
if [ -f "$backup_dir/templates_catalog.json" ]; then
|
||||
cp "$backup_dir/templates_catalog.json" "$GOTELEGRAM_DIR/templates_catalog.json" 2>/dev/null
|
||||
cp "$backup_dir/templates_catalog.json" "$PCATELEGRAM_WEB_DIR/templates_catalog.json" 2>/dev/null
|
||||
fi
|
||||
if [ -f "$backup_dir/stats_history.csv" ]; then
|
||||
cp "$backup_dir/stats_history.csv" "$GOTELEGRAM_DIR/stats_history.csv" 2>/dev/null
|
||||
cp "$backup_dir/stats_history.csv" "$PCATELEGRAM_WEB_DIR/stats_history.csv" 2>/dev/null
|
||||
log_success "История статистики восстановлена"
|
||||
fi
|
||||
if [ -f "$backup_dir/user_stats_history.csv" ]; then
|
||||
cp "$backup_dir/user_stats_history.csv" "$GOTELEGRAM_DIR/user_stats_history.csv" 2>/dev/null
|
||||
cp "$backup_dir/user_stats_history.csv" "$PCATELEGRAM_WEB_DIR/user_stats_history.csv" 2>/dev/null
|
||||
log_success "История статистики пользователей восстановлена"
|
||||
fi
|
||||
if [ -f "$backup_dir/shared-443.json" ]; then
|
||||
cp "$backup_dir/shared-443.json" "$GOTELEGRAM_DIR/shared-443.json" 2>/dev/null
|
||||
cp "$backup_dir/shared-443.json" "$PCATELEGRAM_WEB_DIR/shared-443.json" 2>/dev/null
|
||||
fi
|
||||
|
||||
# Восстанавливаем состояние бота
|
||||
@@ -392,8 +392,8 @@ restore_backup() {
|
||||
start_telemt
|
||||
fi
|
||||
command -v nginx &>/dev/null && systemctl start nginx 2>/dev/null
|
||||
systemctl restart gotelegram-bot 2>/dev/null || true
|
||||
systemctl restart gotelegram-admin 2>/dev/null || true
|
||||
systemctl restart pcatelegram_web-bot 2>/dev/null || true
|
||||
systemctl restart pcatelegram_web-admin 2>/dev/null || true
|
||||
|
||||
# Очистка
|
||||
rm -rf "$tmp_dir"
|
||||
@@ -469,43 +469,43 @@ set_backup_schedule() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
mkdir -p "$GOTELEGRAM_DIR" "$BACKUP_DIR"
|
||||
mkdir -p "$PCATELEGRAM_WEB_DIR" "$BACKUP_DIR"
|
||||
|
||||
if [ "$frequency" = "off" ]; then
|
||||
systemctl disable --now gotelegram-backup.timer >/dev/null 2>&1 || true
|
||||
rm -f /etc/systemd/system/gotelegram-backup.timer /etc/systemd/system/gotelegram-backup.service
|
||||
systemctl disable --now pcatelegram_web-backup.timer >/dev/null 2>&1 || true
|
||||
rm -f /etc/systemd/system/pcatelegram_web-backup.timer /etc/systemd/system/pcatelegram_web-backup.service
|
||||
systemctl daemon-reload >/dev/null 2>&1 || true
|
||||
else
|
||||
cat > /etc/systemd/system/gotelegram-backup.service << 'EOSVC'
|
||||
cat > /etc/systemd/system/pcatelegram_web-backup.service << 'EOSVC'
|
||||
[Unit]
|
||||
Description=goTelegram Pro backup
|
||||
Description=PCAtelegram_web backup
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
Environment=GOTELEGRAM_BACKUP_KEEP=30
|
||||
ExecStart=/bin/bash -lc 'source /opt/gotelegram/lib/common.sh; source /opt/gotelegram/lib/i18n.sh; source /opt/gotelegram/lib/telemt.sh; source /opt/gotelegram/lib/website.sh; source /opt/gotelegram/lib/backup.sh; load_language "$(detect_language 2>/dev/null || echo en)"; create_backup ""; cleanup_old_backups "${GOTELEGRAM_BACKUP_KEEP:-30}"'
|
||||
Environment=PCATELEGRAM_WEB_BACKUP_KEEP=30
|
||||
ExecStart=/bin/bash -lc 'source /opt/pcatelegram_web/lib/common.sh; source /opt/pcatelegram_web/lib/i18n.sh; source /opt/pcatelegram_web/lib/telemt.sh; source /opt/pcatelegram_web/lib/website.sh; source /opt/pcatelegram_web/lib/backup.sh; load_language "$(detect_language 2>/dev/null || echo en)"; create_backup ""; cleanup_old_backups "${PCATELEGRAM_WEB_BACKUP_KEEP:-30}"'
|
||||
EOSVC
|
||||
|
||||
cat > /etc/systemd/system/gotelegram-backup.timer << EOTIMER
|
||||
cat > /etc/systemd/system/pcatelegram_web-backup.timer << EOTIMER
|
||||
[Unit]
|
||||
Description=goTelegram Pro scheduled backup
|
||||
Description=PCAtelegram_web scheduled backup
|
||||
|
||||
[Timer]
|
||||
OnCalendar=$calendar
|
||||
Persistent=true
|
||||
RandomizedDelaySec=15m
|
||||
Unit=gotelegram-backup.service
|
||||
Unit=pcatelegram_web-backup.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
EOTIMER
|
||||
systemctl daemon-reload >/dev/null 2>&1 || return 1
|
||||
systemctl enable --now gotelegram-backup.timer >/dev/null 2>&1 || return 1
|
||||
systemctl enable --now pcatelegram_web-backup.timer >/dev/null 2>&1 || return 1
|
||||
fi
|
||||
|
||||
cat > "$GOTELEGRAM_DIR/backup_schedule.json" << EOSCHEDULE
|
||||
cat > "$PCATELEGRAM_WEB_DIR/backup_schedule.json" << EOSCHEDULE
|
||||
{
|
||||
"frequency": "$frequency",
|
||||
"calendar": "$calendar",
|
||||
@@ -513,19 +513,19 @@ EOTIMER
|
||||
"updated_at": "$(date -Iseconds)"
|
||||
}
|
||||
EOSCHEDULE
|
||||
chmod 600 "$GOTELEGRAM_DIR/backup_schedule.json" 2>/dev/null || true
|
||||
chmod 600 "$PCATELEGRAM_WEB_DIR/backup_schedule.json" 2>/dev/null || true
|
||||
log_success "Backup schedule: $frequency"
|
||||
echo "$frequency"
|
||||
}
|
||||
|
||||
backup_schedule_status() {
|
||||
local frequency="off" calendar=""
|
||||
if [ -f "$GOTELEGRAM_DIR/backup_schedule.json" ] && command -v jq >/dev/null 2>&1; then
|
||||
frequency=$(jq -r '.frequency // "off"' "$GOTELEGRAM_DIR/backup_schedule.json" 2>/dev/null || echo "off")
|
||||
calendar=$(jq -r '.calendar // ""' "$GOTELEGRAM_DIR/backup_schedule.json" 2>/dev/null || echo "")
|
||||
if [ -f "$PCATELEGRAM_WEB_DIR/backup_schedule.json" ] && command -v jq >/dev/null 2>&1; then
|
||||
frequency=$(jq -r '.frequency // "off"' "$PCATELEGRAM_WEB_DIR/backup_schedule.json" 2>/dev/null || echo "off")
|
||||
calendar=$(jq -r '.calendar // ""' "$PCATELEGRAM_WEB_DIR/backup_schedule.json" 2>/dev/null || echo "")
|
||||
fi
|
||||
echo "frequency=$frequency calendar=$calendar"
|
||||
systemctl list-timers gotelegram-backup.timer --no-pager 2>/dev/null || true
|
||||
systemctl list-timers pcatelegram_web-backup.timer --no-pager 2>/dev/null || true
|
||||
}
|
||||
|
||||
# ── Интерактивный бекап ──────────────────────────────────────────────────────
|
||||
|
||||
96
lib/common.sh
Normal file → Executable file
96
lib/common.sh
Normal file → Executable file
@@ -1,32 +1,32 @@
|
||||
#!/bin/bash
|
||||
# goTelegram Pro v2.5.0 — common utilities
|
||||
# PCAtelegram_web v2.5.0 — common utilities
|
||||
# Colors, logging, spinner, system helpers, v1 compat, i18n-aware
|
||||
|
||||
# ── Version ───────────────────────────────────────────────────────────────────
|
||||
GOTELEGRAM_VERSION="2.5.0"
|
||||
GOTELEGRAM_NAME="goTelegram Pro"
|
||||
PCATELEGRAM_WEB_VERSION="2.5.0"
|
||||
PCATELEGRAM_WEB_NAME="PCAtelegram_web"
|
||||
|
||||
# ── Пути ──────────────────────────────────────────────────────────────────────
|
||||
GOTELEGRAM_DIR="/opt/gotelegram"
|
||||
GOTELEGRAM_CONFIG="$GOTELEGRAM_DIR/config.json"
|
||||
PCATELEGRAM_WEB_DIR="/opt/pcatelegram_web"
|
||||
PCATELEGRAM_WEB_CONFIG="$PCATELEGRAM_WEB_DIR/config.json"
|
||||
TELEMT_CONFIG="/etc/telemt/config.toml"
|
||||
TELEMT_BIN="/usr/local/bin/telemt"
|
||||
TELEMT_SERVICE="telemt"
|
||||
NGINX_SITE_CONF="/etc/nginx/sites-available/gotelegram"
|
||||
NGINX_SITE_LINK="/etc/nginx/sites-enabled/gotelegram"
|
||||
WEBSITE_ROOT="/var/www/gotelegram-site"
|
||||
BACKUP_DIR="$GOTELEGRAM_DIR/backups"
|
||||
LOG_FILE="/var/log/gotelegram.log"
|
||||
BOT_DIR="/opt/gotelegram-bot"
|
||||
ADMIN_WEB_DIR="/opt/gotelegram-admin"
|
||||
ADMIN_WEB_SERVICE="gotelegram-admin"
|
||||
NGINX_SITE_CONF="/etc/nginx/sites-available/pcatelegram_web"
|
||||
NGINX_SITE_LINK="/etc/nginx/sites-enabled/pcatelegram_web"
|
||||
WEBSITE_ROOT="/var/www/pcatelegram_web-site"
|
||||
BACKUP_DIR="$PCATELEGRAM_WEB_DIR/backups"
|
||||
LOG_FILE="/var/log/pcatelegram_web.log"
|
||||
BOT_DIR="/opt/pcatelegram_web-bot"
|
||||
ADMIN_WEB_DIR="/opt/pcatelegram_web-admin"
|
||||
ADMIN_WEB_SERVICE="pcatelegram_web-admin"
|
||||
ADMIN_WEB_HOST="127.0.0.1"
|
||||
ADMIN_WEB_PORT="1984"
|
||||
|
||||
# ── V1 совместимость ─────────────────────────────────────────────────────────
|
||||
V1_CONTAINER_NAME="mtproto-proxy"
|
||||
V1_CONFIG_FILE="/opt/gotelegram-bot/proxy.json"
|
||||
V1_SERVICE_NAME="gotelegram-bot"
|
||||
V1_CONFIG_FILE="/opt/pcatelegram_web-bot/proxy.json"
|
||||
V1_SERVICE_NAME="pcatelegram_web-bot"
|
||||
|
||||
# ── Цвета ────────────────────────────────────────────────────────────────────
|
||||
RED='\033[0;31m'
|
||||
@@ -93,7 +93,7 @@ progress_bar() {
|
||||
# ── Выполнение с индикатором ─────────────────────────────────────────────────
|
||||
run_with_spinner() {
|
||||
local label="$1"; shift
|
||||
local err_file="/tmp/.gotelegram_spinner_err_$$"
|
||||
local err_file="/tmp/.pcatelegram_web_spinner_err_$$"
|
||||
spinner_start "$label"
|
||||
"$@" >/dev/null 2>"$err_file"
|
||||
local rc=$?
|
||||
@@ -119,11 +119,11 @@ show_banner() {
|
||||
echo ""
|
||||
echo -e "${CYAN}${line}${NC}"
|
||||
if type tf &>/dev/null; then
|
||||
echo -e " ${BOLD}${WHITE}🚀 $(tf banner_title "$GOTELEGRAM_VERSION")${NC}"
|
||||
echo -e " ${BOLD}${WHITE}🚀 $(tf banner_title "$PCATELEGRAM_WEB_VERSION")${NC}"
|
||||
echo -e " ${DIM}$(t banner_subtitle)${NC}"
|
||||
echo -e " ${DIM}$(t banner_features)${NC}"
|
||||
else
|
||||
echo -e " ${BOLD}${WHITE}🚀 goTelegram Pro v${GOTELEGRAM_VERSION}${NC}"
|
||||
echo -e " ${BOLD}${WHITE}🚀 PCAtelegram_web v${PCATELEGRAM_WEB_VERSION}${NC}"
|
||||
echo -e " ${DIM}MTProxy powered by telemt (Rust + Tokio)${NC}"
|
||||
echo -e " ${DIM}Anti-DPI • Fake TLS • TCP Splice • JA3/JA4${NC}"
|
||||
fi
|
||||
@@ -306,7 +306,7 @@ apt_update() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# ── Зависимости GoTelegram ──────────────────────────────────────────────────
|
||||
# ── Зависимости PCAtelegram_web ──────────────────────────────────────────────────
|
||||
# Полный список внешних команд, которые скрипт использует. Для каждой команды
|
||||
# указан пакет на apt и dnf/yum (имена различаются: например dig = dnsutils на
|
||||
# Debian, bind-utils на RHEL).
|
||||
@@ -429,7 +429,7 @@ ensure_deps() {
|
||||
|
||||
if [ ${#still_missing[@]} -gt 0 ]; then
|
||||
log_error "Critical dependencies still missing: ${still_missing[*]}"
|
||||
log_error "Install manually and re-run gotelegram"
|
||||
log_error "Install manually and re-run pcatelegram_web"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -483,32 +483,32 @@ detect_3xui_443_listener() {
|
||||
warn_3xui_443_conflict() {
|
||||
detect_3xui_443_listener || return 1
|
||||
log_warning "Обнаружен 3x-ui/Xray, который уже слушает TCP/443."
|
||||
log_warning "goTelegram Pro не будет молча останавливать или переписывать 3x-ui."
|
||||
log_dim "Для настоящего shared-443 нужен один фронтовой TLS/SNI-диспетчер и разные SNI-домены для Xray и goTelegram Pro."
|
||||
mkdir -p "$GOTELEGRAM_DIR" 2>/dev/null
|
||||
cat > "$GOTELEGRAM_DIR/shared-443-3xui.md" <<'EOF' 2>/dev/null || true
|
||||
# goTelegram Pro + 3x-ui on one TCP/443
|
||||
log_warning "PCAtelegram_web не будет молча останавливать или переписывать 3x-ui."
|
||||
log_dim "Для настоящего shared-443 нужен один фронтовой TLS/SNI-диспетчер и разные SNI-домены для Xray и PCAtelegram_web."
|
||||
mkdir -p "$PCATELEGRAM_WEB_DIR" 2>/dev/null
|
||||
cat > "$PCATELEGRAM_WEB_DIR/shared-443-3xui.md" <<'EOF' 2>/dev/null || true
|
||||
# PCAtelegram_web + 3x-ui on one TCP/443
|
||||
|
||||
goTelegram Pro detected that 3x-ui/Xray already owns TCP/443. Two independent
|
||||
PCAtelegram_web detected that 3x-ui/Xray already owns TCP/443. Two independent
|
||||
processes cannot bind the same IP:port at the same time. A safe shared setup
|
||||
needs one front TLS/SNI dispatcher on 443 and internal backends, for example:
|
||||
|
||||
- dispatcher: 0.0.0.0:443 (nginx stream ssl_preread)
|
||||
- goTelegram Pro telemt: 127.0.0.1:7443
|
||||
- PCAtelegram_web telemt: 127.0.0.1:7443
|
||||
- 3x-ui/Xray inbound: 127.0.0.1:9443
|
||||
- goTelegram Pro nginx mask site: 127.0.0.1:8443
|
||||
- PCAtelegram_web nginx mask site: 127.0.0.1:8443
|
||||
|
||||
The dispatcher routes Xray SNI domains to Xray. Everything else goes to telemt;
|
||||
telemt then decides whether the session is MTProxy or regular HTTPS and forwards
|
||||
the website to nginx through dns_overrides.
|
||||
|
||||
goTelegram Pro can generate the dispatcher with:
|
||||
PCAtelegram_web can generate the dispatcher with:
|
||||
|
||||
source /opt/gotelegram/lib/shared443.sh
|
||||
shared443_enable <gotelegram-domain> <xray-sni-domain> 127.0.0.1:9443
|
||||
source /opt/pcatelegram_web/lib/shared443.sh
|
||||
shared443_enable <pcatelegram_web-domain> <xray-sni-domain> 127.0.0.1:9443
|
||||
|
||||
Move the 3x-ui/Xray inbound from 0.0.0.0:443 to 127.0.0.1:9443 in the panel first,
|
||||
or nginx will not be able to own the public 443 socket. goTelegram Pro intentionally
|
||||
or nginx will not be able to own the public 443 socket. PCAtelegram_web intentionally
|
||||
does not rewrite the 3x-ui SQLite database or generated Xray config without explicit
|
||||
operator confirmation, because 3x-ui can overwrite manual JSON edits on the next
|
||||
panel change.
|
||||
@@ -531,14 +531,14 @@ check_disk_space() {
|
||||
return 0
|
||||
}
|
||||
|
||||
# ── Конфигурация GoTelegram (JSON) ──────────────────────────────────────────
|
||||
save_gotelegram_config() {
|
||||
mkdir -p "$(dirname "$GOTELEGRAM_CONFIG")"
|
||||
# ── Конфигурация PCAtelegram_web (JSON) ──────────────────────────────────────────
|
||||
save_pcatelegram_web_config() {
|
||||
mkdir -p "$(dirname "$PCATELEGRAM_WEB_CONFIG")"
|
||||
local cur_lang
|
||||
cur_lang=$(type get_language &>/dev/null && get_language || echo en)
|
||||
cat > "$GOTELEGRAM_CONFIG" << EOJSON
|
||||
cat > "$PCATELEGRAM_WEB_CONFIG" << EOJSON
|
||||
{
|
||||
"version": "$GOTELEGRAM_VERSION",
|
||||
"version": "$PCATELEGRAM_WEB_VERSION",
|
||||
"engine": "${1:-telemt}",
|
||||
"mode": "${2:-lite}",
|
||||
"port": ${3:-443},
|
||||
@@ -551,12 +551,12 @@ save_gotelegram_config() {
|
||||
"updated_at": "$(date -Iseconds)"
|
||||
}
|
||||
EOJSON
|
||||
chmod 600 "$GOTELEGRAM_CONFIG"
|
||||
chmod 600 "$PCATELEGRAM_WEB_CONFIG"
|
||||
}
|
||||
|
||||
load_gotelegram_config() {
|
||||
if [ -f "$GOTELEGRAM_CONFIG" ]; then
|
||||
cat "$GOTELEGRAM_CONFIG"
|
||||
load_pcatelegram_web_config() {
|
||||
if [ -f "$PCATELEGRAM_WEB_CONFIG" ]; then
|
||||
cat "$PCATELEGRAM_WEB_CONFIG"
|
||||
return 0
|
||||
fi
|
||||
echo "{}"
|
||||
@@ -565,11 +565,11 @@ load_gotelegram_config() {
|
||||
|
||||
config_get() {
|
||||
local key="$1"
|
||||
if [ ! -f "$GOTELEGRAM_CONFIG" ]; then
|
||||
if [ ! -f "$PCATELEGRAM_WEB_CONFIG" ]; then
|
||||
return 2 # file missing
|
||||
fi
|
||||
local val
|
||||
val=$(jq -r ".$key // empty" "$GOTELEGRAM_CONFIG" 2>/dev/null)
|
||||
val=$(jq -r ".$key // empty" "$PCATELEGRAM_WEB_CONFIG" 2>/dev/null)
|
||||
if [ $? -ne 0 ]; then
|
||||
return 3 # invalid JSON
|
||||
fi
|
||||
@@ -671,12 +671,12 @@ migrate_v1_to_v2() {
|
||||
|
||||
# Backup v1 config
|
||||
if [ -f "$V1_CONFIG_FILE" ]; then
|
||||
mkdir -p "$GOTELEGRAM_DIR"
|
||||
cp "$V1_CONFIG_FILE" "$GOTELEGRAM_DIR/v1_backup_proxy.json" 2>/dev/null
|
||||
mkdir -p "$PCATELEGRAM_WEB_DIR"
|
||||
cp "$V1_CONFIG_FILE" "$PCATELEGRAM_WEB_DIR/v1_backup_proxy.json" 2>/dev/null
|
||||
if type tf &>/dev/null; then
|
||||
log_success "$(tf v1_config_saved "$GOTELEGRAM_DIR/v1_backup_proxy.json")"
|
||||
log_success "$(tf v1_config_saved "$PCATELEGRAM_WEB_DIR/v1_backup_proxy.json")"
|
||||
else
|
||||
log_success "v1 config saved to $GOTELEGRAM_DIR/v1_backup_proxy.json"
|
||||
log_success "v1 config saved to $PCATELEGRAM_WEB_DIR/v1_backup_proxy.json"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -735,6 +735,6 @@ validate_domain() {
|
||||
|
||||
# ── Init: создание директорий ────────────────────────────────────────────────
|
||||
init_dirs() {
|
||||
mkdir -p "$GOTELEGRAM_DIR" "$BACKUP_DIR" /etc/telemt 2>/dev/null
|
||||
mkdir -p "$PCATELEGRAM_WEB_DIR" "$BACKUP_DIR" /etc/telemt 2>/dev/null
|
||||
touch "$LOG_FILE" 2>/dev/null
|
||||
}
|
||||
|
||||
12
lib/i18n.sh
Normal file → Executable file
12
lib/i18n.sh
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# GoTelegram v2.5.0 — i18n engine
|
||||
# PCAtelegram_web v2.5.0 — i18n engine
|
||||
# Internationalization support: EN (English) / RU (Русский)
|
||||
#
|
||||
# Usage:
|
||||
@@ -74,14 +74,14 @@ get_language() {
|
||||
|
||||
# ── Detect saved language from config.json, default en ──
|
||||
detect_language() {
|
||||
local cfg="${GOTELEGRAM_CONFIG:-/opt/gotelegram/config.json}"
|
||||
local cfg="${PCATELEGRAM_WEB_CONFIG:-/opt/pcatelegram_web/config.json}"
|
||||
local lang=""
|
||||
if [ -f "$cfg" ] && command -v jq >/dev/null 2>&1; then
|
||||
lang=$(jq -r '.language // empty' "$cfg" 2>/dev/null)
|
||||
fi
|
||||
# Also check marker file (language set before config.json exists)
|
||||
if [ -z "$lang" ]; then
|
||||
local marker="${GOTELEGRAM_DIR:-/opt/gotelegram}/.language"
|
||||
local marker="${PCATELEGRAM_WEB_DIR:-/opt/pcatelegram_web}/.language"
|
||||
if [ -f "$marker" ]; then
|
||||
lang=$(head -c 2 "$marker" 2>/dev/null | tr -d '[:space:]')
|
||||
fi
|
||||
@@ -100,11 +100,11 @@ save_language() {
|
||||
if ! [[ "$lang" =~ ^(en|ru)$ ]]; then
|
||||
return 1
|
||||
fi
|
||||
mkdir -p "${GOTELEGRAM_DIR:-/opt/gotelegram}" 2>/dev/null
|
||||
mkdir -p "${PCATELEGRAM_WEB_DIR:-/opt/pcatelegram_web}" 2>/dev/null
|
||||
# Always write marker for early-access (before config.json exists)
|
||||
echo "$lang" > "${GOTELEGRAM_DIR:-/opt/gotelegram}/.language" 2>/dev/null
|
||||
echo "$lang" > "${PCATELEGRAM_WEB_DIR:-/opt/pcatelegram_web}/.language" 2>/dev/null
|
||||
|
||||
local cfg="${GOTELEGRAM_CONFIG:-/opt/gotelegram/config.json}"
|
||||
local cfg="${PCATELEGRAM_WEB_CONFIG:-/opt/pcatelegram_web/config.json}"
|
||||
if [ -f "$cfg" ] && command -v jq >/dev/null 2>&1; then
|
||||
local tmp
|
||||
tmp=$(mktemp) || return 1
|
||||
|
||||
18
lib/lang/en.sh
Normal file → Executable file
18
lib/lang/en.sh
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# goTelegram Pro v2.5.0 — English translations
|
||||
# PCAtelegram_web v2.5.0 — English translations
|
||||
# shellcheck disable=SC2034,SC2148
|
||||
|
||||
# ── Common words ────────────────────────────────────────────────────────
|
||||
@@ -25,7 +25,7 @@ I18N[success]="Done"
|
||||
I18N[wait]="Please wait..."
|
||||
|
||||
# ── Banner ──────────────────────────────────────────────────────────────
|
||||
I18N[banner_title]="goTelegram Pro v%s"
|
||||
I18N[banner_title]="PCAtelegram_web v%s"
|
||||
I18N[banner_subtitle]="MTProxy powered by telemt (Rust + Tokio)"
|
||||
I18N[banner_features]="Anti-DPI • Fake TLS • TCP Splice • JA3/JA4"
|
||||
I18N[credits_title]="Credits / Thanks"
|
||||
@@ -75,7 +75,7 @@ I18N[submenu_about_title]="ℹ️ ABOUT"
|
||||
I18N[about_version_info]="Version info"
|
||||
I18N[about_promo]="Promo / Donate"
|
||||
I18N[version_title]="🔍 Information"
|
||||
I18N[version_label]="goTelegram Pro:"
|
||||
I18N[version_label]="PCAtelegram_web:"
|
||||
I18N[version_engine]="Engine:"
|
||||
I18N[version_tech]="Technology:"
|
||||
I18N[version_license]="License:"
|
||||
@@ -106,7 +106,7 @@ I18N[install_cfg_mode]="Mode:"
|
||||
I18N[install_cfg_domain]="Domain:"
|
||||
I18N[install_confirm_proxy]="Install proxy?"
|
||||
I18N[install_confirm_proxy_site]="Install proxy + website?"
|
||||
I18N[install_done]="goTelegram Pro v%s installed! (%s mode)"
|
||||
I18N[install_done]="PCAtelegram_web v%s installed! (%s mode)"
|
||||
I18N[install_arch_desc1]="telemt accepts all traffic on 443 (HTTPS masquerade)"
|
||||
I18N[install_arch_desc2]="nginx serves the site on internal port %s"
|
||||
I18N[install_arch_desc3]="ISP only sees HTTPS traffic to %s:443"
|
||||
@@ -125,7 +125,7 @@ I18N[logs_telemt_title]="📋 telemt logs (last %s lines):"
|
||||
# ── Link / Share ────────────────────────────────────────────────────────
|
||||
I18N[link_title]="🔗 Connection link:"
|
||||
I18N[share_title]="📤 Forward this message:"
|
||||
I18N[share_line1]="🔐 MTProxy for Telegram (goTelegram Pro v%s)"
|
||||
I18N[share_line1]="🔐 MTProxy for Telegram (PCAtelegram_web v%s)"
|
||||
I18N[share_server]="🌍 Server: %s"
|
||||
I18N[share_port]="🔌 Port: %s"
|
||||
I18N[share_connect_cta]="👉 Connect with one tap:"
|
||||
@@ -141,7 +141,7 @@ I18N[website_restart_nginx]="Restart nginx"
|
||||
I18N[website_change_template]="Change template"
|
||||
|
||||
# ── Remove ──────────────────────────────────────────────────────────────
|
||||
I18N[remove_title]="🗑 Remove goTelegram Pro"
|
||||
I18N[remove_title]="🗑 Remove PCAtelegram_web"
|
||||
I18N[remove_proxy_only]="Remove proxy only (telemt)"
|
||||
I18N[remove_bot_only]="Remove Telegram bot only"
|
||||
I18N[remove_all]="Remove everything (proxy + bot + settings)"
|
||||
@@ -151,7 +151,7 @@ I18N[remove_backup_before]="Create a backup before removal?"
|
||||
I18N[remove_warn_all]="This will remove EVERYTHING: proxy, bot, site, settings."
|
||||
I18N[remove_confirm_all]="Are you absolutely sure?"
|
||||
I18N[remove_proxy_done]="Proxy removed"
|
||||
I18N[remove_all_done]="goTelegram Pro fully removed (proxy + bot)"
|
||||
I18N[remove_all_done]="PCAtelegram_web fully removed (proxy + bot)"
|
||||
|
||||
# ── Telegram bot submenu ────────────────────────────────────────────────
|
||||
I18N[bot_title]="🤖 Telegram bot"
|
||||
@@ -332,7 +332,7 @@ I18N[backup_lang_label]="Language"
|
||||
I18N[backup_date_label]="Date"
|
||||
I18N[backup_confirm_restore]="Restore configuration? Current settings will be overwritten."
|
||||
I18N[backup_restored_telemt]="telemt config restored"
|
||||
I18N[backup_restored_gotelegram]="goTelegram Pro config restored"
|
||||
I18N[backup_restored_pcatelegram_web]="PCAtelegram_web config restored"
|
||||
I18N[backup_restored_lang]="Interface language restored"
|
||||
I18N[backup_restored_nginx]="nginx config restored"
|
||||
I18N[backup_restored_ssl]="SSL certificates restored"
|
||||
@@ -362,7 +362,7 @@ I18N[auto_refresh]="Refresh in 30 sec"
|
||||
I18N[deps_installing]="Installing dependencies: %s"
|
||||
|
||||
# ── Migration ───────────────────────────────────────────────────────────
|
||||
I18N[v1_detected]="⚠️ goTelegram Pro v1 (mtg) installation detected"
|
||||
I18N[v1_detected]="⚠️ PCAtelegram_web v1 (mtg) installation detected"
|
||||
I18N[v1_container]="Container: %s"
|
||||
I18N[v1_migration_step]="Migrating from v1 (mtg) to v2 (telemt)"
|
||||
I18N[v1_found_title]="Found v1 (mtg) installation:"
|
||||
|
||||
18
lib/lang/ru.sh
Normal file → Executable file
18
lib/lang/ru.sh
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# goTelegram Pro v2.5.0 — Russian translations
|
||||
# PCAtelegram_web v2.5.0 — Russian translations
|
||||
# shellcheck disable=SC2034,SC2148
|
||||
|
||||
# ── Common words ────────────────────────────────────────────────────────
|
||||
@@ -25,7 +25,7 @@ I18N[success]="Готово"
|
||||
I18N[wait]="Подождите..."
|
||||
|
||||
# ── Banner ──────────────────────────────────────────────────────────────
|
||||
I18N[banner_title]="goTelegram Pro v%s"
|
||||
I18N[banner_title]="PCAtelegram_web v%s"
|
||||
I18N[banner_subtitle]="MTProxy на ядре telemt (Rust + Tokio)"
|
||||
I18N[banner_features]="Anti-DPI • Fake TLS • TCP Splice • JA3/JA4"
|
||||
I18N[credits_title]="Благодарности / Credits"
|
||||
@@ -75,7 +75,7 @@ I18N[submenu_about_title]="ℹ️ О ПРОГРАММЕ"
|
||||
I18N[about_version_info]="Информация о версии"
|
||||
I18N[about_promo]="Промо / Донат"
|
||||
I18N[version_title]="🔍 Информация"
|
||||
I18N[version_label]="goTelegram Pro:"
|
||||
I18N[version_label]="PCAtelegram_web:"
|
||||
I18N[version_engine]="Ядро:"
|
||||
I18N[version_tech]="Технология:"
|
||||
I18N[version_license]="Лицензия:"
|
||||
@@ -106,7 +106,7 @@ I18N[install_cfg_mode]="Режим:"
|
||||
I18N[install_cfg_domain]="Домен:"
|
||||
I18N[install_confirm_proxy]="Установить прокси?"
|
||||
I18N[install_confirm_proxy_site]="Установить прокси + сайт?"
|
||||
I18N[install_done]="goTelegram Pro v%s установлен! (%s-режим)"
|
||||
I18N[install_done]="PCAtelegram_web v%s установлен! (%s-режим)"
|
||||
I18N[install_arch_desc1]="telemt принимает весь трафик на 443 (маскировка под HTTPS)"
|
||||
I18N[install_arch_desc2]="nginx обслуживает сайт на внутреннем порту %s"
|
||||
I18N[install_arch_desc3]="Провайдер видит только HTTPS-трафик к %s:443"
|
||||
@@ -125,7 +125,7 @@ I18N[logs_telemt_title]="📋 Логи telemt (последние %s строк)
|
||||
# ── Link / Share ────────────────────────────────────────────────────────
|
||||
I18N[link_title]="🔗 Ссылка для подключения:"
|
||||
I18N[share_title]="📤 Перешлите это сообщение:"
|
||||
I18N[share_line1]="🔐 MTProxy для Telegram (goTelegram Pro v%s)"
|
||||
I18N[share_line1]="🔐 MTProxy для Telegram (PCAtelegram_web v%s)"
|
||||
I18N[share_server]="🌍 Сервер: %s"
|
||||
I18N[share_port]="🔌 Порт: %s"
|
||||
I18N[share_connect_cta]="👉 Подключиться одним нажатием:"
|
||||
@@ -141,7 +141,7 @@ I18N[website_restart_nginx]="Перезапустить nginx"
|
||||
I18N[website_change_template]="Сменить шаблон"
|
||||
|
||||
# ── Remove ──────────────────────────────────────────────────────────────
|
||||
I18N[remove_title]="🗑 Удаление goTelegram Pro"
|
||||
I18N[remove_title]="🗑 Удаление PCAtelegram_web"
|
||||
I18N[remove_proxy_only]="Удалить только прокси (telemt)"
|
||||
I18N[remove_bot_only]="Удалить только Telegram-бота"
|
||||
I18N[remove_all]="Удалить всё (прокси + бот + настройки)"
|
||||
@@ -151,7 +151,7 @@ I18N[remove_backup_before]="Сделать бекап перед удалени
|
||||
I18N[remove_warn_all]="Это удалит ВСЁ: прокси, бот, сайт, настройки."
|
||||
I18N[remove_confirm_all]="Вы точно уверены?"
|
||||
I18N[remove_proxy_done]="Прокси удалён"
|
||||
I18N[remove_all_done]="goTelegram Pro полностью удалён (прокси + бот)"
|
||||
I18N[remove_all_done]="PCAtelegram_web полностью удалён (прокси + бот)"
|
||||
|
||||
# ── Telegram bot submenu ────────────────────────────────────────────────
|
||||
I18N[bot_title]="🤖 Telegram-бот"
|
||||
@@ -332,7 +332,7 @@ I18N[backup_lang_label]="Язык"
|
||||
I18N[backup_date_label]="Дата"
|
||||
I18N[backup_confirm_restore]="Восстановить конфигурацию? Текущие настройки будут перезаписаны."
|
||||
I18N[backup_restored_telemt]="telemt конфиг восстановлен"
|
||||
I18N[backup_restored_gotelegram]="goTelegram Pro конфиг восстановлен"
|
||||
I18N[backup_restored_pcatelegram_web]="PCAtelegram_web конфиг восстановлен"
|
||||
I18N[backup_restored_lang]="Язык интерфейса восстановлен"
|
||||
I18N[backup_restored_nginx]="nginx конфиг восстановлен"
|
||||
I18N[backup_restored_ssl]="SSL сертификаты восстановлены"
|
||||
@@ -362,7 +362,7 @@ I18N[auto_refresh]="Обновление через 30 сек"
|
||||
I18N[deps_installing]="Установка зависимостей: %s"
|
||||
|
||||
# ── Migration ───────────────────────────────────────────────────────────
|
||||
I18N[v1_detected]="⚠️ Обнаружена установка goTelegram Pro v1 (mtg)"
|
||||
I18N[v1_detected]="⚠️ Обнаружена установка PCAtelegram_web v1 (mtg)"
|
||||
I18N[v1_container]="Контейнер: %s"
|
||||
I18N[v1_migration_step]="Миграция с v1 (mtg) на v2 (telemt)"
|
||||
I18N[v1_found_title]="Найдена установка v1 (mtg):"
|
||||
|
||||
60
lib/stats.sh
Normal file → Executable file
60
lib/stats.sh
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# stats.sh — Traffic statistics module for GoTelegram v2.5.0
|
||||
# stats.sh — Traffic statistics module for PCAtelegram_web v2.5.0
|
||||
# Tracks proxy (telemt port 443) and site (nginx port 8443) traffic
|
||||
# Uses iptables counters + real-time snapshots + historical CSV
|
||||
|
||||
@@ -10,12 +10,12 @@ YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
STATS_DIR="/run/gotelegram"
|
||||
HISTORY_FILE="/opt/gotelegram/stats_history.csv"
|
||||
USER_HISTORY_FILE="/opt/gotelegram/user_stats_history.csv"
|
||||
STATS_DIR="/run/pcatelegram_web"
|
||||
HISTORY_FILE="/opt/pcatelegram_web/stats_history.csv"
|
||||
USER_HISTORY_FILE="/opt/pcatelegram_web/user_stats_history.csv"
|
||||
SNAPSHOTS_DIR="$STATS_DIR/snapshots"
|
||||
CURRENT_SNAPSHOT="$STATS_DIR/stats_current.json"
|
||||
CONFIG_FILE="/opt/gotelegram/config.json"
|
||||
CONFIG_FILE="/opt/pcatelegram_web/config.json"
|
||||
TELEMT_CONFIG_FILE="/etc/telemt/config.toml"
|
||||
STATS_RETENTION_DAYS="${STATS_RETENTION_DAYS:-365}"
|
||||
STATS_MINUTE_RETENTION_DAYS="${STATS_MINUTE_RETENTION_DAYS:-31}"
|
||||
@@ -35,23 +35,23 @@ stats_init() {
|
||||
chmod 755 "$STATS_DIR" "$SNAPSHOTS_DIR" 2>/dev/null
|
||||
|
||||
# Create iptables chain if not exists
|
||||
if ! iptables -L GOTELEGRAM_STATS -n >/dev/null 2>&1; then
|
||||
iptables -N GOTELEGRAM_STATS 2>/dev/null
|
||||
if ! iptables -L PCATELEGRAM_WEB_STATS -n >/dev/null 2>&1; then
|
||||
iptables -N PCATELEGRAM_WEB_STATS 2>/dev/null
|
||||
fi
|
||||
|
||||
# Add chain to INPUT if not already present
|
||||
if ! iptables -C INPUT -j GOTELEGRAM_STATS 2>/dev/null; then
|
||||
iptables -I INPUT -j GOTELEGRAM_STATS 2>/dev/null
|
||||
if ! iptables -C INPUT -j PCATELEGRAM_WEB_STATS 2>/dev/null; then
|
||||
iptables -I INPUT -j PCATELEGRAM_WEB_STATS 2>/dev/null
|
||||
fi
|
||||
|
||||
# Add rule for proxy traffic (port 443, TCP)
|
||||
if ! iptables -C GOTELEGRAM_STATS -p tcp --dport 443 2>/dev/null; then
|
||||
iptables -A GOTELEGRAM_STATS -p tcp --dport 443 2>/dev/null
|
||||
if ! iptables -C PCATELEGRAM_WEB_STATS -p tcp --dport 443 2>/dev/null; then
|
||||
iptables -A PCATELEGRAM_WEB_STATS -p tcp --dport 443 2>/dev/null
|
||||
fi
|
||||
|
||||
# Add rule for site traffic (loopback, port 8443, TCP)
|
||||
if ! iptables -C GOTELEGRAM_STATS -i lo -p tcp --dport 8443 2>/dev/null; then
|
||||
iptables -A GOTELEGRAM_STATS -i lo -p tcp --dport 8443 2>/dev/null
|
||||
if ! iptables -C PCATELEGRAM_WEB_STATS -i lo -p tcp --dport 8443 2>/dev/null; then
|
||||
iptables -A PCATELEGRAM_WEB_STATS -i lo -p tcp --dport 8443 2>/dev/null
|
||||
fi
|
||||
|
||||
# Initialize CSV header if file doesn't exist
|
||||
@@ -81,7 +81,7 @@ stats_collect() {
|
||||
|
||||
# Parse iptables output: format is "pkts bytes target"
|
||||
# We need to extract bytes (2nd column) for each rule
|
||||
local iptables_output=$(iptables -L GOTELEGRAM_STATS -v -n -x 2>/dev/null)
|
||||
local iptables_output=$(iptables -L PCATELEGRAM_WEB_STATS -v -n -x 2>/dev/null)
|
||||
|
||||
# Extract counters for port 443 (proxy)
|
||||
proxy_bytes=$(echo "$iptables_output" | grep "dpt:443" | grep -v "lo" | awk '{print $2}')
|
||||
@@ -140,7 +140,7 @@ EOF
|
||||
}
|
||||
|
||||
# Print active telemt usernames from [access.users]. Usernames are restricted by
|
||||
# goTelegram to A-Z/a-z/0-9/_.- so they are safe in URLs and CSV fields.
|
||||
# PCAtelegram_web to A-Z/a-z/0-9/_.- so they are safe in URLs and CSV fields.
|
||||
stats_active_users() {
|
||||
[[ -f "$TELEMT_CONFIG_FILE" ]] || return 0
|
||||
awk '
|
||||
@@ -478,9 +478,9 @@ toggle_stats() {
|
||||
fi
|
||||
|
||||
# Remove iptables rules
|
||||
iptables -D INPUT -j GOTELEGRAM_STATS 2>/dev/null
|
||||
iptables -F GOTELEGRAM_STATS 2>/dev/null
|
||||
iptables -X GOTELEGRAM_STATS 2>/dev/null
|
||||
iptables -D INPUT -j PCATELEGRAM_WEB_STATS 2>/dev/null
|
||||
iptables -F PCATELEGRAM_WEB_STATS 2>/dev/null
|
||||
iptables -X PCATELEGRAM_WEB_STATS 2>/dev/null
|
||||
|
||||
# Clean up directories
|
||||
rm -rf "$STATS_DIR" 2>/dev/null
|
||||
@@ -504,7 +504,7 @@ toggle_stats() {
|
||||
|
||||
# Install systemd service for stats collection
|
||||
install_stats_collector() {
|
||||
local service_file="/etc/systemd/system/gotelegram-stats.service"
|
||||
local service_file="/etc/systemd/system/pcatelegram_web-stats.service"
|
||||
|
||||
# Check if running as root
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
@@ -527,14 +527,14 @@ install_stats_collector() {
|
||||
# Create systemd service file
|
||||
cat > "$service_file" <<'EOF'
|
||||
[Unit]
|
||||
Description=goTelegram Pro Traffic Stats Collector
|
||||
Description=PCAtelegram_web Traffic Stats Collector
|
||||
After=network.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
ExecStart=/bin/bash -c 'source /opt/gotelegram/lib/common.sh; source /opt/gotelegram/lib/stats.sh; stats_init; while true; do stats_collect; sleep 1; done'
|
||||
ExecStart=/bin/bash -c 'source /opt/pcatelegram_web/lib/common.sh; source /opt/pcatelegram_web/lib/stats.sh; stats_init; while true; do stats_collect; sleep 1; done'
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
StandardOutput=journal
|
||||
@@ -546,8 +546,8 @@ EOF
|
||||
|
||||
chmod 644 "$service_file"
|
||||
systemctl daemon-reload
|
||||
systemctl enable gotelegram-stats.service
|
||||
systemctl restart gotelegram-stats.service
|
||||
systemctl enable pcatelegram_web-stats.service
|
||||
systemctl restart pcatelegram_web-stats.service
|
||||
|
||||
if [[ -f "$CONFIG_FILE" ]] && command -v jq &>/dev/null; then
|
||||
local tmp
|
||||
@@ -560,7 +560,7 @@ EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Сервис gotelegram-stats установлен и запущен" >&2
|
||||
echo "Сервис pcatelegram_web-stats установлен и запущен" >&2
|
||||
}
|
||||
|
||||
# Remove stats collector service
|
||||
@@ -570,15 +570,15 @@ remove_stats_collector() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
systemctl stop gotelegram-stats.service 2>/dev/null
|
||||
systemctl disable gotelegram-stats.service 2>/dev/null
|
||||
rm -f /etc/systemd/system/gotelegram-stats.service
|
||||
systemctl stop pcatelegram_web-stats.service 2>/dev/null
|
||||
systemctl disable pcatelegram_web-stats.service 2>/dev/null
|
||||
rm -f /etc/systemd/system/pcatelegram_web-stats.service
|
||||
systemctl daemon-reload
|
||||
|
||||
# Remove iptables rules
|
||||
iptables -D INPUT -j GOTELEGRAM_STATS 2>/dev/null
|
||||
iptables -F GOTELEGRAM_STATS 2>/dev/null
|
||||
iptables -X GOTELEGRAM_STATS 2>/dev/null
|
||||
iptables -D INPUT -j PCATELEGRAM_WEB_STATS 2>/dev/null
|
||||
iptables -F PCATELEGRAM_WEB_STATS 2>/dev/null
|
||||
iptables -X PCATELEGRAM_WEB_STATS 2>/dev/null
|
||||
|
||||
# Clean up directories and files
|
||||
rm -rf "$STATS_DIR" 2>/dev/null
|
||||
|
||||
4
lib/telemt.sh
Normal file → Executable file
4
lib/telemt.sh
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# GoTelegram v2.5.0 — Управление telemt binary
|
||||
# PCAtelegram_web v2.5.0 — Управление telemt binary
|
||||
# Скачивание, обновление, запуск, остановка через systemd
|
||||
|
||||
TELEMT_GITHUB="telemt/telemt"
|
||||
@@ -159,7 +159,7 @@ install_telemt_service() {
|
||||
|
||||
cat > "/etc/systemd/system/${TELEMT_SERVICE}.service" << EOF
|
||||
[Unit]
|
||||
Description=goTelegram Pro MTProxy (telemt engine)
|
||||
Description=PCAtelegram_web MTProxy (telemt engine)
|
||||
Documentation=https://github.com/telemt/telemt
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
4
lib/telemt_config.sh
Normal file → Executable file
4
lib/telemt_config.sh
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# GoTelegram v2.5.0 — Генерация TOML конфигурации для telemt
|
||||
# PCAtelegram_web v2.5.0 — Генерация TOML конфигурации для telemt
|
||||
|
||||
# ── Популярные домены (не заблокированные в РФ) ──────────────────────────────
|
||||
QUICK_DOMAINS=(
|
||||
@@ -44,7 +44,7 @@ generate_telemt_toml() {
|
||||
fi
|
||||
|
||||
cat > "$output" << EOTOML
|
||||
# GoTelegram v${GOTELEGRAM_VERSION} — telemt v3 configuration
|
||||
# PCAtelegram_web v${PCATELEGRAM_WEB_VERSION} — telemt v3 configuration
|
||||
# Сгенерировано: $(date -Iseconds)
|
||||
# Режим: ${mask_mode}
|
||||
|
||||
|
||||
4
lib/templates_catalog.sh
Normal file → Executable file
4
lib/templates_catalog.sh
Normal file → Executable file
@@ -1,10 +1,10 @@
|
||||
#!/bin/bash
|
||||
# GoTelegram v2.5.0 — website templates catalog
|
||||
# PCAtelegram_web v2.5.0 — website templates catalog
|
||||
# Pick from ~1800 templates, preview links, git sparse-checkout downloads,
|
||||
# + custom git URL templates (user-supplied public repos)
|
||||
|
||||
CATALOG_FILE="$(dirname "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")")/templates_catalog.json"
|
||||
TEMPLATES_CACHE="/tmp/gotelegram_templates"
|
||||
TEMPLATES_CACHE="/tmp/pcatelegram_web_templates"
|
||||
|
||||
# Custom git template limits
|
||||
CUSTOM_GIT_MAX_SIZE_MB=100
|
||||
|
||||
14
lib/website.sh
Normal file → Executable file
14
lib/website.sh
Normal file → Executable file
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# GoTelegram v2.5.0 — Управление сайтом (nginx + certbot + шаблоны)
|
||||
# PCAtelegram_web v2.5.0 — Управление сайтом (nginx + certbot + шаблоны)
|
||||
|
||||
# ── Установка nginx ──────────────────────────────────────────────────────────
|
||||
install_nginx() {
|
||||
@@ -39,7 +39,7 @@ generate_nginx_config() {
|
||||
mkdir -p /etc/nginx/sites-available /etc/nginx/sites-enabled
|
||||
|
||||
cat > "$NGINX_SITE_CONF" << 'EONGINX'
|
||||
# GoTelegram v2.5.0 — nginx config
|
||||
# PCAtelegram_web v2.5.0 — nginx config
|
||||
# Pro: nginx на 127.0.0.1:8443 (внутренний), telemt на 0.0.0.0:443 (внешний)
|
||||
# Обычный браузер → :443 → telemt → 127.0.0.1:8443 → nginx (сайт)
|
||||
|
||||
@@ -88,7 +88,7 @@ server {
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
|
||||
# Корень сайта
|
||||
root /var/www/gotelegram-site;
|
||||
root /var/www/pcatelegram_web-site;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
@@ -127,7 +127,7 @@ generate_nginx_temp_config() {
|
||||
local domain="$1"
|
||||
|
||||
cat > "$NGINX_SITE_CONF" << EONGINX_TEMP
|
||||
# GoTelegram — временный конфиг (до получения SSL)
|
||||
# PCAtelegram_web — временный конфиг (до получения SSL)
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
@@ -138,7 +138,7 @@ server {
|
||||
allow all;
|
||||
}
|
||||
|
||||
root /var/www/gotelegram-site;
|
||||
root /var/www/pcatelegram_web-site;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
@@ -257,8 +257,8 @@ deploy_template_to_nginx() {
|
||||
mkdir -p "$WEBSITE_ROOT"
|
||||
cp -a "$template_dir/." "$WEBSITE_ROOT/"
|
||||
rm -f "$WEBSITE_ROOT/.custom_git_source" 2>/dev/null || true
|
||||
echo "$template_id" > "$WEBSITE_ROOT/.gotelegram_template_id" 2>/dev/null || true
|
||||
[ -n "$source_url" ] && echo "$source_url" > "$WEBSITE_ROOT/.gotelegram_template_source" 2>/dev/null || true
|
||||
echo "$template_id" > "$WEBSITE_ROOT/.pcatelegram_web_template_id" 2>/dev/null || true
|
||||
[ -n "$source_url" ] && echo "$source_url" > "$WEBSITE_ROOT/.pcatelegram_web_template_source" 2>/dev/null || true
|
||||
chown -R www-data:www-data "$WEBSITE_ROOT" 2>/dev/null || chown -R nginx:nginx "$WEBSITE_ROOT" 2>/dev/null
|
||||
chmod -R 755 "$WEBSITE_ROOT"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user