Skip to content
Chad Hollman edited this page Apr 30, 2019 · 74 revisions

Configuration documentation

Configuration files are located in the smsgateway/conf directory.

gammu.conf

Use any modem that is supported by the gammu library and has sms feature supported.
Find your modem there and see the suggested Configuration there.

default: Is prepared for 2 USB-modems with at connection and is tested with HUAWEI E122

To see if gammu works with your stick try to

  • print modems information gammu -c conf/gammu.conf -s 0 identify
  • check if a PIN is needed gammu -c conf/gammu.conf -s 0 getsecuritystatus
  • set the PIN gammu -c conf/gammu.conf -s 0 entersecuritycode PIN 1234
  • send a SMS echo "test" | gammu -c conf/gammu.conf -s 0 sendsms TEXT +43123456789

[gammu]

This section is for the first modem and is specified as -s 0 above or "gammusection":0 in the modemlist below

  • device
    Is the where the modem / phone is connected to.
    sample E122: device = /dev/ttyUSB0
  • name
    Specify a name for this modem
  • connection
    Is the connection type for this modem.
    sample E122: connection = at

[gammu1..n]

Specify other modems/phones connected.

smsgw.conf

The fast forward way to configure the smsgateway is to set the modemlist in section [pid]!

The file has to have section [db], [pis], [pid] and [wis] in it. Don't delete them.

[DEFAULT]

Each of these values can be overwritten in the specific sections below.

  • loglevel
    CRITICAL / ERROR / WARNING / INFO / DEBUG
    default: loglevel = WARNING
  • logdirectory
    Has to be an absolute path to the log directory ending in /.
    default: is the /logs directory which is located in the same directory as the smsgw.py
    sample: logdirectory = /var/log/smsgw/
  • logfile
    The global file where the logs have to be written. Logrotation time is midnight, file encoding is UTF-8, timestamp is UTC.
    default: 4 logfiles are created and is the name of the configuration section name (db/pid/pis/wis) ending with the file extension ".log" sample: logfile = smsgw.log
  • logfiledaysback
    How many days the logfile should be kept as history.
    default: logfiledaysback = 7 sample: logfiledaysback = 31
  • key
    This is the default key - change this in production!
    Communication key for data transfer encryption. Has to be the same key on every WiS/PiS/PiD.
    default: key = 7D8FAA235238F8C2

[db]

General database settings.

  • loglevel
    As in [DEFAULT], only for this section.
  • logdirectory
    As in [DEFAULT], only for this section.
  • logfile
    As in [DEFAULT], only for this section.
  • logfiledaysback As in [DEFAULT], only for this section.
  • key Set it in [DEFAULT], not in here!
  • dbname
    The name for the SMS sqlite database.
    default: dbname = n0r1sk_smsgateway
    sample: dbname = sms_db
  • dbttl
    Defines the time in seconds how long the SMS should be kept in database.
    default: is 90 days and dbttl = 7776000
    sample: dbttl = 34560000 (for 400 days)

[pis]

  • loglevel
    As in [DEFAULT], only for this section.
  • logdirectory
    As in [DEFAULT], only for this section.
  • logfile
    As in [DEFAULT], only for this section.
  • logfiledaysback As in [DEFAULT], only for this section.
  • key Set it in [DEFAULT], not in here!
  • pisid
    A distinct ID for the Pi Server.
    default: pisid = pis-dummy
    sample: pisid = pis_1
  • ipaddress
    The ipaddress for the Pi Server.
    default: ipaddress = 127.0.0.1
    sample: ipaddress = 10.0.0.20
  • port
    The port on which the Pi Server should be reachable for the web socket connection established by Pi Daemon. default: ipaddress = 7788
    sample: port = 7788
  • wisurllist
    An URL list for the Web Interface Server/s. default: wisurllist = [{"url": "http://127.0.0.1:7777"}]
    sample: wisurllist = [{"url": "http://10.0.0.24:7777"}, {"url": "http://10.0.0.25:7777"}]
  • retrywisurl
    Number of retries before switching to the next Web Interface Server in the wisurllist
    default: retrywisurl = 2
    sample: retrywisurl = 2
  • retrywait
    Seconds to wait between retries.
    default: retrywait = 5
    sample: retrywait = 5
  • maxwaitpid
    Seconds to wait for the delivery answer of the Pi Daemon. If the wait limit is exceeded an error is send to the Web Interface Server.
    default: maxwaitpid = 10
    sample: maxwaitpid = 120

