This commit is contained in:
2026-10-17 09:45:00 +03:30
parent dd39844c02
commit 3f72861b64
8 changed files with 79 additions and 35 deletions

View File

@@ -20,8 +20,8 @@ UI_TAIL_SOURCE=""
UI_NEEDS_CLEAR=1
UI_LAST_GEOMETRY=""
trap 'UI_NEEDS_CLEAR=1' WINCH
STAGE_NAMES=("System check" "System packages" "Java runtime" "Backup" "CTI package" "PostgreSQL" "Asterisk setup" "File ownership" "HTTPS setup" "Asterisk and service health")
STAGE_STATES=("WAIT" "WAIT" "WAIT" "WAIT" "WAIT" "WAIT" "WAIT" "WAIT" "WAIT" "WAIT")
STAGE_NAMES=("System check" "System packages" "Java runtime" "Backup" "CTI package" "PostgreSQL" "Asterisk setup" "File ownership" "HTTPS setup" "Asterisk and service health" "Restart services")
STAGE_STATES=("WAIT" "WAIT" "WAIT" "WAIT" "WAIT" "WAIT" "WAIT" "WAIT" "WAIT" "WAIT" "WAIT")
CURRENT_STAGE=-1
INSTALL_APPROVED=0
PACKAGE_INSTALL_STARTED=0
@@ -1194,6 +1194,44 @@ if [[ "$(docker inspect --format '{{.State.Running}}' asterisk 2>/dev/null || tr
fail "Asterisk stopped responding after Java startup"
fi
stage_begin 10 "Restarting Asterisk, CTI Java service and Nginx in order"
log "Stage 11/11: restarting the Asterisk container"
quiet_command docker restart asterisk || fail "Could not restart the Asterisk container in stage 11"
ASTERISK_READY=0
for attempt in $(seq 1 60); do
if [[ "$(docker inspect --format '{{.State.Running}}' asterisk 2>/dev/null || true)" == true ]] \
&& docker exec asterisk asterisk -rx 'core show version' >/dev/null 2>&1; then
ASTERISK_READY=1
break
fi
UI_MESSAGE="Waiting for Asterisk before Java restart ($((attempt * 2))s / 120s)"
render_ui
sleep 2
done
((ASTERISK_READY)) || fail "Asterisk did not become ready before the Java restart"
log "Stage 11/11: restarting the CTI Java service"
JAVA_SERVICE_START_TIME="@$(date +%s)"
quiet_command systemctl restart raymnad-cti.service || fail "Could not restart the CTI Java service in stage 11"
BACKEND_READY=0
for attempt in $(seq 1 60); do
if systemctl is-active --quiet raymnad-cti.service \
&& curl --connect-timeout 2 --max-time 5 --fail --silent "$BACKEND_READINESS_URL" 2>/dev/null \
| grep -Eq '"status"[[:space:]]*:[[:space:]]*"UP"'; then
BACKEND_READY=1
break
fi
UI_MESSAGE="Waiting for CTI Java health before Nginx restart ($((attempt * 2))s / 120s)"
render_ui
sleep 2
done
((BACKEND_READY)) || fail "CTI Java service did not become healthy before the Nginx restart"
log "Stage 11/11: restarting Nginx"
quiet_command systemctl restart nginx.service || fail "Could not restart Nginx in stage 11"
quiet_command systemctl is-active --quiet nginx.service || fail "Nginx is not active after stage 11 restart"
stage_done 10
log "Online installation completed. Raymand CTI backend and web interface are running."
log "Asterisk is running in Docker."
log "Open https://<server-address>/ to use Raymand CTI. The default self-signed certificate will show a browser trust warning."