opensipscli 0.3.1__tar.gz → 0.3.5__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.
Files changed (68) hide show
  1. opensipscli-0.3.5/.github/workflows/docker-push-image.yml +26 -0
  2. opensipscli-0.3.5/.github/workflows/docker-readme.yml +26 -0
  3. opensipscli-0.3.5/.github/workflows/pypi.yml +94 -0
  4. opensipscli-0.3.5/.gitignore +10 -0
  5. {opensipscli-0.3.1/opensipscli.egg-info → opensipscli-0.3.5}/PKG-INFO +20 -17
  6. {opensipscli-0.3.1 → opensipscli-0.3.5}/README.md +5 -2
  7. opensipscli-0.3.5/SECURITY.md +9 -0
  8. opensipscli-0.3.5/docker/Dockerfile +27 -0
  9. opensipscli-0.3.5/docker/Makefile +13 -0
  10. opensipscli-0.3.5/docker/docker.md +55 -0
  11. opensipscli-0.3.5/docker/run.sh +37 -0
  12. opensipscli-0.3.5/docs/INSTALLATION.md +109 -0
  13. opensipscli-0.3.5/docs/modules/database.md +142 -0
  14. opensipscli-0.3.5/docs/modules/diagnose.md +190 -0
  15. opensipscli-0.3.5/docs/modules/instance.md +54 -0
  16. opensipscli-0.3.5/docs/modules/mi.md +83 -0
  17. opensipscli-0.3.5/docs/modules/tls.md +99 -0
  18. opensipscli-0.3.5/docs/modules/trace.md +56 -0
  19. opensipscli-0.3.5/docs/modules/trap.md +38 -0
  20. opensipscli-0.3.5/docs/modules/user.md +63 -0
  21. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/cli.py +9 -4
  22. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/db.py +8 -8
  23. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/defaults.py +2 -0
  24. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/logger.py +1 -1
  25. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/modules/database.py +80 -5
  26. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/modules/diagnose.py +2 -2
  27. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/modules/mi.py +1 -1
  28. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/modules/user.py +1 -2
  29. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/version.py +1 -1
  30. opensipscli-0.3.5/packaging/debian/.gitignore +8 -0
  31. opensipscli-0.3.5/packaging/debian/changelog +21 -0
  32. opensipscli-0.3.5/packaging/debian/compat +1 -0
  33. opensipscli-0.3.5/packaging/debian/control +29 -0
  34. opensipscli-0.3.5/packaging/debian/copyright +29 -0
  35. opensipscli-0.3.5/packaging/debian/rules +16 -0
  36. opensipscli-0.3.5/packaging/debian/source/format +1 -0
  37. opensipscli-0.3.5/packaging/debian/watch +6 -0
  38. opensipscli-0.3.5/packaging/redhat_fedora/opensips-cli.spec +75 -0
  39. opensipscli-0.3.5/pyproject.toml +43 -0
  40. opensipscli-0.3.5/setup.cfg +1 -0
  41. opensipscli-0.3.5/setup.py +65 -0
  42. opensipscli-0.3.5/test/alltests.py +43 -0
  43. opensipscli-0.3.5/test/test-database.sh +122 -0
  44. opensipscli-0.3.5/test/test.sh +39 -0
  45. opensipscli-0.3.1/MANIFEST.in +0 -1
  46. opensipscli-0.3.1/PKG-INFO +0 -225
  47. opensipscli-0.3.1/opensipscli.egg-info/SOURCES.txt +0 -33
  48. opensipscli-0.3.1/opensipscli.egg-info/dependency_links.txt +0 -1
  49. opensipscli-0.3.1/opensipscli.egg-info/requires.txt +0 -4
  50. opensipscli-0.3.1/opensipscli.egg-info/top_level.txt +0 -1
  51. opensipscli-0.3.1/setup.cfg +0 -4
  52. opensipscli-0.3.1/setup.py +0 -91
  53. {opensipscli-0.3.1 → opensipscli-0.3.5}/LICENSE +0 -0
  54. {opensipscli-0.3.1 → opensipscli-0.3.5}/bin/opensips-cli +0 -0
  55. {opensipscli-0.3.1 → opensipscli-0.3.5}/etc/default.cfg +0 -0
  56. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/__init__.py +0 -0
  57. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/args.py +0 -0
  58. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/comm.py +0 -0
  59. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/config.py +0 -0
  60. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/libs/__init__.py +0 -0
  61. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/libs/sqlalchemy_utils.py +0 -0
  62. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/main.py +0 -0
  63. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/module.py +0 -0
  64. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/modules/__init__.py +0 -0
  65. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/modules/instance.py +0 -0
  66. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/modules/tls.py +0 -0
  67. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/modules/trace.py +0 -0
  68. {opensipscli-0.3.1 → opensipscli-0.3.5}/opensipscli/modules/trap.py +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 }}'
@@ -0,0 +1,10 @@
1
+ *.pyc
2
+ *.pyo
3
+ *.swp
4
+ __pycach*
5
+ /.pybuild/
6
+ /build/
7
+ /dist/
8
+ /MANIFEST
9
+ *egg-info/
10
+ tags
@@ -1,24 +1,24 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: opensipscli
3
- Version: 0.3.1
3
+ Version: 0.3.5
4
4
  Summary: OpenSIPS Command Line Interface
