diff --git a/.github/workflows/build-deb-package.yml b/.github/workflows/build-deb-package.yml new file mode 100644 index 00000000..13e203c1 --- /dev/null +++ b/.github/workflows/build-deb-package.yml @@ -0,0 +1,48 @@ +name: Build Debian Package +# Check status: systemctl status changedetection.io.service +# Get logs: journalctl -u changedetection.io.service +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +jobs: + build-deb: + runs-on: ubuntu-latest + name: Build and Package changedetection.io + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Python 3.8 + uses: actions/setup-python@v4 + with: + python-version: '3.8' + + - name: Install Build Dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + build-essential \ + devscripts \ + dh-virtualenv \ + dh-python \ + python3-all \ + python3-all-dev \ + python3.10 \ + python3.10-venv \ + python3.10-dev \ + debhelper-compat + + - name: Build the Debian Package + run: | + debuild -us -uc + + - name: Upload Debian Package Artifact + uses: actions/upload-artifact@v3 + with: + name: changedetection.io-deb-package + path: ../*.deb diff --git a/changedetectionio/__main__.py b/changedetectionio/__main__.py new file mode 100644 index 00000000..c7c70d0b --- /dev/null +++ b/changedetectionio/__main__.py @@ -0,0 +1,4 @@ +from . import main + +if __name__ == '__main__': + main() diff --git a/debian/.debhelper/generated/changedetection.io/installed-by-dh_install b/debian/.debhelper/generated/changedetection.io/installed-by-dh_install new file mode 100644 index 00000000..8d6095dc --- /dev/null +++ b/debian/.debhelper/generated/changedetection.io/installed-by-dh_install @@ -0,0 +1 @@ +./debian/changedetection.io.service diff --git a/debian/.debhelper/generated/changedetection.io/installed-by-dh_installdocs b/debian/.debhelper/generated/changedetection.io/installed-by-dh_installdocs new file mode 100644 index 00000000..e69de29b diff --git a/debian/changedetection.io.service b/debian/changedetection.io.service new file mode 100644 index 00000000..bb8de000 --- /dev/null +++ b/debian/changedetection.io.service @@ -0,0 +1,13 @@ +[Unit] +Description=changedetection.io Service +After=network.target + +[Service] +User=changedetio +Group=changedetio +WorkingDirectory=/opt/changedetection.io +ExecStart=/opt/changedetection.io/bin/python -m changedetectionio +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/debian/changedetection.io/lib/systemd/system/changedetection.io.service b/debian/changedetection.io/lib/systemd/system/changedetection.io.service new file mode 100644 index 00000000..bb8de000 --- /dev/null +++ b/debian/changedetection.io/lib/systemd/system/changedetection.io.service @@ -0,0 +1,13 @@ +[Unit] +Description=changedetection.io Service +After=network.target + +[Service] +User=changedetio +Group=changedetio +WorkingDirectory=/opt/changedetection.io +ExecStart=/opt/changedetection.io/bin/python -m changedetectionio +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/debian/changedetection.io/usr/share/doc/changedetection.io/changelog.Debian b/debian/changedetection.io/usr/share/doc/changedetection.io/changelog.Debian new file mode 100644 index 00000000..e9265678 --- /dev/null +++ b/debian/changedetection.io/usr/share/doc/changedetection.io/changelog.Debian @@ -0,0 +1,5 @@ +changedetection.io (1.0-1) unstable; urgency=medium + + * Initial release. + + -- Your Name Wed, 01 Nov 2023 12:00:00 +0000 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 00000000..e9265678 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +changedetection.io (1.0-1) unstable; urgency=medium + + * Initial release. + + -- Your Name Wed, 01 Nov 2023 12:00:00 +0000 diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..f0f9c488 --- /dev/null +++ b/debian/control @@ -0,0 +1,14 @@ +Source: changedetection.io +Section: web +Priority: optional +Maintainer: Your Name +Build-Depends: debhelper-compat (= 13), dh-virtualenv, dh-python, python3-all (>= 3.10), python3-all (<< 3.13), python3.10, python3.10-venv +Standards-Version: 4.6.0 +Rules-Requires-Root: no +Homepage: https://github.com/dgtlmoon/changedetection.io + +Package: changedetection.io +Architecture: all +Depends: ${misc:Depends}, python3 (>= 3.10), python3 (<< 3.13) +Description: Web page change detection - Python application + A web-based application for monitoring web pages for changes. \ No newline at end of file diff --git a/debian/debhelper-build-stamp b/debian/debhelper-build-stamp new file mode 100644 index 00000000..b1ec0d88 --- /dev/null +++ b/debian/debhelper-build-stamp @@ -0,0 +1 @@ +changedetection.io diff --git a/debian/install b/debian/install new file mode 100644 index 00000000..9ba3bb64 --- /dev/null +++ b/debian/install @@ -0,0 +1 @@ +debian/changedetection.io.service lib/systemd/system/ diff --git a/debian/postinst b/debian/postinst new file mode 100755 index 00000000..8aac5aed --- /dev/null +++ b/debian/postinst @@ -0,0 +1,23 @@ +#!/bin/sh +set -e + +# Determine Python version +PYTHON_VERSION=$(ls /usr/bin/python3.1[0-2] | head -n1 | xargs basename) + +# Create 'changedetio' user if it doesn't exist +if ! id "changedetio" >/dev/null 2>&1; then + adduser --system --group --no-create-home changedetio +fi + +# Set ownership of the installation directory +chown -R changedetio:changedetio /opt/changedetection.io + +# Update the systemd service file if necessary +sed -i "s|ExecStart=.*|ExecStart=/opt/changedetection.io/bin/$PYTHON_VERSION -m changedetectionio|" /lib/systemd/system/changedetection.io.service + +# Enable and start the service +systemctl daemon-reload +systemctl enable changedetection.io.service +systemctl start changedetection.io.service + +exit 0 \ No newline at end of file diff --git a/debian/postrm b/debian/postrm new file mode 100755 index 00000000..0cf85ff2 --- /dev/null +++ b/debian/postrm @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +# Remove user on purge +if [ "$1" = "purge" ]; then + deluser --system changedetio +fi + +systemctl daemon-reload + +exit 0 diff --git a/debian/prerm b/debian/prerm new file mode 100755 index 00000000..5ae480f9 --- /dev/null +++ b/debian/prerm @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +# Stop and disable the service +systemctl stop changedetection.io.service +systemctl disable changedetection.io.service + +exit 0 diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000..daccd392 --- /dev/null +++ b/debian/rules @@ -0,0 +1,12 @@ +#!/usr/bin/make -f + +%: + dh $@ --with python-virtualenv --buildsystem=pybuild + +PYTHON_VERSION := $(shell py3versions -r '>= 3.10 << 3.13' -i) + +override_dh_virtualenv: + dh_virtualenv --sourcedirectory=. \ + --install-suffix='' \ + --requirements=requirements.txt \ + --python=/usr/bin/$(PYTHON_VERSION) \ No newline at end of file