v2.5.0: add legacy state migration

This commit is contained in:
Виталий Литвинов
2026-04-24 18:58:52 +03:00
parent 7afeb59261
commit ed9073f28f
7 changed files with 288 additions and 4 deletions

View File

@@ -237,11 +237,15 @@ get_ssl_expiry() {
# ── Деплой шаблона сайта ─────────────────────────────────────────────────────
deploy_template_to_nginx() {
local template_dir="$1"
local template_id="${2:-}"
local source_url=""
if [ ! -d "$template_dir" ] || [ ! -f "$template_dir/index.html" ]; then
log_error "Шаблон не содержит index.html: $template_dir"
return 1
fi
[ -z "$template_id" ] && template_id=$(basename "$template_dir")
[ -f "$template_dir/.custom_git_source" ] && source_url=$(head -1 "$template_dir/.custom_git_source" 2>/dev/null || echo "")
# Бекапим старый сайт
if [ -d "$WEBSITE_ROOT" ] && [ "$(ls -A "$WEBSITE_ROOT" 2>/dev/null)" ]; then
@@ -251,7 +255,10 @@ deploy_template_to_nginx() {
fi
mkdir -p "$WEBSITE_ROOT"
cp -r "$template_dir"/* "$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
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"
@@ -334,7 +341,7 @@ remove_pro_mode() {
# ── Смена шаблона ────────────────────────────────────────────────────────────
switch_template() {
local new_template_dir="$1"
deploy_template_to_nginx "$new_template_dir"
deploy_template_to_nginx "$new_template_dir" "$(basename "$new_template_dir")"
# nginx не требует перезапуска — статика обновилась на месте
log_success "Шаблон сайта обновлён"
}