diff --git a/.fpm b/.fpm index b96e532..f51ab9b 100644 --- a/.fpm +++ b/.fpm @@ -11,3 +11,6 @@ --depends python3-tz --python-disable-dependency pybase64 --depends python3-unpaddedbase64 +--deb-systemd service/sentinel_mrhat_cam.service +--deb-systemd-enable +--deb-systemd-auto-start diff --git a/.github/workflows/python_release.yml b/.github/workflows/python_release.yml deleted file mode 100644 index ef0be11..0000000 --- a/.github/workflows/python_release.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Python release - -on: - push: - tags: - - "v*.*.*" - -jobs: - publish-and-release: - name: Publish and release distributions - - runs-on: ubuntu-latest - - permissions: - contents: write - discussions: write - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Package and publish - uses: EffectiveRange/python-package-github-action@v2 - with: - use-devcontainer: 'true' - container-config: 'amd64-container' - debian-dist-type: 'fpm-deb' - install-packaging-tools: 'false' - - name: Release - uses: EffectiveRange/version-release-github-action@v1 - - diff --git a/.github/workflows/test_and_release.yml b/.github/workflows/test_and_release.yml new file mode 100644 index 0000000..2c22f49 --- /dev/null +++ b/.github/workflows/test_and_release.yml @@ -0,0 +1,60 @@ +name: Test and Release + +on: + push: + branches: main + tags: v*.*.* + + pull_request: + branches: [ "main" ] + types: + - synchronize + - opened + - reopened + +concurrency: + group: ${{ github.workflow }}-${{ github.sha }} + cancel-in-progress: true + +jobs: + test: + name: Build and test + + runs-on: ubuntu-latest + + permissions: + # Gives the action the necessary permissions for publishing new + # comments in pull requests. + pull-requests: write + contents: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Verify changes + uses: EffectiveRange/python-verify-github-action@v1 + with: + coverage-threshold: '0' + + release: + if: startsWith(github.ref, 'refs/tags/') + needs: test + + name: Publish and release + + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: true + - name: Package and publish + uses: EffectiveRange/python-package-github-action@v2 + with: + use-devcontainer: 'true' + container-config: 'amd64-container' + debian-dist-type: 'fpm-deb' + install-packaging-tools: 'false' + - name: Release + uses: EffectiveRange/version-release-github-action@v1 diff --git a/sentinel_mrhat_cam/config.json b/config/config.json similarity index 100% rename from sentinel_mrhat_cam/config.json rename to config/config.json diff --git a/sentinel_mrhat_cam/log_config.yaml b/config/log_config.yaml similarity index 100% rename from sentinel_mrhat_cam/log_config.yaml rename to config/log_config.yaml diff --git a/scripts/daemon.sh b/scripts/daemon.sh deleted file mode 100644 index ba1f8b4..0000000 --- a/scripts/daemon.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -# Define the service file path -SERVICE_FILE="/etc/systemd/system/sentinel_mrhat_cam.service" - -# Create the service file with the necessary content -sudo bash -c "cat > $SERVICE_FILE <=6.0 -Requires-Dist: pillow -Requires-Dist: pytz -Requires-Dist: paho-mqtt -Requires-Dist: numpy -Requires-Dist: pybase64 -Requires-Dist: pdocs diff --git a/sentinel_mrhat_cam/sentinel_mrhat_cam.egg-info/SOURCES.txt b/sentinel_mrhat_cam/sentinel_mrhat_cam.egg-info/SOURCES.txt deleted file mode 100644 index da319ea..0000000 --- a/sentinel_mrhat_cam/sentinel_mrhat_cam.egg-info/SOURCES.txt +++ /dev/null @@ -1,9 +0,0 @@ -README.md -setup.cfg -setup.py -scripts/sentinel_mrhat_cam.sh -sentinel_mrhat_cam/sentinel_mrhat_cam.egg-info/PKG-INFO -sentinel_mrhat_cam/sentinel_mrhat_cam.egg-info/SOURCES.txt -sentinel_mrhat_cam/sentinel_mrhat_cam.egg-info/dependency_links.txt -sentinel_mrhat_cam/sentinel_mrhat_cam.egg-info/requires.txt -sentinel_mrhat_cam/sentinel_mrhat_cam.egg-info/top_level.txt \ No newline at end of file diff --git a/sentinel_mrhat_cam/sentinel_mrhat_cam.egg-info/dependency_links.txt b/sentinel_mrhat_cam/sentinel_mrhat_cam.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/sentinel_mrhat_cam/sentinel_mrhat_cam.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/sentinel_mrhat_cam/sentinel_mrhat_cam.egg-info/requires.txt b/sentinel_mrhat_cam/sentinel_mrhat_cam.egg-info/requires.txt deleted file mode 100644 index da4e3a2..0000000 --- a/sentinel_mrhat_cam/sentinel_mrhat_cam.egg-info/requires.txt +++ /dev/null @@ -1,8 +0,0 @@ -pytest -PyYAML>=6.0 -pillow -pytz -paho-mqtt -numpy -pybase64 -pdocs diff --git a/sentinel_mrhat_cam/sentinel_mrhat_cam.egg-info/top_level.txt b/sentinel_mrhat_cam/sentinel_mrhat_cam.egg-info/top_level.txt deleted file mode 100644 index 8b13789..0000000 --- a/sentinel_mrhat_cam/sentinel_mrhat_cam.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/sentinel_mrhat_cam/static_config.py b/sentinel_mrhat_cam/static_config.py index d445194..b5d1f5b 100644 --- a/sentinel_mrhat_cam/static_config.py +++ b/sentinel_mrhat_cam/static_config.py @@ -2,11 +2,11 @@ import logging # Configuration file paths -SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) -LOG_CONFIG_PATH = os.path.join(SCRIPT_DIR, 'log_config.yaml') -CONFIG_PATH = os.path.join(SCRIPT_DIR, 'config.json') -TEMP_CONFIG_PATH = os.path.join(SCRIPT_DIR, 'temp_config.json') -STATE_FILE_PATH = os.path.join(SCRIPT_DIR, 'state_file.json') +CONFIG_DIR = '/etc/sentinel_mrhat_cam' +LOG_CONFIG_PATH = os.path.join(CONFIG_DIR, 'log_config.yaml') +CONFIG_PATH = os.path.join(CONFIG_DIR, 'config.json') +TEMP_CONFIG_PATH = os.path.join(CONFIG_DIR, 'temp_config.json') +STATE_FILE_PATH = os.path.join(CONFIG_DIR, 'state_file.json') # MQTT Configuration """ BROKER = "192.168.0.105" diff --git a/service/sentinel_mrhat_cam.service b/service/sentinel_mrhat_cam.service new file mode 100644 index 0000000..c6befe2 --- /dev/null +++ b/service/sentinel_mrhat_cam.service @@ -0,0 +1,12 @@ +[Unit] +Description=Run Script Daemon + +[Service] +Type=simple +User=admin +ExecStart=/bin/bash /usr/local/bin/sentinel_mrhat_cam.sh +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target diff --git a/setup.py b/setup.py index b148db0..f5d638b 100644 --- a/setup.py +++ b/setup.py @@ -7,11 +7,7 @@ author='Ferenc Nandor Janky, Attila Gombos, Nyiri Levente, Nyitrai Bence', author_email='info@effective-range.com', packages=find_packages(), - scripts=['scripts/sentinel_mrhat_cam.sh', 'scripts/daemon.sh'], - install_requires=['PyYAML>=6.0', - 'pillow', - 'pytz', - 'paho-mqtt', - 'numpy', - 'pybase64'] + scripts=['scripts/sentinel_mrhat_cam.sh', 'scripts/sentinel_mrhat_cam_main.py'], + data_files=[('config', ['config/config.json', 'config/log_config.yaml'])], + install_requires=['PyYAML>=6.0', 'pillow', 'pytz', 'paho-mqtt', 'numpy', 'pybase64'], )