Commit d54a2eebcd9c59125bd798700a44c9b2f213bc60

Authored by Adhidarma Hadiwinoto
1 parent ff2a27b36e
Exists in master

Typo: smartlogging should be smart_logging

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