Commit f24458bdb8bd29e8b25768325b8929643ba28b69

Authored by Adhidarma Hadiwinoto
1 parent b708801611
Exists in master

Queues and providers gona test

Showing 2 changed files with 16 additions and 2 deletions Side-by-side Diff

bin/smstools-config-install
... ... @@ -11,4 +11,4 @@ if [ -z "$TARGETFILE" ]; then
11 11 fi
12 12  
13 13 sudo install smsd.conf.tmp "$TARGETFILE"
14   -sudo systemctl restart sms3
  14 +# sudo systemctl restart sms3
lib/smstools-config/creator.js
... ... @@ -2,6 +2,7 @@ const moment = require('moment');
2 2 const config = require('komodo-sdk/config');
3 3 const { orderBy } = require('natural-orderby');
4 4 const smstoolsConfig = require('./config-file');
  5 +const queuesAndProviders = require('./queues-and-providers');
5 6  
6 7 function modemNames() {
7 8 const modems = [];
... ... @@ -21,10 +22,19 @@ function modemEntries() {
21 22 modems.forEach((modemName) => {
22 23 const modem = smstoolsConfig.modems[modemName];
23 24  
  25 + let queuesLine = '';
  26 + if (queuesAndProviders.hasQueues()) {
  27 + const queues = queuesAndProviders.getModemQueueName(modemName);
  28 + if (queues && queues.length) {
  29 + queuesLine = `queues = ${queues.join(', ')}`;
  30 + }
  31 + }
  32 +
24 33 const modemEntry = `
25 34 [${modemName}]
26 35 device = ${modem.device}
27 36 outgoing = ${modem.outgoing ? 'yes' : 'no'}
  37 +${queuesLine}
28 38 `.trim();
29 39  
30 40 retval.push(modemEntry);
... ... @@ -33,7 +43,9 @@ outgoing = ${modem.outgoing ? 'yes' : 'no'}
33 43 return retval;
34 44 }
35 45  
36   -module.exports = () => {
  46 +module.exports = async () => {
  47 + const queuesAndProvidersStr = queuesAndProviders.hasQueues() ? (await queuesAndProviders.dump()) : '';
  48 +
37 49 const newContent = `
38 50 # Generated by komodo-center-smstools based on config timestamp ${moment(smstoolsConfig.ts).format('YYYY-MM-DD HH:mm:ss')}
39 51 # Do not edit this file manually
... ... @@ -55,6 +67,8 @@ sent = /var/spool/sms/sent
55 67 failed = /var/spool/sms/failed
56 68 ${smstoolsConfig.customConfig || ''}
57 69  
  70 +${queuesAndProvidersStr}
  71 +
58 72 [default]
59 73 sentsleeptime = ${config.smstools_sentsleeptime || 0}
60 74 send_delay = ${config.smstools_send_delay || 0}