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

3
.gitignore vendored
View File

@@ -8,9 +8,6 @@ p-line/license.lic
p-line/node_modules
p-line//fax
offline/images/
cti_app/node_modules
cti_app/.pnp
cti_app/.pnp.js

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."

View File

@@ -54,6 +54,9 @@ class OnlineInstallerTests(unittest.TestCase):
installer = (ROOT / path).read_text()
self.assertIn("allowmultiplelogin = yes", installer)
self.assertIn("pline.local-asterisk-api-token", installer)
stage_names = installer.split("STAGE_NAMES=(", 1)[1].split(")", 1)[0]
stage_states = installer.split("STAGE_STATES=(", 1)[1].split(")", 1)[0]
self.assertEqual(stage_names.count('"') // 2, stage_states.count('"') // 2)
def test_installer_respects_server_configured_apt_repositories(self):
commands = section("apt_cmd() {", "apt_policy() {")

Binary file not shown.

View File

@@ -0,0 +1 @@
9c8cba1cd09d6e281bed06506906a0644bb7212c191f2e28169bf920baa6280b asterisk-22-amd64.tar.gz

View File

@@ -406,10 +406,8 @@ public class Initializer {
sipUserGroupsRepository.save(userGroup);
}
if (sipUsersRepository.count() == 0) {
for (int i = 1001; i <= 1050; i++) {
if (sipUsersRepository.findByUid(String.valueOf(i)).isPresent()) {
continue;
}
var user = new TblSipUser();
user.setAcl("");
user.setUid(String.valueOf(i));
@@ -431,6 +429,7 @@ public class Initializer {
+ user.getUid() + "): " + String.join(", ", conflicts));
}
}
}
// This block can run again when any default SIP entity is missing.
// Keep default media initialization idempotent and preserve customer files.

View File

@@ -392,6 +392,12 @@ public class SipFileGenerator {
}
plineTools.writeInfoFile("sip-trunks", "sip-trunk-" + x.getId(), ics);
});
if (listTrunks.isEmpty()) {
InfoConfiguration info = new InfoConfiguration();
info.setBanner(true);
plineTools.writeInfoFile("sip-trunks", "sip-trunk-0", info);
}
}
private void createSip() {