diff --git a/.gitignore b/.gitignore index b6e4761..90ff4d8 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,5 @@ dmypy.json # Pyre type checker .pyre/ +.idea/modules.xml +.idea/ diff --git a/debian/control b/debian/control index 67c8031..cf72184 100644 --- a/debian/control +++ b/debian/control @@ -2,12 +2,12 @@ Source: te-modbus-plugin Section: python Priority: extra Maintainer: Mario Heidenreich -Build-Depends: debhelper (>= 9), dh-virtualenv (>= 0.8) +Build-Depends: debhelper (>= 9.2), dh-virtualenv (>= 0.8) Standards-Version: 3.9.5 Package: te-modbus-plugin Architecture: any -Pre-Depends: dpkg (>= 1.16.1), tedge_agent (>= 0.7.7), python (>= 3.8.0) | python3 (>= 3.8.0), ${misc:Pre-Depends} +Pre-Depends: dpkg (>= 1.16.1), python (>= 3.8.0) | python3 (>= 3.8.0), ${misc:Pre-Depends} Depends: ${misc:Depends} Description: A short summary of what this is. Further indented lines can contain extra information. diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..71a9b15 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e + +#DEBHELPER# + +# Enable the service only if systemctl is available +if command -v systemctl >/dev/null; then + systemctl start te-modbus-plugin.service + systemctl enable te-modbus-plugin.service +fi \ No newline at end of file diff --git a/debian/rules b/debian/rules index 772e002..a8310b8 100644 --- a/debian/rules +++ b/debian/rules @@ -1,6 +1,7 @@ #!/usr/bin/make -f %: - dh $@ --with python-virtualenv + dh $@ --with python-virtualenv --with systemd +#DEBHELPER# diff --git a/debian/te-modbus-plugin.dirs b/debian/te-modbus-plugin.dirs new file mode 100644 index 0000000..6144d22 --- /dev/null +++ b/debian/te-modbus-plugin.dirs @@ -0,0 +1 @@ +var/log/te-modbus-plugin \ No newline at end of file diff --git a/debian/te-modbus-plugin.install b/debian/te-modbus-plugin.install new file mode 100644 index 0000000..17d0ba7 --- /dev/null +++ b/debian/te-modbus-plugin.install @@ -0,0 +1,2 @@ +config/devices.toml etc/tedge/plugins/modbus/ +config/modbus.toml etc/tedge/plugins/modbus/ \ No newline at end of file diff --git a/debian/te-modbus-plugin.links b/debian/te-modbus-plugin.links new file mode 100644 index 0000000..78e2c97 --- /dev/null +++ b/debian/te-modbus-plugin.links @@ -0,0 +1 @@ +opt/venvs/te-modbus-plugin/bin/te-modbus-reader usr/sbin/te-modbus-plugin \ No newline at end of file diff --git a/debian/te-modbus-plugin.service b/debian/te-modbus-plugin.service new file mode 100644 index 0000000..acdc0cd --- /dev/null +++ b/debian/te-modbus-plugin.service @@ -0,0 +1,10 @@ +[Unit] +Description=Modbus Data Reader + +[Service] +User=root +ExecStart=/usr/sbin/te-modbus-plugin -l /var/log/te-modbus-plugin/modbus.log +Restart=on-failure + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7fd26b9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/setup.py b/setup.py index 5d3f2bb..12dc8e4 100644 --- a/setup.py +++ b/setup.py @@ -6,10 +6,10 @@ setup( name='te-modbus-reader', version='0.1', - description='Modbus plugin for ', - url='http://github.com/trstringer/python3-random-quote', + description='Modbus plugin for thin-edge', + url='https://github.com/thin-edge/modbus-plugin', author='Software AG ♥ thin-edge.io', - author_email='github@trstringer.com', + author_email='info@thin-edge.io', license='MIT', install_requires=[ 'paho-mqtt~=1.6.1', @@ -19,6 +19,7 @@ 'tomli~=2.0.1', 'pyserial-asyncio'], packages=find_packages(), + data_files=[('config/devices.toml', ['config/devices.toml']), ('config/modbus.toml', ['config/modbus.toml'])], entry_points=dict( console_scripts=['te-modbus-reader=modbus_reader.reader:main'] ) diff --git a/systemd/te-modbus-plugin.service b/systemd/te-modbus-plugin.service index 1b75b71..acdc0cd 100644 --- a/systemd/te-modbus-plugin.service +++ b/systemd/te-modbus-plugin.service @@ -1,10 +1,9 @@ [Unit] Description=Modbus Data Reader -After=tedge-agent.service [Service] User=root -ExecStart=/usr/bin/python3 /etc/tedge/reader.py +ExecStart=/usr/sbin/te-modbus-plugin -l /var/log/te-modbus-plugin/modbus.log Restart=on-failure [Install]