Skip to content

Commit aaff2dc

Browse files
committed
fix: replace infinite container loop with 3 attempts, add detailed error info
1 parent 3a2d3b3 commit aaff2dc

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

install_remnawave.sh

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
SCRIPT_VERSION="2.2.2c"
3+
SCRIPT_VERSION="2.2.3"
44
UPDATE_AVAILABLE=false
55
DIR_REMNAWAVE="/usr/local/remnawave_reverse/"
66
LANG_FILE="${DIR_REMNAWAVE}selected_language"
@@ -193,7 +193,8 @@ set_language() {
193193
#API
194194
[REGISTERING_REMNAWAVE]="Registration in Remnawave"
195195
[CHECK_CONTAINERS]="Checking containers availability..."
196-
[CONTAINERS_NOT_READY]="Containers are not ready, waiting..."
196+
[CONTAINERS_NOT_READY_ATTEMPT]="Containers are not ready, waiting... Attempt %d of %d."
197+
[CONTAINERS_TIMEOUT]="Containers not ready after %d attempts.\n\nCheck logs:\n cd /opt/remnawave && docker compose logs -f\n\nAlso check typical Docker issues:\n https://wiki.egam.es/troubleshooting/docker-issues/"
197198
[REGISTRATION_SUCCESS]="Registration completed successfully!"
198199
[GET_PUBLIC_KEY]="Getting public key..."
199200
[PUBLIC_KEY_SUCCESS]="Public key successfully obtained"
@@ -585,7 +586,8 @@ set_language() {
585586
#API
586587
[REGISTERING_REMNAWAVE]="Процесс регистрации в Remnawave"
587588
[CHECK_CONTAINERS]="Проверка доступности контейнеров..."
588-
[CONTAINERS_NOT_READY]="Контейнеры не готовы, ожидание..."
589+
[CONTAINERS_NOT_READY_ATTEMPT]="Контейнеры не готовы, ожидание... Попытка %d из %d."
590+
[CONTAINERS_TIMEOUT]="Контейнеры не готовы после %d попыток.\n\nПроверьте логи:\n cd /opt/remnawave && docker compose logs -f\n\nТакже посмотрите типичные ошибки Docker:\n https://wiki.egam.es/ru/troubleshooting/docker-issues/"
589591
[REGISTRATION_SUCCESS]="Регистрация прошла успешно!"
590592
[GET_PUBLIC_KEY]="Получаем публичный ключ..."
591593
[PUBLIC_KEY_SUCCESS]="Публичный ключ успешно получен"
@@ -2846,11 +2848,6 @@ install_packages() {
28462848
fi
28472849
fi
28482850

2849-
if ! ping -c 1 download.docker.com >/dev/null 2>&1; then
2850-
echo -e "${COLOR_RED}${LANG[ERROR_DOCKER_DNS]}${COLOR_RESET}" >&2
2851-
return 1
2852-
fi
2853-
28542851
if grep -q "Ubuntu" /etc/os-release; then
28552852
install -m 0755 -d /etc/apt/keyrings
28562853
if ! curl -fsSL https://download.docker.com/linux/ubuntu/gpg | tee /etc/apt/keyrings/docker.asc > /dev/null; then
@@ -4586,12 +4583,18 @@ EOL
45864583
sleep 20
45874584

45884585
echo -e "${COLOR_YELLOW}${LANG[CHECK_CONTAINERS]}${COLOR_RESET}"
4589-
until curl -s "http://$domain_url/api/auth/register" \
4586+
local attempts=0
4587+
local max_attempts=3
4588+
until curl -s -f --max-time 30 "http://$domain_url/api/auth/status" \
45904589
--header 'X-Forwarded-For: 127.0.0.1' \
45914590
--header 'X-Forwarded-Proto: https' \
45924591
> /dev/null; do
4593-
echo -e "${COLOR_RED}${LANG[CONTAINERS_NOT_READY]}${COLOR_RESET}"
4594-
sleep 10
4592+
attempts=$((attempts + 1))
4593+
if [ "$attempts" -ge "$max_attempts" ]; then
4594+
error "$(printf "${LANG[CONTAINERS_TIMEOUT]}" $max_attempts)"
4595+
fi
4596+
echo -e "${COLOR_RED}$(printf "${LANG[CONTAINERS_NOT_READY_ATTEMPT]}" $attempts $max_attempts)${COLOR_RESET}"
4597+
sleep 60
45954598
done
45964599

45974600
# Register Remnawave
@@ -5094,12 +5097,18 @@ EOL
50945097

50955098
local domain_url="127.0.0.1:3000"
50965099
echo -e "${COLOR_YELLOW}${LANG[CHECK_CONTAINERS]}${COLOR_RESET}"
5097-
until curl -s "http://$domain_url/api/auth/register" \
5100+
local attempts=0
5101+
local max_attempts=3
5102+
until curl -s -f --max-time 30 "http://$domain_url/api/auth/status" \
50985103
--header 'X-Forwarded-For: 127.0.0.1' \
50995104
--header 'X-Forwarded-Proto: https' \
51005105
> /dev/null; do
5101-
echo -e "${COLOR_RED}${LANG[CONTAINERS_NOT_READY]}${COLOR_RESET}"
5102-
sleep 5
5106+
attempts=$((attempts + 1))
5107+
if [ "$attempts" -ge "$max_attempts" ]; then
5108+
error "$(printf "${LANG[CONTAINERS_TIMEOUT]}" $max_attempts)"
5109+
fi
5110+
echo -e "${COLOR_RED}$(printf "${LANG[CONTAINERS_NOT_READY_ATTEMPT]}" $attempts $max_attempts)${COLOR_RESET}"
5111+
sleep 60
51035112
done
51045113

51055114
# Register Remnawave
@@ -5555,4 +5564,4 @@ case $OPTION in
55555564
exit 1
55565565
;;
55575566
esac
5558-
exit 0
5567+
exit 0

0 commit comments

Comments
 (0)