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

5
.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
@@ -33,4 +30,4 @@ cti_app/npm-debug.log*
cti_app/yarn-debug.log*
cti_app/yarn-error.log*
installer/online-installer
installer/online-installer

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,31 +406,30 @@ public class Initializer {
sipUserGroupsRepository.save(userGroup);
}
for (int i = 1001; i <= 1050; i++) {
if (sipUsersRepository.findByUid(String.valueOf(i)).isPresent()) {
continue;
if (sipUsersRepository.count() == 0) {
for (int i = 1001; i <= 1050; i++) {
var user = new TblSipUser();
user.setAcl("");
user.setUid(String.valueOf(i));
user.setPassword(GlobalTools.getRandomString(12));
if (i > 1024)
user.setSipProfile(profileWebrtc);
else
user.setSipProfile(profileU);
user.setSipUserGroup(userGroup);
user.setCallerIdName(i + "");
user.setCallerIdNumber(String.valueOf(i));
user.setOutboundCallerIdName("[uid]");
user.setOutboundCallerIdNumber(appName + "-[uid]");
var conflicts = dialableNumberConflictService.validateSipUser(user.getUid(), null);
if (conflicts.isEmpty()) {
sipUsersRepository.save(user);
} else {
plineTools.plineLogger("Default SIP User UID conflicts with another dialable number ("
+ user.getUid() + "): " + String.join(", ", conflicts));
}
}
var user = new TblSipUser();
user.setAcl("");
user.setUid(String.valueOf(i));
user.setPassword(GlobalTools.getRandomString(12));
if (i > 1024)
user.setSipProfile(profileWebrtc);
else
user.setSipProfile(profileU);
user.setSipUserGroup(userGroup);
user.setCallerIdName(i + "");
user.setCallerIdNumber(String.valueOf(i));
user.setOutboundCallerIdName("[uid]");
user.setOutboundCallerIdNumber(appName + "-[uid]");
var conflicts = dialableNumberConflictService.validateSipUser(user.getUid(), null);
if (conflicts.isEmpty()) {
sipUsersRepository.save(user);
} else {
plineTools.plineLogger("Default SIP User UID conflicts with another dialable number ("
+ 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

@@ -223,7 +223,7 @@ public class SipFileGenerator {
}
private void createSipTrunks() {
int[] trunkLicense = new int[] { licenseService.getLimit("sip_trunk") };
int[] trunkLicense = new int[] { licenseService.getLimit("sip_trunk") };
var listTrunks = sipTrunkRepository.findAllEnableProfiles(true);
String path = plineTools.getConfigPath() + "sip-trunks/";
@@ -233,7 +233,7 @@ public class SipFileGenerator {
int[] cntTrunk = new int[] { 0 };
listTrunks.forEach(x -> {
if (trunkLicense[0] >= 0 && cntTrunk[0]++ >= trunkLicense[0]) {
if (trunkLicense[0] >= 0 && cntTrunk[0]++ >= trunkLicense[0]) {
return;
}
@@ -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() {
@@ -408,7 +414,7 @@ public class SipFileGenerator {
private void createSipUsers() {
int[] sipUserLicense = new int[] { licenseService.getLimit("sip_users") };
int[] sipUserLicense = new int[] { licenseService.getLimit("sip_users") };
var listExtensions = sipUsersRepository.findAllEnableProfiles(true);
String path = plineTools.getConfigPath() + "sip-users/";
@@ -418,7 +424,7 @@ public class SipFileGenerator {
int[] cntSipUser = new int[] { 0 };
listExtensions.forEach(x -> {
if (sipUserLicense[0] >= 0 && cntSipUser[0]++ >= sipUserLicense[0]) {
if (sipUserLicense[0] >= 0 && cntSipUser[0]++ >= sipUserLicense[0]) {
return;
}
List<InfoConfiguration> ics = new ArrayList<>();
@@ -483,4 +489,4 @@ public class SipFileGenerator {
});
}
}
}