fix: keep installer from preparing data directories
This commit is contained in:
@@ -15,9 +15,7 @@ docker compose logs -f backend worker frontend
|
|||||||
|
|
||||||
## Интерактивный install wizard
|
## Интерактивный install wizard
|
||||||
|
|
||||||
Для нового сервера можно не клонировать весь репозиторий и не ставить Python.
|
Для нового сервера скачайте install-скрипт и запустите его:
|
||||||
Скачайте только POSIX `sh`-скрипт через `raw.githubusercontent.com` и
|
|
||||||
запустите его:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -fsSL https://raw.githubusercontent.com/3252a8/remnawave-minishop/main/scripts/install.sh -o install.sh
|
curl -fsSL https://raw.githubusercontent.com/3252a8/remnawave-minishop/main/scripts/install.sh -o install.sh
|
||||||
@@ -31,7 +29,7 @@ Wizard работает через меню с цифрами и подтвер
|
|||||||
- сохранить backup существующих файлов перед перезаписью;
|
- сохранить backup существующих файлов перед перезаписью;
|
||||||
- запустить `docker compose pull && docker compose up -d`;
|
- запустить `docker compose pull && docker compose up -d`;
|
||||||
- проверить текущий стек через `docker compose ps` и логи `migrate`;
|
- проверить текущий стек через `docker compose ps` и логи `migrate`;
|
||||||
- запустить миграцию из поддерживаемых legacy-ботов: Remnashop и старый
|
- запустить миграцию из поддерживаемых ботов: Remnashop и старый
|
||||||
`remnawave-tg-shop`;
|
`remnawave-tg-shop`;
|
||||||
|
|
||||||
Для тестирования другой ветки или форка задайте источник перед запуском:
|
Для тестирования другой ветки или форка задайте источник перед запуском:
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ sh install.sh
|
|||||||
```
|
```
|
||||||
|
|
||||||
В меню выберите `Install new stack and run legacy migration` или
|
В меню выберите `Install new stack and run legacy migration` или
|
||||||
`Run legacy migration only`, затем источник `Legacy remnawave-tg-shop`.
|
`Run legacy migration only`, затем источник `Old remnawave-tg-shop`.
|
||||||
Wizard поддерживает два режима:
|
Wizard поддерживает два режима:
|
||||||
|
|
||||||
- `Copy old Docker volumes` - тот же безопасный сценарий, что и старый
|
- `Copy old Docker volumes` - тот же безопасный сценарий, что и старый
|
||||||
|
|||||||
+13
-32
@@ -1,16 +1,13 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
# Dependency-light installer for fresh Linux hosts.
|
# Interactive installer for fresh Docker Compose hosts.
|
||||||
# It intentionally avoids Python and clones only the files selected by the user.
|
|
||||||
|
|
||||||
DEFAULT_REPO="${MINISHOP_INSTALL_REPO:-3252a8/remnawave-minishop}"
|
DEFAULT_REPO="${MINISHOP_INSTALL_REPO:-3252a8/remnawave-minishop}"
|
||||||
DEFAULT_REF="${MINISHOP_INSTALL_REF:-main}"
|
DEFAULT_REF="${MINISHOP_INSTALL_REF:-main}"
|
||||||
DEFAULT_IMAGE_TAG="${MINISHOP_IMAGE_TAG:-latest}"
|
DEFAULT_IMAGE_TAG="${MINISHOP_IMAGE_TAG:-latest}"
|
||||||
INSTALL_STATE_DIR=".installer"
|
INSTALL_STATE_DIR=".installer"
|
||||||
IMPORTER_CACHE_PATH="$INSTALL_STATE_DIR/import_legacy.py"
|
IMPORTER_CACHE_PATH="$INSTALL_STATE_DIR/import_legacy.py"
|
||||||
APP_UID=10001
|
|
||||||
APP_GID=10001
|
|
||||||
OLD_TGSHOP_DB_VOLUME="remnawave-tg-shop-db-data"
|
OLD_TGSHOP_DB_VOLUME="remnawave-tg-shop-db-data"
|
||||||
NEW_MINISHOP_DB_VOLUME="remnawave-minishop-db-data"
|
NEW_MINISHOP_DB_VOLUME="remnawave-minishop-db-data"
|
||||||
OLD_TGSHOP_CADDY_DATA_VOLUME="remnawave-tg-shop-caddy-data"
|
OLD_TGSHOP_CADDY_DATA_VOLUME="remnawave-tg-shop-caddy-data"
|
||||||
@@ -85,7 +82,7 @@ banner() {
|
|||||||
printf '\n'
|
printf '\n'
|
||||||
color "Remnawave MiniShop Install Wizard" "$BOLD$CYAN"
|
color "Remnawave MiniShop Install Wizard" "$BOLD$CYAN"
|
||||||
printf '\n'
|
printf '\n'
|
||||||
color "Install, configure, start, and migrate legacy bot data." "$DIM"
|
color "Install, configure, start, and migrate existing bot data." "$DIM"
|
||||||
printf '\n\n'
|
printf '\n\n'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,8 +129,8 @@ Environment overrides:
|
|||||||
LEGACY_TGSHOP_SOURCE_DSN default remnawave-tg-shop source DSN for dump/restore
|
LEGACY_TGSHOP_SOURCE_DSN default remnawave-tg-shop source DSN for dump/restore
|
||||||
|
|
||||||
The wizard is interactive by design. It never overwrites files without
|
The wizard is interactive by design. It never overwrites files without
|
||||||
confirmation. Remnashop imports always run dry-run first; legacy
|
confirmation. Remnashop imports always run dry-run first; remnawave-tg-shop
|
||||||
remnawave-tg-shop can be migrated from Docker volumes or a PostgreSQL DSN.
|
can be migrated from Docker volumes or a PostgreSQL DSN.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -638,21 +635,6 @@ write_env_file() {
|
|||||||
ok "Wrote $ENV_PATH"
|
ok "Wrote $ENV_PATH"
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_data_directory() {
|
|
||||||
section "Prepare data directory"
|
|
||||||
data_dir="$TARGET_DIR/data"
|
|
||||||
mkdir -p "$data_dir/themes" "$data_dir/webapp-logo" "$data_dir/webapp-emoji" "$data_dir/backups"
|
|
||||||
if [ ! -f "$data_dir/locales-overrides.json" ]; then
|
|
||||||
printf '{}\n' > "$data_dir/locales-overrides.json"
|
|
||||||
fi
|
|
||||||
if command -v chown >/dev/null 2>&1; then
|
|
||||||
if ! chown -R "$APP_UID:$APP_GID" "$data_dir" 2>/dev/null; then
|
|
||||||
warn "Could not chown data files. Run: sudo chown -R $APP_UID:$APP_GID data"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
ok "Prepared $data_dir"
|
|
||||||
}
|
|
||||||
|
|
||||||
require_docker() {
|
require_docker() {
|
||||||
if command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1; then
|
if command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1; then
|
||||||
COMPOSE_STYLE="docker"
|
COMPOSE_STYLE="docker"
|
||||||
@@ -742,7 +724,7 @@ copy_volume_if_safe() {
|
|||||||
if [ "$required" = "1" ]; then
|
if [ "$required" = "1" ]; then
|
||||||
warn "Target volume $target_volume is already not empty."
|
warn "Target volume $target_volume is already not empty."
|
||||||
warn "It may already be migrated, or the target stack may have been started with an empty database."
|
warn "It may already be migrated, or the target stack may have been started with an empty database."
|
||||||
if confirm "Continue without copying the legacy database volume?" 0; then
|
if confirm "Continue without copying the old database volume?" 0; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
@@ -762,7 +744,7 @@ copy_volume_if_safe() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop_known_legacy_containers() {
|
stop_known_legacy_containers() {
|
||||||
section "Stop legacy containers"
|
section "Stop old containers"
|
||||||
stopped=0
|
stopped=0
|
||||||
for container in $KNOWN_LEGACY_CONTAINERS; do
|
for container in $KNOWN_LEGACY_CONTAINERS; do
|
||||||
if docker inspect "$container" >/dev/null 2>&1; then
|
if docker inspect "$container" >/dev/null 2>&1; then
|
||||||
@@ -775,7 +757,7 @@ stop_known_legacy_containers() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ "$stopped" = "0" ]; then
|
if [ "$stopped" = "0" ]; then
|
||||||
info "No known legacy containers found."
|
info "No known old containers found."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -847,7 +829,7 @@ run_import_command() {
|
|||||||
choose_legacy_source() {
|
choose_legacy_source() {
|
||||||
choose "Source bot" "1" "1|2|3" \
|
choose "Source bot" "1" "1|2|3" \
|
||||||
"1. Remnashop - import users, subscriptions, payments, referrals and promo codes." \
|
"1. Remnashop - import users, subscriptions, payments, referrals and promo codes." \
|
||||||
"2. Legacy remnawave-tg-shop - upgrade an old compatible database/volume." \
|
"2. Old remnawave-tg-shop - upgrade an old compatible database/volume." \
|
||||||
"3. Skip migration"
|
"3. Skip migration"
|
||||||
case "$CHOICE_VALUE" in
|
case "$CHOICE_VALUE" in
|
||||||
1) LEGACY_SOURCE="remnashop" ;;
|
1) LEGACY_SOURCE="remnashop" ;;
|
||||||
@@ -941,7 +923,7 @@ prepare_compose_without_starting_apps() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
run_tgshop_volume_migration() {
|
run_tgshop_volume_migration() {
|
||||||
section "Legacy remnawave-tg-shop volume migration"
|
section "Old remnawave-tg-shop volume migration"
|
||||||
warn "This path copies the old PostgreSQL Docker volume into the new Minishop volume."
|
warn "This path copies the old PostgreSQL Docker volume into the new Minishop volume."
|
||||||
warn "Old volumes are not deleted; keep them until you verify the new stack."
|
warn "Old volumes are not deleted; keep them until you verify the new stack."
|
||||||
|
|
||||||
@@ -964,7 +946,7 @@ run_tgshop_volume_migration() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
run_tgshop_dsn_migration() {
|
run_tgshop_dsn_migration() {
|
||||||
section "Legacy remnawave-tg-shop DSN migration"
|
section "Old remnawave-tg-shop DSN migration"
|
||||||
warn "The old standalone helper did not support direct DSN import."
|
warn "The old standalone helper did not support direct DSN import."
|
||||||
warn "This wizard path dumps the old PostgreSQL database, restores it into target Compose PostgreSQL, then runs Minishop schema migrations."
|
warn "This wizard path dumps the old PostgreSQL database, restores it into target Compose PostgreSQL, then runs Minishop schema migrations."
|
||||||
warn "The target database will be dropped and recreated before restore."
|
warn "The target database will be dropped and recreated before restore."
|
||||||
@@ -992,7 +974,7 @@ run_tgshop_dsn_migration() {
|
|||||||
(cd "$TARGET_DIR" && run_compose exec -T postgres sh -c \
|
(cd "$TARGET_DIR" && run_compose exec -T postgres sh -c \
|
||||||
'dropdb -U "$POSTGRES_USER" --if-exists "$POSTGRES_DB" && createdb -U "$POSTGRES_USER" "$POSTGRES_DB"') || return 1
|
'dropdb -U "$POSTGRES_USER" --if-exists "$POSTGRES_DB" && createdb -U "$POSTGRES_USER" "$POSTGRES_DB"') || return 1
|
||||||
|
|
||||||
section "Dump and restore legacy database"
|
section "Dump and restore old database"
|
||||||
(cd "$TARGET_DIR" && run_compose run --rm --no-deps \
|
(cd "$TARGET_DIR" && run_compose run --rm --no-deps \
|
||||||
-e "SOURCE_DSN=$SOURCE_DSN" \
|
-e "SOURCE_DSN=$SOURCE_DSN" \
|
||||||
-e "TARGET_DSN=$TARGET_DSN" \
|
-e "TARGET_DSN=$TARGET_DSN" \
|
||||||
@@ -1006,7 +988,7 @@ run_tgshop_dsn_migration() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
run_remnawave_tg_shop_migration() {
|
run_remnawave_tg_shop_migration() {
|
||||||
section "Legacy remnawave-tg-shop migration"
|
section "Old remnawave-tg-shop migration"
|
||||||
ENV_PATH="$TARGET_DIR/.env"
|
ENV_PATH="$TARGET_DIR/.env"
|
||||||
if [ ! -f "$ENV_PATH" ]; then
|
if [ ! -f "$ENV_PATH" ]; then
|
||||||
fail ".env not found. Install or generate configuration first."
|
fail ".env not found. Install or generate configuration first."
|
||||||
@@ -1067,10 +1049,9 @@ install_flow() {
|
|||||||
download_profile_files || return 1
|
download_profile_files || return 1
|
||||||
write_env_file || return 1
|
write_env_file || return 1
|
||||||
mkdir -p "$TARGET_DIR/$INSTALL_STATE_DIR"
|
mkdir -p "$TARGET_DIR/$INSTALL_STATE_DIR"
|
||||||
prepare_data_directory || return 1
|
|
||||||
if [ "$with_migration" = "1" ]; then
|
if [ "$with_migration" = "1" ]; then
|
||||||
choose_legacy_source
|
choose_legacy_source
|
||||||
elif confirm "Run a legacy bot migration now?" 0; then
|
elif confirm "Run a migration from another bot now?" 0; then
|
||||||
choose_legacy_source
|
choose_legacy_source
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ def test_shell_installer_downloads_raw_files_and_runs_import_in_container():
|
|||||||
def test_shell_installer_supports_legacy_tgshop_volume_and_dsn_paths():
|
def test_shell_installer_supports_legacy_tgshop_volume_and_dsn_paths():
|
||||||
script = INSTALL_SCRIPT.read_text(encoding="utf-8")
|
script = INSTALL_SCRIPT.read_text(encoding="utf-8")
|
||||||
|
|
||||||
assert "Legacy remnawave-tg-shop" in script
|
assert "Old remnawave-tg-shop" in script
|
||||||
assert "remnawave-tg-shop-db-data" in script
|
assert "remnawave-tg-shop-db-data" in script
|
||||||
assert "remnawave-minishop-db-data" in script
|
assert "remnawave-minishop-db-data" in script
|
||||||
assert "pg_dump --clean --if-exists" in script
|
assert "pg_dump --clean --if-exists" in script
|
||||||
|
|||||||
Reference in New Issue
Block a user