@bitcall/webrtc-sip-gateway 0.3.7 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +28 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitcall/webrtc-sip-gateway",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
4
4
  "description": "Linux CLI for bootstrapping and managing the Bitcall WebRTC-to-SIP Gateway",
5
5
  "repository": {
6
6
  "type": "git",
package/src/index.js CHANGED
@@ -1011,6 +1011,30 @@ function writeComposeTemplate(config = {}) {
1011
1011
  writeFileWithMode(COMPOSE_PATH, `${compose}\n`, 0o644);
1012
1012
  }
1013
1013
 
1014
+ function stripLegacyKamailioVolume(composeContent) {
1015
+ const lines = composeContent.split(/\r?\n/);
1016
+ const filtered = lines.filter((line) => !line.includes("/etc/kamailio"));
1017
+ if (filtered.length === lines.length) {
1018
+ return { changed: false, content: composeContent };
1019
+ }
1020
+ const content = `${filtered.join("\n").replace(/\n*$/, "")}\n`;
1021
+ return { changed: true, content };
1022
+ }
1023
+
1024
+ function migrateLegacyComposeIfNeeded() {
1025
+ if (!fs.existsSync(COMPOSE_PATH)) {
1026
+ return false;
1027
+ }
1028
+ const original = fs.readFileSync(COMPOSE_PATH, "utf8");
1029
+ const migrated = stripLegacyKamailioVolume(original);
1030
+ if (!migrated.changed) {
1031
+ return false;
1032
+ }
1033
+ writeFileWithMode(COMPOSE_PATH, migrated.content, 0o644);
1034
+ console.log("Detected legacy /etc/kamailio compose volume override. Removed automatically.");
1035
+ return true;
1036
+ }
1037
+
1014
1038
  function provisionCustomCert(config) {
1015
1039
  validateCustomCert(config.customCertPath, config.customKeyPath, config.domain);
1016
1040
 
@@ -1373,6 +1397,7 @@ function runSystemctl(args, fallbackComposeArgs) {
1373
1397
 
1374
1398
  function upCommand() {
1375
1399
  ensureInitialized();
1400
+ migrateLegacyComposeIfNeeded();
1376
1401
  runSystemctl(["start", SERVICE_NAME], ["up", "-d", "--remove-orphans"]);
1377
1402
  }
1378
1403
 
@@ -1383,6 +1408,7 @@ function downCommand() {
1383
1408
 
1384
1409
  function restartCommand() {
1385
1410
  ensureInitialized();
1411
+ migrateLegacyComposeIfNeeded();
1386
1412
  runSystemctl(["reload", SERVICE_NAME], ["restart"]);
1387
1413
  }
1388
1414
 
@@ -1617,6 +1643,7 @@ async function certInstallCommand(options) {
1617
1643
 
1618
1644
  function updateCommand() {
1619
1645
  ensureInitialized();
1646
+ migrateLegacyComposeIfNeeded();
1620
1647
  const envMap = loadEnvFile(ENV_PATH);
1621
1648
  const currentImage = envMap.BITCALL_GATEWAY_IMAGE || "";
1622
1649
  const targetImage = DEFAULT_GATEWAY_IMAGE;
@@ -1861,6 +1888,7 @@ module.exports = {
1861
1888
  buildSecurityNotes,
1862
1889
  buildQuickFlowDefaults,
1863
1890
  shouldRequireAllowlist,
1891
+ stripLegacyKamailioVolume,
1864
1892
  isOriginWildcard,
1865
1893
  isSingleProviderConfigured,
1866
1894
  printRequiredPorts,