Skip to content

Commit

Permalink
Merge pull request #935 from jookies/0.10
Browse files Browse the repository at this point in the history
0.10.6
  • Loading branch information
farirat committed Jan 4, 2021
2 parents 465e7dc + cc30725 commit 350a915
Show file tree
Hide file tree
Showing 26 changed files with 270 additions and 58 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,8 @@ twistd.log
# Celery
celerybeat-schedule.db

# Packaging
*.deb
*.rpm

.env
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ python:
- '3.8'
# - '3.9'
env:
- ROOT_PATH=~/jasmin JASMIN_RELEASE=0.10.5
- ROOT_PATH=~/jasmin JASMIN_RELEASE=0.10.6
# Command to install dependencies
install:
- pip install -r requirements.txt
Expand Down
9 changes: 9 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ RUN pip install .

ENV UNICODEMAP_JP unicode-ascii

ENV ROOT_PATH /
ENV CONFIG_PATH /etc/jasmin
ENV RESOURCE_PATH /etc/jasmin/resource
ENV STORE_PATH /etc/jasmin/store
ENV LOG_PATH /var/log/jasmin

COPY misc/config/*.cfg ${CONFIG_PATH}/
COPY misc/config/resource ${RESOURCE_PATH}

WORKDIR /usr/jasmin

# Change binding host for jcli, redis, and amqp
Expand Down
8 changes: 4 additions & 4 deletions docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ RUN chown jasmin:jasmin ${CONFIG_PATH} ${RESOURCE_PATH} ${STORE_PATH} ${LOG_PATH

WORKDIR /build

RUN pip install -e git+https://github.com/jookies/txamqp.git@master#egg=txAMQP
RUN pip install -e git+https://github.com/jookies/python-messaging.git@master#egg=messaging
RUN pip install -e git+https://github.com/jookies/smpp.pdu.git@master#egg=smpp.pdu
RUN pip install -e git+https://github.com/jookies/smpp.twisted.git@master#egg=smpp.twisted
RUN pip install -e git+https://github.com/jookies/txamqp.git@master#egg=txamqp3
RUN pip install -e git+https://github.com/jookies/python-messaging.git@master#egg=python-messaging
RUN pip install -e git+https://github.com/jookies/smpp.pdu.git@master#egg=smpp.pdu3
RUN pip install -e git+https://github.com/jookies/smpp.twisted.git@master#egg=smpp.twisted3

COPY . .

Expand Down
6 changes: 3 additions & 3 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ COPY README.rst .

RUN pip install -r requirements.txt
RUN pip install -r requirements-test.txt
RUN pip install -e git+https://github.com/jookies/python-messaging.git@master#egg=messaging
RUN pip install -e git+https://github.com/jookies/smpp.pdu.git@master#egg=smpp.pdu
RUN pip install -e git+https://github.com/jookies/smpp.twisted.git@master#egg=smpp.twisted
RUN pip install -e git+https://github.com/jookies/python-messaging.git@master#egg=python-messaging
RUN pip install -e git+https://github.com/jookies/smpp.pdu.git@master#egg=smpp.pdu3
RUN pip install -e git+https://github.com/jookies/smpp.twisted.git@master#egg=smpp.twisted3
RUN pip install .

ENV UNICODEMAP_JP unicode-ascii
Expand Down
2 changes: 1 addition & 1 deletion jasmin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

MAJOR = 0
MINOR = 10
PATCH = 5
PATCH = 6
META = ''


Expand Down
2 changes: 1 addition & 1 deletion jasmin/bin/dlrd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3

import os
import signal
Expand Down
2 changes: 1 addition & 1 deletion jasmin/bin/dlrlookupd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3

import os
import signal
Expand Down
2 changes: 1 addition & 1 deletion jasmin/bin/interceptord.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3

import os
import signal
Expand Down
2 changes: 1 addition & 1 deletion jasmin/bin/jasmind.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3

import os
import signal
Expand Down
2 changes: 1 addition & 1 deletion jasmin/protocols/cli/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def doStart(self):
pending_load = ['mtrouter', 'morouter', 'filter', 'group', 'smppcc', 'httpcc', 'user']
while True:
for _pl in pending_load:
if re.match(r'.*%s configuration loaded.*' % _pl, tr.value(), re.DOTALL):
if re.match(r'.*%s configuration loaded.*' % _pl, str(tr.value()), re.DOTALL):
self.log.info("%s configuration loaded.", _pl)
pending_load.remove(_pl)

Expand Down
6 changes: 3 additions & 3 deletions jasmin/protocols/cli/jcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def connectionMade(self):
self.terminal.write('Authentication required.\n\n')

# Provision managers
self.managers = {'user': UsersManager(self, self.factory.pb),
'group': GroupsManager(self, self.factory.pb),
self.managers = {'group': GroupsManager(self, self.factory.pb),
'user': UsersManager(self, self.factory.pb),
'mointerceptor': MoInterceptorManager(self, self.factory.pb),
'mtinterceptor': MtInterceptorManager(self, self.factory.pb),
'morouter': MoRouterManager(self, self.factory.pb),
Expand Down Expand Up @@ -379,7 +379,7 @@ def do_mtrouter(self, arg, opts=None):
make_option('-1', '--start', type="string", metavar="CID",
help="Start SMPP connector using it's CID"),
make_option('-0', '--stop', type="string", metavar="CID",
help="Start SMPP connector using it's CID")], '')
help="Stop SMPP connector using it's CID")], '')
def do_smppccm(self, arg, opts):
"""SMPP connector management"""

Expand Down
10 changes: 8 additions & 2 deletions jasmin/protocols/rest/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,13 @@ def on_post(self, request, response):

# Convert _ to -
# Added for compliance with json encoding/decoding constraints on dev env like .Net
for k, v in request_args.items():
_request_args = request_args.copy() # void dictionary key change error in python 3.8
for k, v in _request_args.items():
del (request_args[k])
request_args[re.sub('_', '-', k)] = v

del _request_args # Unset the variable

self.build_response_from_proxy_result(
response,
self.call_jasmin(
Expand Down Expand Up @@ -214,10 +217,13 @@ def on_post(self, request, response):

# Convert _ to -
# Added for compliance with json encoding/decoding constraints on dev env like .Net
for k, v in message_params.items():
_message_params = message_params.copy() # Avoid dictionary key changed error in python 3.8
for k, v in _message_params.items():
del (message_params[k])
message_params[re.sub('_', '-', k)] = v

del _message_params # Unset the variable

# Ignore message if these args are not found
if 'to' not in message_params or ('content' not in message_params and 'hex-content' not in message_params):
continue
Expand Down
2 changes: 1 addition & 1 deletion misc/config/systemd/jasmin-celery.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Before=jasmin-restapi.service

[Service]
SyslogIdentifier=jasmin-celery
PIDFile=/var/run/jasmin-celery.pid
PIDFile=/run/jasmin-celery.pid
User=jasmin
Group=jasmin
ExecStart=/bin/sh -c "celery -A jasmin.protocols.rest.tasks worker -l INFO -c 4 --autoscale=10,3"
Expand Down
4 changes: 2 additions & 2 deletions misc/config/systemd/jasmin-dlrd.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ After=network.target jasmind.service

[Service]
SyslogIdentifier=jasmin-dlrd
PIDFile=/var/run/jasmin-dlrd.pid
PIDFile=/run/jasmin-dlrd.pid
User=jasmin
Group=jasmin
ExecStart=/usr/bin/dlrd.py
ExecStart=/usr/local/bin/dlrd.py

[Install]
WantedBy=multi-user.target
4 changes: 2 additions & 2 deletions misc/config/systemd/jasmin-dlrlookupd.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ After=network.target jasmind.service

[Service]
SyslogIdentifier=jasmin-dlrlookupd
PIDFile=/var/run/jasmin-dlrlookupd.pid
PIDFile=/run/jasmin-dlrlookupd.pid
User=jasmin
Group=jasmin
ExecStart=/usr/bin/dlrlookupd.py
ExecStart=/usr/local/bin/dlrlookupd.py

[Install]
WantedBy=multi-user.target
4 changes: 2 additions & 2 deletions misc/config/systemd/jasmin-interceptord.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Before=jasmind.service

[Service]
SyslogIdentifier=interceptord
PIDFile=/var/run/interceptord.pid
PIDFile=/run/interceptord.pid
User=jasmin
Group=jasmin
ExecStart=/usr/bin/interceptord.py
ExecStart=/usr/local/bin/interceptord.py

[Install]
WantedBy=multi-user.target
4 changes: 2 additions & 2 deletions misc/config/systemd/jasmin-restapi.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ After=network.target jasmind.service

[Service]
SyslogIdentifier=jasmin-restapi
PIDFile=/var/run/jasmin-restapi.pid
PIDFile=/run/jasmin-restapi.pid
User=jasmin
Group=jasmin
ExecStart=/bin/sh -c "twistd -n --pidfile=/tmp/twistd-web-restapi.pid web --wsgi=jasmin.protocols.rest.api"
ExecStart=/bin/sh -c "twistd3 -n --pidfile=/tmp/twistd-web-restapi.pid web --wsgi=jasmin.protocols.rest.api"

[Install]
WantedBy=multi-user.target
4 changes: 2 additions & 2 deletions misc/config/systemd/jasmind.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ After=network.target

[Service]
SyslogIdentifier=jasmind
PIDFile=/var/run/jasmind.pid
PIDFile=/run/jasmind.pid
User=jasmin
Group=jasmin
ExecStart=/usr/bin/jasmind.py --username jcliadmin --password jclipwd
ExecStart=/usr/local/bin/jasmind.py --username jcliadmin --password jclipwd

[Install]
WantedBy=multi-user.target
2 changes: 1 addition & 1 deletion misc/doc/sources/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# The short X.Y version.
version = "0.10"
# The full version, including alpha/beta/rc tags.
release = "0.10.5"
release = "0.10.6"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
37 changes: 18 additions & 19 deletions misc/doc/sources/installation/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Jasmin installation is provided as rpm & deb Linux packages, docker image and py
Prerequisites & Dependencies
****************************

`Jasmin <http://jasminsms.com/>`_ requires Python 2.7 or newer (but not Python 3) with a functioning `pip module <https://pypi.python.org/pypi/pip>`_.
`Jasmin <http://jasminsms.com/>`_ requires Python 3 (Python 2 is no more supported) with a functioning `pip module <https://pypi.python.org/pypi/pip>`_.

.. hint:: Latest pip module installation: # **curl https://bootstrap.pypa.io/get-pip.py | python**

Expand All @@ -29,46 +29,45 @@ Depending on the Linux distribution you are using, you may need to install the f
Ubuntu
******

`Jasmin <http://jasminsms.com/>`_ can be installed through **DEB** packages hosted on `Packagecloud <https://packagecloud.io/jookies/python-jasmin>`_::
`Jasmin <http://jasminsms.com/>`_ can be installed through **DEB** packages hosted on `Packagecloud <https://packagecloud.io/jookies/jasmin-sms-gateway>`_::

wget -qO - http://bit.ly/jasmin-deb-repo | sudo bash
sudo apt-get install python-jasmin
curl -s https://setup.jasminsms.com/deb | sudo bash
sudo apt-get install jasmin-sms-gateway

.. note:: Ubuntu 15.04 and higher versions are supported.
.. note:: Ubuntu 20.04 and newer versions are supported.

You have to install and setup **RabbitMQ** or **Redis** servers on same machine (Default configuration) or on separate ones (Requires Jasmin configuration: /etc/jasmin/jasmin.cfg).

.. note:: redis and rabbitmq must be installed and already running.

Once Jasmin installed, you may simply start the **jasmind** service::

sudo systemctl enable jasmind
sudo systemctl start jasmind

.. note:: redis and rabbitmq must be started with jasmin.
.. note:: redis and rabbitmq must be installed and already running.

RHEL & CentOS
*************

`Jasmin <http://jasminsms.com/>`_ can be installed through **RPM** packages hosted on `Packagecloud <https://packagecloud.io/jookies/python-jasmin>`_::
`Jasmin <http://jasminsms.com/>`_ can be installed through **RPM** packages hosted on `Packagecloud <https://packagecloud.io/jookies/jasmin-sms-gateway>`_::

wget -qO - http://bit.ly/jasmin-rpm-repo | sudo bash
sudo yum install python-jasmin
curl -s https://setup.jasminsms.com/rpm | sudo bash
sudo yum install epel-release
sudo yum install jasmin-sms-gateway

.. note:: Red Hat Enterprise Linux 7 & CentOS 7 are supported.
.. note:: Many dependencies are installed from the Epel repository, please pay attention to activating this repository before installing jasmin-sms-gateway package.
.. note:: Red Hat Enterprise Linux 8 & CentOS 8 and newer versions are supported.

You may get the following error if **RabbitMQ** or **Redis** server are not installed::
You have to install and setup **RabbitMQ** or **Redis** servers on same machine (Default configuration) or on separate ones (Requires Jasmin configuration: /etc/jasmin/jasmin.cfg).

No package redis available.
No package rabbitmq-server available.

These requirements are available from the `EPEL repository <https://fedoraproject.org/wiki/EPEL>`_, you'll need to enable it before installing Jasmin::

## RHEL/CentOS 7 64-Bit ##
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
.. note:: redis and rabbitmq must be installed and already running.

Once Jasmin installed, you may simply start the **jasmind** service::

sudo systemctl enable jasmind
sudo systemctl start jasmind

.. note:: redis and rabbitmq must be started with jasmin.

Pypi
****
Expand Down
42 changes: 42 additions & 0 deletions misc/packaging/scripts/common-postinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
set -e

JASMIN_USER="jasmin"
JASMIN_GROUP="jasmin"

PACKAGE_NAME="jasmin-sms-gateway"
PYPI_NAME="jasmin"

# Get installed package version and install the related pypi package(s)
if [ "$(grep -Ei 'debian|buntu' /etc/*release)" ]; then
PACKAGE_VERSION=$(dpkg -s "$PACKAGE_NAME"|grep ^Version:|awk '{print $2}')
pip3 install "$PYPI_NAME"=="$PACKAGE_VERSION"
elif [ "$(grep -Ei 'centos|rhel|fedora' /etc/*release)" ]; then
PACKAGE_VERSION=$(rpm -qi "$PACKAGE_NAME"|grep ^Version|awk {'print $3'})
pip3 install "$PYPI_NAME"=="$PACKAGE_VERSION"
else
echo "ERROR: Unsupported OS for this package."
exit 1
fi

# Provision user/group
getent group $JASMIN_GROUP || groupadd -r "$JASMIN_GROUP"
grep -q "^${JASMIN_USER}:" /etc/passwd || useradd -r -g $JASMIN_GROUP \
-d /usr/share/jasmin -s /sbin/nologin \
-c "Jasmin SMS Gateway user" $JASMIN_USER

# Change owner of required folders
chown -R "$JASMIN_USER:$JASMIN_GROUP" /etc/jasmin/store/
chown -R "$JASMIN_USER:$JASMIN_GROUP" /var/log/jasmin

if [ "$1" = configure ]; then
# Enable jasmind service
/bin/systemctl daemon-reload
/bin/systemctl enable jasmind
fi

# python3-falcon package is not available in centos/rhel 8
# this is a workaround
if [ "$(grep -Ei 'centos|rhel|fedora' /etc/*release)" ]; then
pip3 install falcon==2.0.0
fi
17 changes: 17 additions & 0 deletions misc/packaging/scripts/common-preremove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -e

PYPI_NAME="jasmin"

pip3 uninstall -y "$PYPI_NAME"

# Stop and disable jasmind service
/bin/systemctl stop jasmind
/bin/systemctl disable jasmind
/bin/systemctl daemon-reload

# python3-falcon package is not available in centos/rhel 8
# this is a workaround
if [ "$(grep -Ei 'centos|rhel|fedora' /etc/*release)" ]; then
pip3 uninstall -y falcon==2.0.0
fi

0 comments on commit 350a915

Please sign in to comment.