[pid]

  • loglevel
    As in [DEFAULT], only for this section.
  • logdirectory
    As in [DEFAULT], only for this section.
  • logfile
    As in [DEFAULT], only for this section.
  • logfiledaysback
    As in [DEFAULT], only for this section.
  • key
    Set it in [DEFAULT], not in here! A distinct ID for the Pi Daemon.
    default: pidid = pid_dummy
    sample: pidid = pid_1
  • modemlist
    Is a list of JSON modem values. All values are mandatory. You have to set this before starting the code.
    ** modemid **
    Usually the mobile phone number for that SIM card but could also be a self defined name.
    ** regex **
    List the country codes which should be handled by this modem as an regular expression. Append "fallback" to the regular expression "regex" to provide one ore more fallback modem in case of no target number match.
    ** lbfactor **
    Use "lbfactor" to weight the distribution of SMS between modems. eg: 2 means the modem is used twice as often as with factor 1 (the regular expression and the lbcount are evaluated before)
    ** pin **
    Use null for no PIN.
    ** gammusection**
    Set the section to use for modem communication using python gammu.
    0 for [gammu], 1 for [gammu1], etc.
    ** ctryexitcode**
    This is replacing the + sign to each target number before sending.
    ** modemname**
    A free text for the description of the modem. Also seen in WIS web gui.
    default: modemlist = [{}] sample: modemlist = [{"modemid":"0043123456789", "regex":"(\\+43|\\+49|fallback)", "lbfactor":1, "pin":"1234", "gammusection":0, "ctryexitcode":"00", "modemname":"Room 1"}, {"modemid":"0043987654321", "regex":"(\\+43)", "lbfactor":2, "pin":null, "gammusection":1, "ctryexitcode":"00", "modemname":"Room 2"}]
    Here is again the sample for better json reading.
[
  {
    "modemid": "0043123456789",
    "regex": "(\\+43|\\+49|fallback)",
    "lbfactor": 1,
    "pin": "0815",
    "gammusection": 0,
    "ctryexitcode": "00",
    "modemname": "Room 1"
  },
  {
    "modemid": "0043987654321",
    "regex": "(\\+43)",
    "lbfactor": 2,
    "pin": null,
    "gammusection": 1,
    "ctryexitcode": "00",
    "modemname": "Room 2 use null for no pin"
  }
]
  • pisurllist
    Set the websocket uri to one ore more PIS.
    default: pisurllist = [{"url": "ws://127.0.0.1:7788"}]
    sample: pisurllist = [{"url": "ws://127.0.0.1:7788"}, {"url": "ws://127.0.0.1:7799"}]
  • retrypisurl
    Number of retries before switching to the next Pi Server in the pisurllist
    default: retrypisurl = 2
    sample: retrypisurl = 5
  • retrywait
    Seconds to wait between retries.
    default: retrywait = 5
    sample: retrywait = 15
  • wrapgammu
    Using Gammu CLI instead of Python Gammu.
    default: wrapgammu = Off
    sample: wrapgammu = On
  • gammucmd
    Absolute path gammu command - needed if when wrapgammu is on.
    sample: gammucmd = /opt/gammu/bin/gammu
  • gammudebug
    Enable Gammu Debugging
    default: gammudebug = Off
    sample: gammudebug = On
  • gammudebugfile
    Name of the Logfile for Gammu debugging. Is created in the logdirectory.
    default: gammudebugfile = gammu.log
    sample: gammudebugfile = /tmp/gammu.log
  • testmode
    This is for testing only. Special SMS content is used for special answers without the need of a modem.
    default: testmode = Off
    sample: testmode = On

