Currently, I run a scheduled Task on my Router. From other Linux systems I found out, that somehow it’s possible to send logs over E-Mail. But Is it also possible to register a Matrix client to get some logs into a matrix chat?
It would be nice If I could write COMMAND > \path\to\matrix
and instant get the logs of a command.
sending output of a cron command via mail is builtin feature of cron daemon. Pushing that feature to matrix client would either require modifying cron program or installing and configuring software that would push mail to matrix notification.
Looking at it, daemon used is from “cronie” package and is started with -s option which pushes all output to syslog.
syslog daemon used is “syslog-ng”. perhaps you could configure it to send some kinds of filter that would send messages to matrix
However I don’t see any matrix client in OpenWRT for now.
My suggestions:
- search for “matrix cli”, You might find “GitHub - 8go/matrix-commander: simple but convenient CLI-based Matrix client app for sending and receiving”
- consider to facilitate “matrix-ng” and “dendrite”, as they are progressing.
I didn’t verify, if they do/will offer CLI features.
But it seems to be of help to have a look on that evolving eco system.
Seems not working because pip has problems compiling cffi as far it seems gcc is the problem.
could you please tell more exhaustive and exact on what you did, what you expected, and what did/did not happen as expected? thx a lot.
cd /srv/
python3 -m venv /srv/matrix --without-pip
source /srv/matrix/bin/activate
python3 /srv/get-pip.py
pip install matrix-commander
Collecting matrix-commander
Using cached matrix_commander-7.6.0-py3-none-any.whl.metadata (130 kB)
Collecting aiohttp (from matrix-commander)
Using cached aiohttp-3.9.1.tar.gz (7.5 MB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Installing backend dependencies: started
Installing backend dependencies: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Collecting aiofiles>=0.6.0 (from matrix-commander)
Using cached aiofiles-23.2.1-py3-none-any.whl.metadata (9.7 kB)
Collecting argparse (from matrix-commander)
Using cached argparse-1.4.0-py2.py3-none-any.whl (23 kB)
Collecting asyncio (from matrix-commander)
Using cached asyncio-3.4.3-py3-none-any.whl (101 kB)
Collecting datetime (from matrix-commander)
Using cached DateTime-5.4-py3-none-any.whl.metadata (33 kB)
Collecting emoji (from matrix-commander)
Using cached emoji-2.9.0-py2.py3-none-any.whl.metadata (5.3 kB)
Collecting markdown (from matrix-commander)
Using cached Markdown-3.5.1-py3-none-any.whl.metadata (7.1 kB)
Collecting matrix-nio>=0.14.1 (from matrix-nio[e2e]>=0.14.1->matrix-commander)
Using cached matrix_nio-0.23.0-py3-none-any.whl.metadata (4.5 kB)
Collecting notify2 (from matrix-commander)
Using cached notify2-0.3.1-py2.py3-none-any.whl (8.0 kB)
Collecting Pillow (from matrix-commander)
Using cached Pillow-10.1.0.tar.gz (50.8 MB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Installing backend dependencies: started
Installing backend dependencies: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Collecting python-magic (from matrix-commander)
Using cached python_magic-0.4.27-py2.py3-none-any.whl (13 kB)
Collecting pyxdg (from matrix-commander)
Using cached pyxdg-0.28-py2.py3-none-any.whl (49 kB)
Collecting uuid (from matrix-commander)
Using cached uuid-1.30.tar.gz (5.8 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Collecting aiohttp-socks<0.8.0,>=0.7.0 (from matrix-nio>=0.14.1->matrix-nio[e2e]>=0.14.1->matrix-commander)
Using cached aiohttp_socks-0.7.1-py3-none-any.whl (9.3 kB)
Collecting h11<0.15.0,>=0.14.0 (from matrix-nio>=0.14.1->matrix-nio[e2e]>=0.14.1->matrix-commander)
Using cached h11-0.14.0-py3-none-any.whl (58 kB)
Collecting h2<5.0.0,>=4.0.0 (from matrix-nio>=0.14.1->matrix-nio[e2e]>=0.14.1->matrix-commander)
Using cached h2-4.1.0-py3-none-any.whl (57 kB)
Collecting jsonschema<5.0.0,>=4.14.0 (from matrix-nio>=0.14.1->matrix-nio[e2e]>=0.14.1->matrix-commander)
Using cached jsonschema-4.20.0-py3-none-any.whl.metadata (8.1 kB)
Collecting pycryptodome<4.0.0,>=3.10.1 (from matrix-nio>=0.14.1->matrix-nio[e2e]>=0.14.1->matrix-commander)
Using cached pycryptodome-3.19.0.tar.gz (4.8 MB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Installing backend dependencies: started
Installing backend dependencies: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Collecting unpaddedbase64<3.0.0,>=2.1.0 (from matrix-nio>=0.14.1->matrix-nio[e2e]>=0.14.1->matrix-commander)
Using cached unpaddedbase64-2.1.0-py3-none-any.whl (6.1 kB)
Collecting attrs>=17.3.0 (from aiohttp->matrix-commander)
Using cached attrs-23.1.0-py3-none-any.whl (61 kB)
Collecting multidict<7.0,>=4.5 (from aiohttp->matrix-commander)
Using cached multidict-6.0.4.tar.gz (51 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Installing backend dependencies: started
Installing backend dependencies: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Collecting yarl<2.0,>=1.0 (from aiohttp->matrix-commander)
Using cached yarl-1.9.4-py3-none-any.whl.metadata (31 kB)
Collecting frozenlist>=1.1.1 (from aiohttp->matrix-commander)
Using cached frozenlist-1.4.1-py3-none-any.whl.metadata (12 kB)
Collecting aiosignal>=1.1.2 (from aiohttp->matrix-commander)
Using cached aiosignal-1.3.1-py3-none-any.whl (7.6 kB)
Collecting async-timeout<5.0,>=4.0 (from aiohttp->matrix-commander)
Using cached async_timeout-4.0.3-py3-none-any.whl.metadata (4.2 kB)
Collecting atomicwrites<2.0.0,>=1.4.0 (from matrix-nio[e2e]>=0.14.1->matrix-commander)
Using cached atomicwrites-1.4.1.tar.gz (14 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Collecting cachetools<5.0.0,>=4.2.1 (from matrix-nio[e2e]>=0.14.1->matrix-commander)
Using cached cachetools-4.2.4-py3-none-any.whl (10 kB)
Collecting peewee<4.0.0,>=3.14.4 (from matrix-nio[e2e]>=0.14.1->matrix-commander)
Using cached peewee-3.17.0.tar.gz (2.9 MB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Collecting python-olm<4.0.0,>=3.1.3 (from matrix-nio[e2e]>=0.14.1->matrix-commander)
Using cached python-olm-3.2.16.tar.gz (2.7 MB)
Installing build dependencies: started
Installing build dependencies: finished with status 'error'
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> [71 lines of output]
Collecting setuptools
Using cached setuptools-69.0.3-py3-none-any.whl.metadata (6.3 kB)
Collecting cffi>=1.0.0
Using cached cffi-1.16.0.tar.gz (512 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Installing backend dependencies: started
Installing backend dependencies: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Collecting pycparser (from cffi>=1.0.0)
Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Using cached setuptools-69.0.3-py3-none-any.whl (819 kB)
Building wheels for collected packages: cffi
Building wheel for cffi (pyproject.toml): started
Building wheel for cffi (pyproject.toml): finished with status 'error'
error: subprocess-exited-with-error
× Building wheel for cffi (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [39 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-armv7l-cpython-39
creating build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/verifier.py -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/vengine_gen.py -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/vengine_cpy.py -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/setuptools_ext.py -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/recompiler.py -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/pkgconfig.py -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/model.py -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/lock.py -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/ffiplatform.py -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/error.py -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/cparser.py -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/commontypes.py -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/cffi_opcode.py -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/backend_ctypes.py -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/api.py -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/_shimmed_dist_utils.py -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/_imp_emulation.py -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/__init__.py -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/_cffi_include.h -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/parse_c_type.h -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/_embedding.h -> build/lib.linux-armv7l-cpython-39/cffi
copying src/cffi/_cffi_errors.h -> build/lib.linux-armv7l-cpython-39/cffi
running build_ext
building '_cffi_backend' extension
creating build/temp.linux-armv7l-cpython-39
creating build/temp.linux-armv7l-cpython-39/src
creating build/temp.linux-armv7l-cpython-39/src/c
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -mfloat-abi=hard -fmacro-prefix-map=/home/beast/workspace/TurrisOS/packages-hbk-omnia/build/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/Python-3.9.18=Python-3.9.18 -Wformat -Werror=format-security -DPIC -fpic -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,now -Wl,-z,relro -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -mfloat-abi=hard -fmacro-prefix-map=/home/beast/workspace/TurrisOS/packages-hbk-omnia/build/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/Python-3.9.18=Python-3.9.18 -Wformat -Werror=format-security -DPIC -fpic -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,now -Wl,-z,relro -DNDEBUG -fno-inline -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -mfloat-abi=hard -fmacro-prefix-map=/home/beast/workspace/TurrisOS/packages-hbk-omnia/build/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/Python-3.9.18=Python-3.9.18 -Wformat -Werror=format-security -DPIC -fpic -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,now -Wl,-z,relro -DNDEBUG -fno-inline -I/home/beast/workspace/TurrisOS/packages-hbk-omnia/build/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-8.4.0_musl_eabi/usr/include -I/home/beast/workspace/TurrisOS/packages-hbk-omnia/build/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-8.4.0_musl_eabi/include/fortify -I/home/beast/workspace/TurrisOS/packages-hbk-omnia/build/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-8.4.0_musl_eabi/include -fPIC -DFFI_BUILDING=1 -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/srv/matrix/include -I/usr/include/python3.9 -c src/c/_cffi_backend.c -o build/temp.linux-armv7l-cpython-39/src/c/_cffi_backend.o
src/c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
#include <ffi.h>
^~~~~~~
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for cffi
Failed to build cffi
ERROR: Could not build wheels for cffi, which is required to install pyproject.toml-based projects
[notice] A new release of pip is available: 23.3.1 -> 23.3.2
[notice] To update, run: pip install --upgrade pip
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
[notice] A new release of pip is available: 23.3.1 -> 23.3.2
[notice] To update, run: pip install --upgrade pip
I see. Trapped in lib version dependencies.
Analysis
...
Collecting python-olm<4.0.0,>=3.1.3 (from matrix-nio[e2e]>=0.14.1->matrix-commander)
Using cached python-olm-3.2.16.tar.gz (2.7 MB)
Installing build dependencies: started
Installing build dependencies: finished with status 'error'
error: subprocess-exited-with-error
...
Matrix Commander brings quite a lot of features. The network io libraries make use of the implementation of the olm and megolm cryptographic ratchets.
- python-olm requires python-cffi and libolm
- python-cffi requires cffi
- python-cffi (and python-cffi-src) are available as package for TurrisOS 6.4.4
- TurrisOS 6.4.4 provides Python3.9
- cffi “latest” has been tested successfully with Python 3.8-3.12
cffi installation
deep dive on building & integrating ffi
Ways out
The aim is to simply push messages onto an matrix channel upon certain os events.
-
modify matrix-commander build configuration to accept python3-cffi based on python3.9 and the libffi installed on turris os.
-
modify turris os, enabling the use of python3.8, hoping for a successful build
-
find a simpler, much more leightweight solution
Simpler solutions
A web web recherche for “lightweight matrix client” pointed towards github topic matrix clients
Candidates:
- GitHub - nadams/go-matrixcli: Interact with matrix servers from the cli
- GitHub - neosam/ruma-client: A Matrix client library for Rust.
- more to find
go-matrixcli
I gave it a try on turris os:
schnapps create “before go-matrixlic”
opkg install gcc golang
# ar is required to have gcc/go-compile believe something about threads.
ar -rc /usr/lib/libpthread.a
go run /srv/matrix-dist/go-matrixcli-master/cmd/matrixcli/ version
go run /srv/matrix-dist/go-matrixcli-master/cmd/matrixcli/ accounts list
go run /srv/matrix-dist/go-matrixcli-master/cmd/matrixcli/ accounts login https://oschat.my.family
Name: jack
Username: jackinthebox2
Password: .....
…
I didn’t succedd with the logon, but this might get caused by the server choosen.
ruma-client
RUMA reaiizes a minimalistic matrix client library providing the features wanted:
- logon into a session
- send messages
As ruma is based on RUST, it has significant smaller memory requirements than a Python application. All you need to do is to implement a little rust program enabling for logon, send and logoff (feel free to implement session caching).
This topic was automatically closed after 60 days. New replies are no longer allowed.