Commit 3b4e58a99299504f969cbf897b8af9963397c61c
1 parent
aed5cf4c37
Exists in
master
config.smstools_sentsleeptime
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 | 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 | smart_logging = yes | 44 | smart_logging = yes |
45 | autosplit = ${(config.smstools_autosplit !== undefined && config.smstools_autosplit !== null) ? config.smstools_autosplit : 1} | 45 | autosplit = ${(config.smstools_autosplit !== undefined && config.smstools_autosplit !== null) ? config.smstools_autosplit : 1} |
46 | user = ${smstoolsConfig.user || 'smstools'} | 46 | user = ${smstoolsConfig.user || 'smstools'} |
47 | group = ${smstoolsConfig.group || 'smstools'} | 47 | group = ${smstoolsConfig.group || 'smstools'} |
48 | eventhandler = ${config.smstools_eventhandler || '/var/lib/smstools/centers/smstools/bin/smstools-eventhandler.js'} | 48 | eventhandler = ${config.smstools_eventhandler || '/var/lib/smstools/centers/smstools/bin/smstools-eventhandler.js'} |
49 | stats_interval = ${config.smstools_stats_interval || 60} | 49 | stats_interval = ${config.smstools_stats_interval || 60} |
50 | stats = ${config.smstools_stats || '/var/log/smsd/smsd_stats'} | 50 | stats = ${config.smstools_stats || '/var/log/smsd/smsd_stats'} |
51 | sent = /var/spool/sms/sent | 51 | sent = /var/spool/sms/sent |
52 | failed = /var/spool/sms/failed | 52 | failed = /var/spool/sms/failed |
53 | ${smstoolsConfig.customConfig || ''} | 53 | ${smstoolsConfig.customConfig || ''} |
54 | 54 | ||
55 | [default] | 55 | [default] |
56 | sentsleeptime = ${config.smstools_sentsleeptime || 5} | ||
56 | incoming = yes | 57 | incoming = yes |
57 | regular_run_interval = 60 | 58 | regular_run_interval = 60 |
58 | regular_run_cmd = AT+CGSN | 59 | regular_run_cmd = AT+CGSN |
59 | regular_run_cmd = AT+CIMI | 60 | regular_run_cmd = AT+CIMI |
60 | regular_run_cmd = AT+COPS? | 61 | regular_run_cmd = AT+COPS? |
61 | regular_run_statfile = /var/spool/sms/regular_run/modemname | 62 | regular_run_statfile = /var/spool/sms/regular_run/modemname |
62 | 63 | ||
63 | ${modemEntries().join('\n\n')} | 64 | ${modemEntries().join('\n\n')} |
64 | 65 | ||
65 | # end of configuration file | 66 | # end of configuration file |
66 | `; | 67 | `; |
67 | return `${newContent.trim()}\n`; | 68 | return `${newContent.trim()}\n`; |
68 | }; | 69 | }; |
69 | 70 |