[wis]

  • loglevel
    As in [DEFAULT], only for this section.
  • logfile
    As in [DEFAULT], only for this section.
  • password
    The default password is changeme - CHANGE IT!
    This password is used as password for the root user which is automatically created on system startup.
    Therefore the root user is always present on each system. Please choose the password and the salt wisely! This password including the salt is hashed with the Python hashlib.sha512() function. Afterwards the result will be BASE64 encoded via Python hexdigest function.
    The resulting hash can be used as password if you set the salt option value to that one used on creation.
    To generate a new password witch can be used here see the following example:
    default: 20778ba41791cdc8ac54b4f1dab8cf7602a81f256cbeb9e782263e8bb00e01794d47651351e5873f9ac82868ede75aa6719160e624f02bba4df1f94324025058
    sample: 20778ba41791cdc8ac54b4f1dab8cf7602a81f256cbeb9e782263e8bb00e01794d47651351e5873f9ac82868ede75aa6719160e624f02bba4df1f94324025058
Python 3.4.3 (default, Mar 25 2015, 17:13:50)
[GCC 4.9.2 20150304 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> password = 'test'
>>> salt = 'areallyfunnysalt'
>>> hashlib.sha512((password + salt).encode('utf-8')).hexdigest()
'20778ba41791cdc8ac54b4f1dab8cf7602a81f256cbeb9e782263e8bb00e01794d47651351e5873f9ac82868ede75aa6719160e624f02bba4df1f94324025058'
  • salt
    The default salt is changeme - CHANGE IT!
    The salt is used during the password hashing process and is also used to verify the password.
    default: changeme
    sample: changeme
  • wisid
    The wisid should be set to an unique value inside the smsgateway infrastructure. It will be displayed on the web gui as modems are connected through PIS servers.
    default: nowisid
    sample: wis1
  • ipaddress
    This defines the ipaddress which is used by the smsgateway for the WIS module.
    default: 127.0.0.1
    sample: 192.168.0.1
  • port
    This defines the port which is used by the smsgateway for the WIS module.
    default: 7777
    sample: 7777
  • peers
    The peer list defines the WIS peers in the smsgateway setup. If this is a single smsgateway installation you must not specify anything. If you are running the smsgateway in a multiple WIS environment you should at least specify one WIS peer. You must not specify all other WIS instances but you could if you like. The peer list is used on startup to contact at least another WIS to retrieve the the routing table with the actual existing modem routes. The format of this value is a JSON array of dictionary entries.
    default: [{}]
    sample: [{"url": "http://192.168.0.2:8888"}]
  • cleanupseconds
    The cleanupseconds configuration is used to delete SMS messages from the SMS SQlite table of this WIS instance. Every SMS older than this number of seconds will be deleted.
    default: 86400
    sample: 5184000
  • validusernamelength
    An positive integer value that is validated against the length of the given username upon login. If the provided username is longer than this setting, login is not permitted.
    validusernamelength = 30
  • validusernameregex
    This regular expression will be validated against the given username upon login. If the regular expression matches (it founds invalid signs) login is not permitted.
    validusernameregex = ([^a-zA-Z0-9])
  • ldapenabled Enable LDAP login. If not specified LDAP login is disabled.
    default: false
    sample: true
  • ldapserver
    This configuration item sets the LDAP server which is used for user login search. This could be an FQDN or ip address. Please make sure that the LDAP server is reachable.
    sample: ldap.mydomain.com
  • ldapbasedn
    The basedn is used to allocate the users in the LDAP directory. sample: ou=USERS
  • ldapusers
    Specify a JSON list of users who are authorized to login through LDAP.
    default: []
    sample: ["User01", "User02", "User03"]
  • sslenabled Enable SSL (https) encryption for the web gui and web services.
    default: false
    sample: true
  • sslcertificate
    Specify the path and name to the certificate file. Please be aware that we are distribution a certificate including the private key. This is a security problem and the certificate should only be used for testing purposed.
    default: no default value
    sample: ssl/cert.pem
  • sslprivatekey
    Specify the path and name to the key file. Please be aware that we are distribution a certificate including the private key. This is a security problem and the key should only be used for testing purposed.
    default: no default value
    sample: ssl/privkey.pem
  • sslcertificatechain Specify the path and name to the certificate chain file.
    default: no default value
    sample: ssl/chain.pem

Clone this wiki locally