Tidy up the installer

Layout: the file now reads top to bottom as output helpers, constants,
functions and the scenario. Functions were scattered between executable code
(some defined inside steps), the previous role was computed twice, and the
firewall code sat in the middle of a step. The firewall is now a function and
a step of its own; installing the awg-ctrl command moved into the services
step, so there are still six steps.

Fixes:
- the shebang was on line 4, after the license comment, so it did nothing;
- a reinstall removed /opt/awg-control before the configuration questions, so
  answering "no" to "Continue?" left the server with no installation; it is
  now removed only after the confirmation;
- with kept data the panel port was asked again with a new random default,
  which broke bookmarks and the API address even though the secret path was
  kept; the panel port, login, password and JWT secret now default to the
  previous values;
- UI_PORT, UI_USER, UI_PASS and SERVER_NAME from the environment were
  overwritten by the prompts; they now skip them, as the README says;
- when the user database existed but was not kept, the server name was not
  asked and silently became "VPN";
- random ports are checked to be free and distinct from each other;
- the server IP from ifconfig.me is validated, with a fallback to the source
  address of the default route;
- prompts are all in Russian; a panel with VPN can pick a random node port
  with "+";
- comments no longer point to docs/node-protocol.md, which is not in the repo;
- shellcheck -S warning is clean.

An update now gives a secret path to an install that has none and prints the
new panel address (UI_PREFIX=off, or an empty UI_PREFIX= in cli.env, keeps it
without one). The summary shows whether the panel has a secret path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013bNGYiDst62wH3ZGTRPFLJ
This commit is contained in:
Claude
2026-10-28 12:27:08 +00:00
parent ff2d71600c
commit 1169a0adc7
2 changed files with 639 additions and 568 deletions
+10 -6
View File
@@ -115,7 +115,9 @@ sudo bash -c "$(curl -Ls https://raw.githubusercontent.com/maeneko/forgetting/ma
| `AWG_PIN` | `y` (по умолчанию) — закрепить версию пакетов AmneziaWG (`apt-mark hold`) | | `AWG_PIN` | `y` (по умолчанию) — закрепить версию пакетов AmneziaWG (`apt-mark hold`) |
| `AWG_PORT` | UDP-порт VPN вместо случайного | | `AWG_PORT` | UDP-порт VPN вместо случайного |
| `AWG_MTU` | MTU туннеля вместо случайного (1280–1500) | | `AWG_MTU` | MTU туннеля вместо случайного (1280–1500) |
| `UI_PORT`, `UI_USER`, `UI_PASS` | порт, логин и пароль панели — без вопросов |
| `UI_PREFIX` | свой секретный путь панели (8–64 символа `A–Z a–z 0–9 _ -`); `off` — без пути | | `UI_PREFIX` | свой секретный путь панели (8–64 символа `A–Z a–z 0–9 _ -`); `off` — без пути |
| `SERVER_NAME` | имя VPN-сервера — без вопроса |
| `SUB_PORT`, `SUB_TLS`, `NODE_PORT` | порт и HTTPS подписки, порт хаба нод — без вопросов | | `SUB_PORT`, `SUB_TLS`, `NODE_PORT` | порт и HTTPS подписки, порт хаба нод — без вопросов |
| `UNINSTALL` | `y` — удалить, см. ниже | | `UNINSTALL` | `y` — удалить, см. ниже |
| `AMNEZIA_PPA_SUITE` | серия PPA для Debian (`focal`/`jammy`/`noble`) | | `AMNEZIA_PPA_SUITE` | серия PPA для Debian (`focal`/`jammy`/`noble`) |
@@ -126,12 +128,14 @@ sudo bash -c "$(curl -Ls https://raw.githubusercontent.com/maeneko/forgetting/ma
Повторный запуск установщика на сервере с установкой предлагает: Повторный запуск установщика на сервере с установкой предлагает:
1. **Обновить** — новая версия, настройки, пользователи и роль сохраняются. `cli.env` не 1. **Обновить** — новая версия, настройки, пользователи и роль сохраняются. Установке без
меняется, поэтому секретного пути у установки, где его не было, не появится — включить: секретного пути панели он выдаётся, и установщик печатает новый адрес: закладки и адрес
`UI_PREFIX=<путь>` в `cli.env` и `awg-ctrl restart` (или переустановка с сохранением данных, внешнего API нужно обновить. Оставить без пути — `UI_PREFIX=off` перед запуском или пустое
она выдаст путь сама). `UI_PREFIX=` в `cli.env`.
2. **Переустановить** — с нуля; пользователей и ключ сервера можно сохранить. Тогда сохраняются 2. **Переустановить** — с нуля; пользователей и ключ сервера можно сохранить. Тогда по умолчанию
и порт, параметры обфускации, MTU и секретный путь — они зашиты в выданные ключи и ссылки. остаются и порты (VPN, панели, подписки, хаба), параметры обфускации, MTU, секретный путь,
логин и пароль панели — они зашиты в выданные ключи, ссылки и закладки. Прежняя установка
убирается только после ответа «да» на «Продолжить?».
3. **Удалить** — полностью (без меню: `UNINSTALL=y`, подтверждение «удалить» тогда не 3. **Удалить** — полностью (без меню: `UNINSTALL=y`, подтверждение «удалить» тогда не
спрашивается). спрашивается).
+629 -562
View File
File diff suppressed because it is too large Load Diff