opensipscli 0.3.1__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- opensipscli-0.4.0/.github/workflows/docker-push-image.yml +26 -0
- opensipscli-0.4.0/.github/workflows/docker-readme.yml +26 -0
- opensipscli-0.4.0/.github/workflows/pypi.yml +94 -0
- opensipscli-0.4.0/.gitignore +10 -0
- {opensipscli-0.3.1/opensipscli.egg-info → opensipscli-0.4.0}/PKG-INFO +21 -19
- {opensipscli-0.3.1 → opensipscli-0.4.0}/README.md +6 -3
- opensipscli-0.4.0/SECURITY.md +9 -0
- {opensipscli-0.3.1 → opensipscli-0.4.0}/bin/opensips-cli +1 -1
- opensipscli-0.4.0/docker/Dockerfile +27 -0
- opensipscli-0.4.0/docker/Makefile +13 -0
- opensipscli-0.4.0/docker/docker.md +55 -0
- opensipscli-0.4.0/docker/run.sh +37 -0
- opensipscli-0.4.0/docs/INSTALLATION.md +108 -0
- opensipscli-0.4.0/docs/modules/database.md +144 -0
- opensipscli-0.4.0/docs/modules/diagnose.md +190 -0
- opensipscli-0.4.0/docs/modules/instance.md +54 -0
- opensipscli-0.4.0/docs/modules/mi.md +83 -0
- opensipscli-0.4.0/docs/modules/tls.md +99 -0
- opensipscli-0.4.0/docs/modules/trace.md +56 -0
- opensipscli-0.4.0/docs/modules/trap.md +38 -0
- opensipscli-0.4.0/docs/modules/user.md +63 -0
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/__init__.py +1 -1
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/args.py +1 -1
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/cli.py +19 -5
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/comm.py +1 -1
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/config.py +1 -1
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/db.py +56 -52
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/defaults.py +3 -1
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/libs/__init__.py +1 -1
- opensipscli-0.4.0/opensipscli/libs/sqlalchemy_utils.py +166 -0
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/logger.py +2 -2
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/main.py +1 -1
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/module.py +1 -1
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/modules/__init__.py +1 -1
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/modules/database.py +89 -8
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/modules/diagnose.py +3 -3
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/modules/instance.py +1 -1
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/modules/mi.py +13 -2
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/modules/tls.py +1 -1
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/modules/trace.py +1 -1
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/modules/trap.py +1 -1
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/modules/user.py +2 -3
- {opensipscli-0.3.1 → opensipscli-0.4.0}/opensipscli/version.py +2 -2
- opensipscli-0.4.0/packaging/debian/.gitignore +8 -0
- opensipscli-0.4.0/packaging/debian/changelog +27 -0
- opensipscli-0.4.0/packaging/debian/compat +1 -0
- opensipscli-0.4.0/packaging/debian/control +29 -0
- opensipscli-0.4.0/packaging/debian/copyright +29 -0
- opensipscli-0.4.0/packaging/debian/rules +16 -0
- opensipscli-0.4.0/packaging/debian/source/format +1 -0
- opensipscli-0.4.0/packaging/debian/watch +6 -0
- opensipscli-0.4.0/packaging/redhat_fedora/opensips-cli.spec +76 -0
- opensipscli-0.4.0/pyproject.toml +42 -0
- opensipscli-0.4.0/setup.cfg +1 -0
- opensipscli-0.4.0/setup.py +64 -0
- opensipscli-0.4.0/test/alltests.py +43 -0
- opensipscli-0.4.0/test/test-database.sh +122 -0
- opensipscli-0.4.0/test/test.sh +39 -0
- opensipscli-0.3.1/MANIFEST.in +0 -1
- opensipscli-0.3.1/PKG-INFO +0 -225
- opensipscli-0.3.1/opensipscli/libs/sqlalchemy_utils.py +0 -244
- opensipscli-0.3.1/opensipscli.egg-info/SOURCES.txt +0 -33
- opensipscli-0.3.1/opensipscli.egg-info/dependency_links.txt +0 -1
- opensipscli-0.3.1/opensipscli.egg-info/requires.txt +0 -4
- opensipscli-0.3.1/opensipscli.egg-info/top_level.txt +0 -1
- opensipscli-0.3.1/setup.cfg +0 -4
- opensipscli-0.3.1/setup.py +0 -91
- {opensipscli-0.3.1 → opensipscli-0.4.0}/LICENSE +0 -0
- {opensipscli-0.3.1 → opensipscli-0.4.0}/etc/default.cfg +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: Push OpenSIPS CLI Images in Docker Hub
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
repository_dispatch:
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v3
|
|
14
|
+
|
|
15
|
+
- name: Log in to Docker Hub
|
|
16
|
+
uses: docker/login-action@v2.1.0
|
|
17
|
+
with:
|
|
18
|
+
username: ${{ secrets.DOCKER_USERNAME }}
|
|
19
|
+
password: ${{ secrets.DOCKER_TOKEN }}
|
|
20
|
+
|
|
21
|
+
- name: Build and push Docker image
|
|
22
|
+
uses: docker/build-push-action@v4
|
|
23
|
+
with:
|
|
24
|
+
context: ./docker/
|
|
25
|
+
push: true
|
|
26
|
+
tags: opensips/opensips-cli:latest
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Update Docker Hub Description
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
paths:
|
|
8
|
+
- ./docker/docker.md
|
|
9
|
+
- .github/workflows/docker-readme.yml
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
dockerHubDescription:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
- name: Docker Hub Description
|
|
19
|
+
uses: peter-evans/dockerhub-description@v4
|
|
20
|
+
with:
|
|
21
|
+
username: ${{ secrets.DOCKER_USERNAME }}
|
|
22
|
+
password: ${{ secrets.DOCKER_TOKEN }}
|
|
23
|
+
repository: opensips/opensips-cli
|
|
24
|
+
readme-filepath: ./docker/docker.md
|
|
25
|
+
short-description: ${{ github.event.repository.description }}
|
|
26
|
+
enable-url-completion: true
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Publish OpenSIPS CLI Python package to PyPI
|
|
3
|
+
|
|
4
|
+
on: push
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
build:
|
|
8
|
+
name: Build distribution
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
- name: Set up Python
|
|
14
|
+
uses: actions/setup-python@v5
|
|
15
|
+
with:
|
|
16
|
+
python-version: "3.x"
|
|
17
|
+
- name: Install pypa/build
|
|
18
|
+
run: >-
|
|
19
|
+
python3 -m
|
|
20
|
+
pip install
|
|
21
|
+
build
|
|
22
|
+
--user
|
|
23
|
+
- name: Build a binary wheel and a source tarball
|
|
24
|
+
run: python3 -m build
|
|
25
|
+
- name: Store the distribution packages
|
|
26
|
+
uses: actions/upload-artifact@v4
|
|
27
|
+
with:
|
|
28
|
+
name: python-package-distributions
|
|
29
|
+
path: dist/
|
|
30
|
+
|
|
31
|
+
publish-to-pypi:
|
|
32
|
+
name: >-
|
|
33
|
+
Publish Python OpenSIPS CLI Python package to PyPI
|
|
34
|
+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
|
|
35
|
+
needs:
|
|
36
|
+
- build
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
environment:
|
|
39
|
+
name: release
|
|
40
|
+
url: https://pypi.org/p/opensips-cli
|
|
41
|
+
permissions:
|
|
42
|
+
id-token: write # IMPORTANT: mandatory for trusted publishing
|
|
43
|
+
|
|
44
|
+
steps:
|
|
45
|
+
- name: Download all the dists
|
|
46
|
+
uses: actions/download-artifact@v4
|
|
47
|
+
with:
|
|
48
|
+
name: python-package-distributions
|
|
49
|
+
path: dist/
|
|
50
|
+
- name: Publish distribution OpenSIPS CLI to PyPI
|
|
51
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
52
|
+
|
|
53
|
+
github-release:
|
|
54
|
+
name: >-
|
|
55
|
+
Sign the OpenSIPS CLI Python package with Sigstore
|
|
56
|
+
and upload them to GitHub Release
|
|
57
|
+
needs:
|
|
58
|
+
- publish-to-pypi
|
|
59
|
+
runs-on: ubuntu-latest
|
|
60
|
+
|
|
61
|
+
permissions:
|
|
62
|
+
contents: write # IMPORTANT: mandatory for making GitHub Releases
|
|
63
|
+
id-token: write # IMPORTANT: mandatory for sigstore
|
|
64
|
+
|
|
65
|
+
steps:
|
|
66
|
+
- name: Download all the dists
|
|
67
|
+
uses: actions/download-artifact@v4
|
|
68
|
+
with:
|
|
69
|
+
name: python-package-distributions
|
|
70
|
+
path: dist/
|
|
71
|
+
- name: Sign the dists with Sigstore
|
|
72
|
+
uses: sigstore/gh-action-sigstore-python@v2.1.1
|
|
73
|
+
with:
|
|
74
|
+
inputs: >-
|
|
75
|
+
./dist/*.tar.gz
|
|
76
|
+
./dist/*.whl
|
|
77
|
+
- name: Create GitHub Release
|
|
78
|
+
env:
|
|
79
|
+
GITHUB_TOKEN: ${{ github.token }}
|
|
80
|
+
run: >-
|
|
81
|
+
gh release create
|
|
82
|
+
'${{ github.ref_name }}'
|
|
83
|
+
--repo '${{ github.repository }}'
|
|
84
|
+
--notes ""
|
|
85
|
+
- name: Upload artifact signatures to GitHub Release
|
|
86
|
+
env:
|
|
87
|
+
GITHUB_TOKEN: ${{ github.token }}
|
|
88
|
+
# Upload to GitHub Release using the `gh` CLI.
|
|
89
|
+
# `dist/` contains the built packages, and the
|
|
90
|
+
# sigstore-produced signatures and certificates.
|
|
91
|
+
run: >-
|
|
92
|
+
gh release upload
|
|
93
|
+
'${{ github.ref_name }}' dist/**
|
|
94
|
+
--repo '${{ github.repository }}'
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: opensipscli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: OpenSIPS Command Line Interface
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Maintainer-email: razvan@opensips.org
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Classifier: Programming Language :: Python :: 3
|
|
5
|
+
Project-URL: Homepage, https://github.com/OpenSIPS/opensips-cli
|
|
6
|
+
Project-URL: Source, https://github.com/OpenSIPS/opensips-cli
|
|
7
|
+
Project-URL: Issues, https://github.com/OpenSIPS/opensips-cli/issues
|
|
8
|
+
Project-URL: Download, https://github.com/OpenSIPS/opensips-cli/archive/master.zip
|
|
9
|
+
Author-email: OpenSIPS Project <project@opensips.org>
|
|
10
|
+
Maintainer-email: Razvan Crainea <razvan@opensips.org>
|
|
11
|
+
License: GNU General Public License v3 (GPLv3)
|
|
12
|
+
License-File: LICENSE
|
|
14
13
|
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
15
14
|
Classifier: Operating System :: OS Independent
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Requires-Python: >=3.8
|
|
18
17
|
Requires-Dist: opensips
|
|
19
|
-
Requires-Dist:
|
|
20
|
-
Requires-Dist: sqlalchemy
|
|
21
|
-
|
|
18
|
+
Requires-Dist: pymysql
|
|
19
|
+
Requires-Dist: sqlalchemy>=1.3.16
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
22
21
|
|
|
23
22
|
# OpenSIPS CLI (Command Line Interface)
|
|
24
23
|
|
|
@@ -92,15 +91,15 @@ The OpenSIPSCLI object can receive a set of arguments/modifiers through the
|
|
|
92
91
|
```
|
|
93
92
|
from opensipscli import args
|
|
94
93
|
...
|
|
95
|
-
args = OpenSIPSCLIArgs(debug=True)
|
|
94
|
+
args = args.OpenSIPSCLIArgs(debug=True)
|
|
96
95
|
opensipscli = cli.OpenSIPSCLI(args)
|
|
97
96
|
...
|
|
98
97
|
```
|
|
99
98
|
|
|
100
|
-
Custom settings can be provided
|
|
99
|
+
Custom settings can be provided through the arguments, i.e.:
|
|
101
100
|
```
|
|
102
101
|
# run commands over http
|
|
103
|
-
args = OpenSIPSCLIArgs(
|
|
102
|
+
args = args.OpenSIPSCLIArgs(communication_type = "http",
|
|
104
103
|
url="http://127.0.0.1:8080/mi")
|
|
105
104
|
...
|
|
106
105
|
```
|
|
@@ -155,6 +154,9 @@ fifo used for the reply from OpenSIPS (Default: `/tmp`)
|
|
|
155
154
|
(Default: `http://127.0.0.1:8888/mi`).
|
|
156
155
|
* `datagram_ip`: The default IP used when `datagram` `communication_type` is used (Default: `127.0.0.1`)
|
|
157
156
|
* `datagram_port`: The default port used when `datagram` `communication_type` is used (Default: `8080`)
|
|
157
|
+
* `datagram_timeout`: Timeout for Datagram Socket.
|
|
158
|
+
* `datagram_buffer_size`: Buffer size for Datagram Socket.
|
|
159
|
+
* `datagram_unix_socket`: Unix Domain Socket to use instead of UDP.
|
|
158
160
|
|
|
159
161
|
Each module can use each of the parameters above, but can also declare their
|
|
160
162
|
own. You can find in each module's documentation page the parameters that they
|
|
@@ -70,15 +70,15 @@ The OpenSIPSCLI object can receive a set of arguments/modifiers through the
|
|
|
70
70
|
```
|
|
71
71
|
from opensipscli import args
|
|
72
72
|
...
|
|
73
|
-
args = OpenSIPSCLIArgs(debug=True)
|
|
73
|
+
args = args.OpenSIPSCLIArgs(debug=True)
|
|
74
74
|
opensipscli = cli.OpenSIPSCLI(args)
|
|
75
75
|
...
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
Custom settings can be provided
|
|
78
|
+
Custom settings can be provided through the arguments, i.e.:
|
|
79
79
|
```
|
|
80
80
|
# run commands over http
|
|
81
|
-
args = OpenSIPSCLIArgs(
|
|
81
|
+
args = args.OpenSIPSCLIArgs(communication_type = "http",
|
|
82
82
|
url="http://127.0.0.1:8080/mi")
|
|
83
83
|
...
|
|
84
84
|
```
|
|
@@ -133,6 +133,9 @@ fifo used for the reply from OpenSIPS (Default: `/tmp`)
|
|
|
133
133
|
(Default: `http://127.0.0.1:8888/mi`).
|
|
134
134
|
* `datagram_ip`: The default IP used when `datagram` `communication_type` is used (Default: `127.0.0.1`)
|
|
135
135
|
* `datagram_port`: The default port used when `datagram` `communication_type` is used (Default: `8080`)
|
|
136
|
+
* `datagram_timeout`: Timeout for Datagram Socket.
|
|
137
|
+
* `datagram_buffer_size`: Buffer size for Datagram Socket.
|
|
138
|
+
* `datagram_unix_socket`: Unix Domain Socket to use instead of UDP.
|
|
136
139
|
|
|
137
140
|
Each module can use each of the parameters above, but can also declare their
|
|
138
141
|
own. You can find in each module's documentation page the parameters that they
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
FROM python:slim-trixie
|
|
2
|
+
LABEL maintainer="Razvan Crainea <razvan@opensips.org>"
|
|
3
|
+
|
|
4
|
+
USER root
|
|
5
|
+
|
|
6
|
+
# Set Environment Variables
|
|
7
|
+
ENV DEBIAN_FRONTEND noninteractive
|
|
8
|
+
|
|
9
|
+
#install basic components
|
|
10
|
+
RUN apt-get -y update -qq && \
|
|
11
|
+
apt-get -y install git
|
|
12
|
+
|
|
13
|
+
#add keyserver, repository
|
|
14
|
+
RUN git clone https://github.com/OpenSIPS/opensips-cli.git /usr/src/opensips-cli && \
|
|
15
|
+
cd /usr/src/opensips-cli && \
|
|
16
|
+
python3 -m pip install . && \
|
|
17
|
+
cd / && rm -rf /usr/src/opensips-cli
|
|
18
|
+
|
|
19
|
+
RUN apt-get purge -y git && \
|
|
20
|
+
apt-get autoremove -y && \
|
|
21
|
+
apt-get clean
|
|
22
|
+
|
|
23
|
+
ADD "run.sh" "/run.sh"
|
|
24
|
+
|
|
25
|
+
ENV PYTHONPATH /usr/lib/python3/dist-packages
|
|
26
|
+
|
|
27
|
+
ENTRYPOINT ["/run.sh", "-o", "communication_type=http"]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
NAME ?= opensips-cli
|
|
2
|
+
OPENSIPS_DOCKER_TAG ?= latest
|
|
3
|
+
|
|
4
|
+
all: build start
|
|
5
|
+
|
|
6
|
+
.PHONY: build start
|
|
7
|
+
build:
|
|
8
|
+
docker build \
|
|
9
|
+
--tag="opensips/opensips-cli:$(OPENSIPS_DOCKER_TAG)" \
|
|
10
|
+
.
|
|
11
|
+
|
|
12
|
+
start:
|
|
13
|
+
docker run -d --name $(NAME) opensips/opensips-cli:$(OPENSIPS_DOCKER_TAG)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# OpenSIPS CLI Docker Image
|
|
2
|
+
|
|
3
|
+
Docker recipe for running [OpenSIPS Command Line
|
|
4
|
+
Interface](https://github.com/OpenSIPS/opensips-cli).
|
|
5
|
+
|
|
6
|
+
## Building the image
|
|
7
|
+
You can build the docker image by running:
|
|
8
|
+
```
|
|
9
|
+
make build
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
This command will build a docker image with OpenSIPS CLI master version taken from
|
|
13
|
+
the git repository
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
The container receives parameters in the following format:
|
|
18
|
+
```
|
|
19
|
+
[-o KEY=VALUE]* CMD [PARAMS]*
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Meaning of the parameters is as it follows:
|
|
23
|
+
|
|
24
|
+
* `-o KEY=VALUE` - used to tune `opensips-cli` at runtime; these parameters
|
|
25
|
+
will end up in opensips-cli config file, in the `default` section, as
|
|
26
|
+
`KEY: VALUE` lines
|
|
27
|
+
* `CMD` - the command used to run; if the `CMD` ends with `.sh` extension, it
|
|
28
|
+
will be run as a bash script, if the `CMD` ends with `.py` extension, it is
|
|
29
|
+
run as a python script, otherwise it is run as a `opensips-cli` command
|
|
30
|
+
* `PARAMS` - optional additional parameters passed to `CMD`
|
|
31
|
+
|
|
32
|
+
## Run
|
|
33
|
+
|
|
34
|
+
To run a bash script, simply pass the connector followed by the bash script:
|
|
35
|
+
```
|
|
36
|
+
docker run -d --name opensips-cli opensips/opensips-cli:latest \
|
|
37
|
+
-o url=http://8.8.8.8:8888/mi script.sh
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Similarly, run a python script:
|
|
41
|
+
```
|
|
42
|
+
docker run -d --name opensips-cli opensips/opensips-cli:latest \
|
|
43
|
+
-o url=http://8.8.8.8:8888/mi script.py
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
To run a single MI command, use:
|
|
47
|
+
```
|
|
48
|
+
docker run -d --name opensips-cli opensips/opensips-cli:latest \
|
|
49
|
+
-o url=http://8.8.8.8:8888/mi -x mi ps
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## DockerHub
|
|
53
|
+
|
|
54
|
+
Docker images are available on
|
|
55
|
+
[DockerHub](https://hub.docker.com/r/opensips/opensips-cli).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
OPTS=
|
|
4
|
+
CMD=
|
|
5
|
+
PARAMS=
|
|
6
|
+
CFG=/etc/opensips-cli.cfg
|
|
7
|
+
|
|
8
|
+
echo "[default]" > "$CFG"
|
|
9
|
+
|
|
10
|
+
while [[ $# -gt 0 ]]; do
|
|
11
|
+
case "$1" in
|
|
12
|
+
-o|--option)
|
|
13
|
+
shift
|
|
14
|
+
P=$(cut -d'=' -f1 <<<"$1")
|
|
15
|
+
V=$(cut -d'=' -f2- <<<"$1")
|
|
16
|
+
echo "$P: $V" >> "$CFG"
|
|
17
|
+
;;
|
|
18
|
+
*)
|
|
19
|
+
if [ -z "$CMD" ]; then
|
|
20
|
+
CMD="$1"
|
|
21
|
+
else
|
|
22
|
+
PARAMS="${PARAMS} ${1}"
|
|
23
|
+
fi
|
|
24
|
+
;;
|
|
25
|
+
esac
|
|
26
|
+
shift
|
|
27
|
+
done
|
|
28
|
+
|
|
29
|
+
if [[ $CMD == *.py ]]; then
|
|
30
|
+
TOOL=python3
|
|
31
|
+
elif [[ $CMD == *.sh ]]; then
|
|
32
|
+
TOOL=bash
|
|
33
|
+
else
|
|
34
|
+
TOOL=opensips-cli
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
exec $TOOL $CMD $PARAMS
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Installation
|
|
2
|
+
|
|
3
|
+
`opensips-cli` is the intended convenient command-line interface for
|
|
4
|
+
administrating `opensips 3.x` installations.
|
|
5
|
+
|
|
6
|
+
Since `version 3.x`, the former script tool `opensipsctl` has been removed.
|
|
7
|
+
Its successor, `opensips-cli`, offers many advantages and will improve handling
|
|
8
|
+
for regular tasks in a pleasant console environment.
|
|
9
|
+
|
|
10
|
+
## From Packages
|
|
11
|
+
|
|
12
|
+
### Debian packages (.deb)
|
|
13
|
+
|
|
14
|
+
Add the ["cli-releases" repository from apt.opensips.org](https://apt.opensips.org/packages.php?v=cli)
|
|
15
|
+
to your system using the instructions provided, then install the
|
|
16
|
+
`opensips-cli` package.
|
|
17
|
+
|
|
18
|
+
Supported Operating Systems (at the time of writing):
|
|
19
|
+
|
|
20
|
+
* Debian 8-10
|
|
21
|
+
* Ubuntu 14.04, 16.04, 18.04, 19.04
|
|
22
|
+
|
|
23
|
+
### RPM packages (.rpm)
|
|
24
|
+
|
|
25
|
+
The ["opensips-yum-releases" meta-package from yum.opensips.org](https://yum.opensips.org/)
|
|
26
|
+
will install a repository that includes both `opensips` and `opensips-cli`
|
|
27
|
+
packages. Once installed, install the `opensips-cli` package.
|
|
28
|
+
|
|
29
|
+
Supported Operating Systems (at the time of writing):
|
|
30
|
+
|
|
31
|
+
* RHEL 6-8, CentOS 6-8, Scientific Linux 6-8, Oracle Linux 6-8
|
|
32
|
+
* Fedora 27-31
|
|
33
|
+
|
|
34
|
+
### Arch Linux AUR
|
|
35
|
+
|
|
36
|
+
The distribution is managed as a rolling release. Packages are administered
|
|
37
|
+
via the `pacman` front-end. Please install the `opensips-cli` package from the
|
|
38
|
+
`AUR` using your favorite client:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
# nightly build (latest `master` branch)
|
|
42
|
+
yay opensips-cli-git
|
|
43
|
+
|
|
44
|
+
# latest release branch
|
|
45
|
+
yay opensips-cli
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## From Source Code
|
|
49
|
+
|
|
50
|
+
### Requirements
|
|
51
|
+
|
|
52
|
+
Before building the CLI, you need to install some dependencies. The process
|
|
53
|
+
will vary on every supported operating system.
|
|
54
|
+
|
|
55
|
+
#### Debian / Ubuntu
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
# required OS packages
|
|
59
|
+
sudo apt install python3 python3-pip python3-pymysql python3-sqlalchemy \
|
|
60
|
+
python3-openssl
|
|
61
|
+
|
|
62
|
+
# alternatively, you can build the requirements from source
|
|
63
|
+
sudo pip3 install PyMySQL sqlalchemy pyOpenSSL
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### Red Hat / CentOS
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
# required CentOS 7 packages
|
|
70
|
+
sudo yum install python36 python36-pip python36-PyMySQL \
|
|
71
|
+
python36-sqlalchemy python36-pyOpenSSL
|
|
72
|
+
|
|
73
|
+
# required CentOS 8 packages
|
|
74
|
+
sudo yum install python3 python3-pip python3-PyMySQL \
|
|
75
|
+
python3-sqlalchemy python3-pyOpenSSL
|
|
76
|
+
|
|
77
|
+
# alternatively, you can build the requirements from source
|
|
78
|
+
sudo pip3 install PyMySQL sqlalchemy pyOpenSSL
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Download, Build & Install
|
|
82
|
+
|
|
83
|
+
We can now download and install the latest development state from the GitHub
|
|
84
|
+
repository:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
git clone https://github.com/opensips/opensips-cli ~/src/opensips-cli
|
|
88
|
+
cd ~/src/opensips-cli
|
|
89
|
+
|
|
90
|
+
# local install (only visible to your user)
|
|
91
|
+
python3 -m pip install --user .
|
|
92
|
+
|
|
93
|
+
# system-wide install
|
|
94
|
+
sudo python3 -m pip install .
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Cleaning up the install
|
|
98
|
+
|
|
99
|
+
To clean up the manually built and installed `opensips-cli` package, run:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
python3 -m pip uninstall opensipscli
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Database Installation
|
|
106
|
+
|
|
107
|
+
Follow the [Database](modules/database.md#Examples) module documentation for a
|
|
108
|
+
complete guide.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# OpenSIPS CLI - Database module
|
|
2
|
+
|
|
3
|
+
Module used to manipulate the database used by OpenSIPS.
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
This module exports the following commands:
|
|
8
|
+
* `create` - creates a new database. Can receive an optional parameter,
|
|
9
|
+
specifying the name of the database to be created. This command also deploys
|
|
10
|
+
the standard OpenSIPS table, as well as other standard tables
|
|
11
|
+
* `drop` - drops a database. Can receive an optional parameter, specifying
|
|
12
|
+
which database to delete.
|
|
13
|
+
* `add` - adds a new module's tables in an existing database. Receives as
|
|
14
|
+
parameter the name of the module, as specified in the OpenSIPS scripts
|
|
15
|
+
hierarchy.
|
|
16
|
+
* `migrate` - copy and convert an OpenSIPS database into its next OpenSIPS
|
|
17
|
+
release equivalent
|
|
18
|
+
|
|
19
|
+
## Configuration
|
|
20
|
+
|
|
21
|
+
### Database Schema Files
|
|
22
|
+
|
|
23
|
+
The database schema files for each supported SQL backend can be installed via
|
|
24
|
+
their corresponding OpenSIPS client module package. For example (only install modules useful to you):
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
apt install opensips-mysql-module opensips-postgres-module opensips-sqlite-module opensips-berkeley-module
|
|
28
|
+
yum install opensips-mysql-module opensips-postgres-module opensips-sqlite-module opensips-berkeley-module
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Once installed, the schema files will be auto-detected by `opensips-cli`.
|
|
32
|
+
|
|
33
|
+
### Setting up the `database` module
|
|
34
|
+
|
|
35
|
+
The following parameters are allowed in the config file:
|
|
36
|
+
|
|
37
|
+
* `database_schema_path` (optional) - absolute path to the OpenSIPS DB schema directory,
|
|
38
|
+
usually `/usr/share/opensips` if installed from packages or `/path/to/opensips/scripts` if you
|
|
39
|
+
are using the OpenSIPS source tree. Default: `/usr/share/opensips`
|
|
40
|
+
* `database_admin_url` (optional) - a connection string to the database with privileged
|
|
41
|
+
(administrator) access level which will be used to create/drop databases, as
|
|
42
|
+
well as to create or ensure access for the non-privileged DB access user
|
|
43
|
+
provided via `database_url`. The URL combines schema, username, password, host
|
|
44
|
+
and port. Default: `mysql://root@localhost`.
|
|
45
|
+
* `database_url` (optional) - the connection string to the database. A good practice
|
|
46
|
+
would be to use a non-administrator access user for this URL. Default:
|
|
47
|
+
`mysql://opensips:opensipsrw@localhost`.
|
|
48
|
+
* `database_name` (optional) - the name of the database. Modules may be separately added
|
|
49
|
+
to this database if you choose not to install all of them. Default: `opensips`.
|
|
50
|
+
* `database_modules` (optional) - accepts the `ALL` keyword that indicates all the
|
|
51
|
+
available modules should be installed, or a space-separated list of modules
|
|
52
|
+
names. If processed with the `create` command, the corresponding tables will
|
|
53
|
+
be deployed. Default: `acc alias_db auth_db avpops clusterer dialog
|
|
54
|
+
dialplan dispatcher domain drouting group load_balancer msilo permissions
|
|
55
|
+
rtpproxy rtpengine speeddial tls_mgm usrloc`.
|
|
56
|
+
* `database_force_drop` (optional) - indicates whether the `drop` command will drop the
|
|
57
|
+
database without user interaction. Default: `false`
|
|
58
|
+
|
|
59
|
+
## Usage Examples
|
|
60
|
+
|
|
61
|
+
### Database Management
|
|
62
|
+
|
|
63
|
+
Consider the following configuration file:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
[default]
|
|
67
|
+
#database_modules: acc clusterer dialog dialplan dispatcher domain rtpproxy usrloc
|
|
68
|
+
database_modules: ALL
|
|
69
|
+
|
|
70
|
+
#database_admin_url: postgresql://root@localhost
|
|
71
|
+
database_admin_url: mysql://root@localhost
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The following command will create the `opensips` database and all possible
|
|
75
|
+
tables within the MySQL instance. Additionally, the `opensips:opensipsrw` user
|
|
76
|
+
will be created will `ALL PRIVILEGES` for the `opensips` database. For some
|
|
77
|
+
backends, such as PostgreSQL, any additionally required permissions will be
|
|
78
|
+
transparently granted to the `opensips` user, for example: table-level or
|
|
79
|
+
sequence-level permissions.
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
opensips-cli -x database create
|
|
83
|
+
Password for admin DB user (root): _
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
If we want to add a new module, say `rtpproxy`, we have to run:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
opensips-cli -x database add rtpproxy
|
|
90
|
+
```
|
|
91
|
+
The command above will create the `rtpproxy_sockets` table.
|
|
92
|
+
|
|
93
|
+
A drop command will prompt the user whether they really want to drop the
|
|
94
|
+
database or not:
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
$ opensips-cli -x database drop
|
|
98
|
+
Do you really want to drop the 'opensips' database [Y/n] (Default is n): n
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
But setting the `database_force_drop` parameter will drop it without asking:
|
|
102
|
+
```
|
|
103
|
+
opensips-cli -o database_force_drop=true -x database drop
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Database Migration (MySQL only)
|
|
107
|
+
|
|
108
|
+
The `database migrate` command can be used to _incrementally_ upgrade
|
|
109
|
+
your OpenSIPS database.
|
|
110
|
+
|
|
111
|
+
#### Migrating from 2.4 to 3.0
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
# fetch the 3.0 OpenSIPS repo & migration scripts
|
|
115
|
+
git clone https://github.com/OpenSIPS/opensips -b 3.0 ~/src/opensips-3.0
|
|
116
|
+
|
|
117
|
+
# provide the custom path to the migration scripts and perform the migration
|
|
118
|
+
opensips-cli -o database_schema_path=~/src/opensips-3.0/scripts \
|
|
119
|
+
-x database migrate 2.4_to_3.0 opensips_2_4 opensips_mig_3_0
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### Migrating from 3.0 to 3.1
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
# fetch the 3.1 OpenSIPS repo & migration scripts
|
|
126
|
+
git clone https://github.com/OpenSIPS/opensips -b 3.1 ~/src/opensips-3.1
|
|
127
|
+
|
|
128
|
+
# provide the custom path to the migration scripts and perform the migration
|
|
129
|
+
opensips-cli -o database_schema_path=~/src/opensips-3.1/scripts \
|
|
130
|
+
-x database migrate 3.0_to_3.1 opensips_3_0 opensips_mig_3_1
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Dependencies
|
|
134
|
+
|
|
135
|
+
* [sqlalchemy](https://www.sqlalchemy.org/) - used to abstract the SQL
|
|
136
|
+
database regardless of the backend used
|
|
137
|
+
* [PyMySQL](https://github.com/PyMySQL/PyMySQL) - pure-Python MySQL/MariaDB
|
|
138
|
+
driver used by SQLAlchemy when connecting to MySQL backends
|
|
139
|
+
|
|
140
|
+
## Limitations
|
|
141
|
+
|
|
142
|
+
This module can only manipulate database backends that are supported by the
|
|
143
|
+
[SQLAlchemy](https://www.sqlalchemy.org/) project, such as SQLite,
|
|
144
|
+
Postgresql, MySQL, Oracle, MS-SQL.
|