Commit 426655c30aa2a946ffa1a4ef8a4356250f425932

Authored by Adhidarma Hadiwinoto
1 parent be0208db48
Exists in master

Typo on blocktime

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