Commit 4ba19e4f93c4a2ea19200addc836c09e502d94fe

Authored by Adhidarma Hadiwinoto
1 parent 69850c9142
Exists in master

config.smstools_send_retry

Showing 1 changed file with 1 additions and 0 deletions Inline Diff

lib/smstools-config/creator.js
1 const moment = require('moment'); 1 const moment = require('moment');
2 const config = require('komodo-sdk/config'); 2 const config = require('komodo-sdk/config');
3 const { orderBy } = require('natural-orderby'); 3 const { orderBy } = require('natural-orderby');
4 const smstoolsConfig = require('./config-file'); 4 const smstoolsConfig = require('./config-file');
5 const queuesAndProviders = require('./queues-and-providers'); 5 const queuesAndProviders = require('./queues-and-providers');
6 6
7 function modemNames() { 7 function modemNames() {
8 const modems = []; 8 const modems = [];
9 9
10 // eslint-disable-next-line no-restricted-syntax 10 // eslint-disable-next-line no-restricted-syntax
11 for (const [key, value] of Object.entries(smstoolsConfig.modems || {})) { 11 for (const [key, value] of Object.entries(smstoolsConfig.modems || {})) {
12 if (value && !value.disabled) modems.push(key); 12 if (value && !value.disabled) modems.push(key);
13 } 13 }
14 14
15 return modems; 15 return modems;
16 } 16 }
17 17
18 function modemEntries() { 18 function modemEntries() {
19 const modems = orderBy(modemNames()); 19 const modems = orderBy(modemNames());
20 const retval = []; 20 const retval = [];
21 21
22 modems.forEach((modemName) => { 22 modems.forEach((modemName) => {
23 const modem = smstoolsConfig.modems[modemName]; 23 const modem = smstoolsConfig.modems[modemName];
24 24
25 let queuesLine = ''; 25 let queuesLine = '';
26 if (queuesAndProviders.hasQueues()) { 26 if (queuesAndProviders.hasQueues()) {
27 const queues = queuesAndProviders.getModemQueueName(modemName); 27 const queues = queuesAndProviders.getModemQueueName(modemName);
28 queuesLine = `queues = ${(queues || []).join(', ') || 'other'}`; 28 queuesLine = `queues = ${(queues || []).join(', ') || 'other'}`;
29 } 29 }
30 30
31 const modemEntry = ` 31 const modemEntry = `
32 [${modemName}] 32 [${modemName}]
33 device = ${modem.device} 33 device = ${modem.device}
34 outgoing = ${modem.outgoing ? 'yes' : 'no'} 34 outgoing = ${modem.outgoing ? 'yes' : 'no'}
35 ${queuesLine} 35 ${queuesLine}
36 `.trim(); 36 `.trim();
37 37
38 retval.push(modemEntry); 38 retval.push(modemEntry);
39 }); 39 });
40 40
41 return retval; 41 return retval;
42 } 42 }
43 43
44 module.exports = async () => { 44 module.exports = async () => {
45 const queuesAndProvidersStr = queuesAndProviders.hasQueues() ? (await queuesAndProviders.dump(true)) : ''; 45 const queuesAndProvidersStr = queuesAndProviders.hasQueues() ? (await queuesAndProviders.dump(true)) : '';
46 46
47 const newContent = ` 47 const newContent = `
48 # Generated by komodo-center-smstools based on config timestamp ${moment(smstoolsConfig.ts).format('YYYY-MM-DD HH:mm:ss')} 48 # Generated by komodo-center-smstools based on config timestamp ${moment(smstoolsConfig.ts).format('YYYY-MM-DD HH:mm:ss')}
49 # Do not edit this file manually 49 # Do not edit this file manually
50 50
51 devices = ${orderBy(modemNames()).join(',')} 51 devices = ${orderBy(modemNames()).join(',')}
52 logfile = ${config.smstools_logfile || config.smstools_log_file || '/var/log/smsd/smsd.log'} 52 logfile = ${config.smstools_logfile || config.smstools_log_file || '/var/log/smsd/smsd.log'}
53 loglevel = ${smstoolsConfig.loglevel || 5} 53 loglevel = ${smstoolsConfig.loglevel || 5}
54 errorsleeptime = ${config.smstools_errorsleeptime || 10} 54 errorsleeptime = ${config.smstools_errorsleeptime || 10}
55 blockafter = ${config.smstools_blockafter || 3} 55 blockafter = ${config.smstools_blockafter || 3}
56 blocktime = ${config.smstools_blocktime || 3600} 56 blocktime = ${config.smstools_blocktime || 3600}
57 smart_logging = yes 57 smart_logging = yes
58 autosplit = ${(config.smstools_autosplit !== undefined && config.smstools_autosplit !== null) ? config.smstools_autosplit : 1} 58 autosplit = ${(config.smstools_autosplit !== undefined && config.smstools_autosplit !== null) ? config.smstools_autosplit : 1}
59 user = ${smstoolsConfig.user || 'smstools'} 59 user = ${smstoolsConfig.user || 'smstools'}
60 group = ${smstoolsConfig.group || 'smstools'} 60 group = ${smstoolsConfig.group || 'smstools'}
61 eventhandler = ${config.smstools_eventhandler || '/var/lib/smstools/centers/smstools/bin/smstools-eventhandler.js'} 61 eventhandler = ${config.smstools_eventhandler || '/var/lib/smstools/centers/smstools/bin/smstools-eventhandler.js'}
62 stats_interval = ${config.smstools_stats_interval || 60} 62 stats_interval = ${config.smstools_stats_interval || 60}
63 stats = ${config.smstools_stats || '/var/log/smsd/smsd_stats'} 63 stats = ${config.smstools_stats || '/var/log/smsd/smsd_stats'}
64 sent = /var/spool/sms/sent 64 sent = /var/spool/sms/sent
65 failed = /var/spool/sms/failed 65 failed = /var/spool/sms/failed
66 ${smstoolsConfig.customConfig || ''} 66 ${smstoolsConfig.customConfig || ''}
67 67
68 ${queuesAndProvidersStr} 68 ${queuesAndProvidersStr}
69 69
70 [default] 70 [default]
71 sentsleeptime = ${config.smstools_sentsleeptime || 0} 71 sentsleeptime = ${config.smstools_sentsleeptime || 0}
72 send_delay = ${config.smstools_send_delay || 0} 72 send_delay = ${config.smstools_send_delay || 0}
73 send_retries = ${config.smstools_send_retry || 2}
73 incoming = yes 74 incoming = yes
74 regular_run_interval = 60 75 regular_run_interval = 60
75 regular_run_cmd = AT+CGSN 76 regular_run_cmd = AT+CGSN
76 regular_run_cmd = AT+CIMI 77 regular_run_cmd = AT+CIMI
77 regular_run_cmd = AT+COPS? 78 regular_run_cmd = AT+COPS?
78 regular_run_statfile = /var/spool/sms/regular_run/modemname 79 regular_run_statfile = /var/spool/sms/regular_run/modemname
79 message_limit = ${config.smstools_message_limit || 5} 80 message_limit = ${config.smstools_message_limit || 5}
80 message_count_clear = ${config.smstools_message_count_clear || 1} 81 message_count_clear = ${config.smstools_message_count_clear || 1}
81 82
82 ${modemEntries().join('\n\n')} 83 ${modemEntries().join('\n\n')}
83 84
84 # end of configuration file 85 # end of configuration file
85 `; 86 `;
86 return `${newContent.trim()}\n`; 87 return `${newContent.trim()}\n`;
87 }; 88 };
88 89