5
- Home-page: https://github.com/OpenSIPS/opensips-cli
6
- Download-URL: https://github.com/OpenSIPS/opensips-cli/archive/master.zip
7
- Author: OpenSIPS Project
8
- Author-email: project@opensips.org
9
- Maintainer: Razvan Crainea
10
- Maintainer-email: razvan@opensips.org
11
- Project-URL: Source Code, https://github.com/OpenSIPS/opensips-cli
12
- Project-URL: Issues Tracker, https://github.com/OpenSIPS/opensips-cli/issues
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
- Description-Content-Type: text/markdown
17
- License-File: LICENSE
18
- Requires-Dist: opensips
15
+ Classifier: Programming Language :: Python :: 3
16
+ Requires-Python: >=3.8
19
17
  Requires-Dist: mysqlclient<1.4.0rc1
20
- Requires-Dist: sqlalchemy<2,>=1.3.3
18
+ Requires-Dist: opensips
21
19
  Requires-Dist: sqlalchemy-utils
20
+ Requires-Dist: sqlalchemy<2,>=1.3.3
21
+ Description-Content-Type: text/markdown
22
22
 
23
23
  # OpenSIPS CLI (Command Line Interface)
24
24
 
@@ -97,10 +97,10 @@ opensipscli = cli.OpenSIPSCLI(args)
97
97
  ...
98
98
  ```
99
99
 
100
- Custom settings can be provided thourgh the arguments, i.e.:
100
+ Custom settings can be provided through the arguments, i.e.:
101
101
  ```
102
102
  # run commands over http
103
- args = OpenSIPSCLIArgs(communcation_type = "http",
103
+ args = OpenSIPSCLIArgs(communication_type = "http",
104
104
  url="http://127.0.0.1:8080/mi")
105
105
  ...
106
106
  ```
@@ -155,6 +155,9 @@ fifo used for the reply from OpenSIPS (Default: `/tmp`)
155
155
  (Default: `http://127.0.0.1:8888/mi`).
156
156
  * `datagram_ip`: The default IP used when `datagram` `communication_type` is used (Default: `127.0.0.1`)
157
157
  * `datagram_port`: The default port used when `datagram` `communication_type` is used (Default: `8080`)
158
+ * `datagram_timeout`: Timeout for Datagram Socket.
159
+ * `datagram_buffer_size`: Buffer size for Datagram Socket.
160
+ * `datagram_unix_socket`: Unix Domain Socket to use instead of UDP.
158
161
 
159
162
  Each module can use each of the parameters above, but can also declare their
160
163
  own. You can find in each module's documentation page the parameters that they
@@ -75,10 +75,10 @@ opensipscli = cli.OpenSIPSCLI(args)
75
75
  ...
76
76
  ```
77
77
 
78
- Custom settings can be provided thourgh the arguments, i.e.:
78
+ Custom settings can be provided through the arguments, i.e.:
79
79
  ```
80
80
  # run commands over http
81
- args = OpenSIPSCLIArgs(communcation_type = "http",
81
+ 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,9 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ All available versions are eligible for security updates
6
+
7
+ ## Reporting a Vulnerability
8
+
9
+ For any security/vulnerability issues you may discover, please send us a full report at security@opensips.org.
@@ -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 default-libmysqlclient-dev gcc
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 gcc && \
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,109 @@
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-dev gcc default-libmysqlclient-dev \
60
+ python3-mysqldb python3-sqlalchemy python3-sqlalchemy-utils \
61
+ python3-openssl
62
+
63
+ # alternatively, you can build the requirements from source
64
+ sudo pip3 install mysqlclient sqlalchemy sqlalchemy-utils pyOpenSSL
65
+ ```
66
+
67
+ #### Red Hat / CentOS
68
+
69
+ ```
70
+ # required CentOS 7 packages
71
+ sudo yum install python36 python36-pip python36-devel gcc mysql-devel \
72
+ python36-mysql python36-sqlalchemy python36-pyOpenSSL
73
+
74
+ # required CentOS 8 packages
75
+ sudo yum install python3 python3-pip python3-devel gcc mysql-devel \
76
+ python3-mysqlclient python3-sqlalchemy python3-pyOpenSSL
77
+
78
+ # alternatively, you can build the requirements from source
79
+ sudo pip3 install mysqlclient sqlalchemy sqlalchemy-utils pyOpenSSL
80
+ ```
81
+
82
+ ### Download, Build & Install
83
+
84
+ We can now download and install the latest development state from the GitHub
85
+ repository:
86
+
87
+ ```
88
+ git clone https://github.com/opensips/opensips-cli ~/src/opensips-cli
89
+ cd ~/src/opensips-cli
90
+
91
+ # local install (only visible to your user)
92
+ python3 -m pip install --user .
93
+
94
+ # system-wide install
95
+ sudo python3 -m pip install .
96
+ ```
97
+
98
+ ### Cleaning up the install
99
+
100
+ To clean up the manually built and installed `opensips-cli` package, run:
101
+
102
+ ```
103
+ python3 -m pip uninstall opensipscli
104
+ ```
105
+
106
+ ## Database Installation
107
+
108
+ Follow the [Database](modules/database.md#Examples) module documentation for a
109
+ complete guide.
@@ -0,0 +1,142 @@
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 and sqlalchemy_utils](https://www.sqlalchemy.org/) - used to
136
+ abstract the SQL database regardless of the backend used
137
+
138
+ ## Limitations
139
+
140
+ This module can only manipulate database backends that are supported by the
141
+ [SQLAlchemy](https://www.sqlalchemy.org/) project, such as SQLite,
142
+ Postgresql, MySQL, Oracle, MS-SQL.