Commit 27da76a09e12c18c4449c644a621bcb0184325d1

Authored by Adhidarma Hadiwinoto
1 parent 2c030bb757
Exists in master

Executing queues

Showing 2 changed files with 3 additions and 5 deletions Inline Diff

bin/smstools-config-install
1 #!/bin/bash 1 #!/bin/bash
2 set -x 2 set -x
3 3
4 DIRFILE=`dirname "$0"` 4 DIRFILE=`dirname "$0"`
5 cd "$DIRFILE/.." 5 cd "$DIRFILE/.."
6 echo `pwd` 6 echo `pwd`
7 7
8 TARGETFILE=$1 8 TARGETFILE=$1
9 if [ -z "$TARGETFILE" ]; then 9 if [ -z "$TARGETFILE" ]; then
10 exit 0 10 exit 0
11 fi 11 fi
12 12
13 sudo install smsd.conf.tmp "$TARGETFILE" 13 sudo install smsd.conf.tmp "$TARGETFILE"
14 # sudo systemctl restart sms3 14 sudo systemctl restart sms3
15 15
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 if (queues && queues.length) { 28 queuesLine = `queues = ${(queues || []).join(', ') || 'other'}`;
29 queuesLine = `queues = ${queues.join(', ')}`;
30 }
31 } 29 }
32 30
33 const modemEntry = ` 31 const modemEntry = `
34 [${modemName}] 32 [${modemName}]
35 device = ${modem.device} 33 device = ${modem.device}
36 outgoing = ${modem.outgoing ? 'yes' : 'no'} 34 outgoing = ${modem.outgoing ? 'yes' : 'no'}
37 ${queuesLine} 35 ${queuesLine}
38 `.trim(); 36 `.trim();
39 37
40 retval.push(modemEntry); 38 retval.push(modemEntry);
41 }); 39 });
42 40
43 return retval; 41 return retval;
44 } 42 }
45 43
46 module.exports = async () => { 44 module.exports = async () => {
47 const queuesAndProvidersStr = queuesAndProviders.hasQueues() ? (await queuesAndProviders.dump()) : ''; 45 const queuesAndProvidersStr = queuesAndProviders.hasQueues() ? (await queuesAndProviders.dump(true)) : '';
48 46
49 const newContent = ` 47 const newContent = `
50 # 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')}
51 # Do not edit this file manually 49 # Do not edit this file manually
52 50
53 devices = ${orderBy(modemNames()).join(',')} 51 devices = ${orderBy(modemNames()).join(',')}
54 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'}
55 loglevel = ${smstoolsConfig.loglevel || 5} 53 loglevel = ${smstoolsConfig.loglevel || 5}
56 errorsleeptime = ${config.smstools_errorsleeptime || 10} 54 errorsleeptime = ${config.smstools_errorsleeptime || 10}
57 blockafter = ${config.smstools_blockafter || 3} 55 blockafter = ${config.smstools_blockafter || 3}
58 blocktime = ${config.smstools_blocktime || 3600} 56 blocktime = ${config.smstools_blocktime || 3600}
59 smart_logging = yes 57 smart_logging = yes
60 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}
61 user = ${smstoolsConfig.user || 'smstools'} 59 user = ${smstoolsConfig.user || 'smstools'}
62 group = ${smstoolsConfig.group || 'smstools'} 60 group = ${smstoolsConfig.group || 'smstools'}
63 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'}
64 stats_interval = ${config.smstools_stats_interval || 60} 62 stats_interval = ${config.smstools_stats_interval || 60}
65 stats = ${config.smstools_stats || '/var/log/smsd/smsd_stats'} 63 stats = ${config.smstools_stats || '/var/log/smsd/smsd_stats'}
66 sent = /var/spool/sms/sent 64 sent = /var/spool/sms/sent
67 failed = /var/spool/sms/failed 65 failed = /var/spool/sms/failed
68 ${smstoolsConfig.customConfig || ''} 66 ${smstoolsConfig.customConfig || ''}
69 67
70 ${queuesAndProvidersStr} 68 ${queuesAndProvidersStr}
71 69
72 [default] 70 [default]
73 sentsleeptime = ${config.smstools_sentsleeptime || 0} 71 sentsleeptime = ${config.smstools_sentsleeptime || 0}
74 send_delay = ${config.smstools_send_delay || 0} 72 send_delay = ${config.smstools_send_delay || 0}
75 incoming = yes 73 incoming = yes
76 regular_run_interval = 60 74 regular_run_interval = 60
77 regular_run_cmd = AT+CGSN 75 regular_run_cmd = AT+CGSN
78 regular_run_cmd = AT+CIMI 76 regular_run_cmd = AT+CIMI
79 regular_run_cmd = AT+COPS? 77 regular_run_cmd = AT+COPS?
80 regular_run_statfile = /var/spool/sms/regular_run/modemname 78 regular_run_statfile = /var/spool/sms/regular_run/modemname
81 message_limit = ${config.smstools_message_limit || 5} 79 message_limit = ${config.smstools_message_limit || 5}
82 message_count_clear = ${config.smstools_message_count_clear || 1} 80 message_count_clear = ${config.smstools_message_count_clear || 1}
83 81
84 ${modemEntries().join('\n\n')} 82 ${modemEntries().join('\n\n')}
85 83
86 # end of configuration file 84 # end of configuration file
87 `; 85 `;
88 return `${newContent.trim()}\n`; 86 return `${newContent.trim()}\n`;
89 }; 87 };
90 88