diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..62179a9 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,17 @@ +name: Agent360-Build-Packages + +on: + push: + +jobs: + build-debian: + # needs: tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Copy source files + run: mkdir -p packager/debian/usr/bin; cp -r agent360 packager/debian/usr/bin/agent360 + - name: Build debian package + run: dpkg-deb --build packager/debian dist/agent360.deb + - name: Install debian package + run: dpkg -i dist/agent360.deb \ No newline at end of file diff --git a/packager/debian/DEBIAN/agent360.service b/packager/debian/DEBIAN/agent360.service new file mode 100755 index 0000000..940fff1 --- /dev/null +++ b/packager/debian/DEBIAN/agent360.service @@ -0,0 +1,11 @@ +[Unit] +Description=360monitoring agent +After=network.target + +[Service] +ExecStart=/usr/bin/agent360/agent360.py +Restart=always +User=agent360 + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/packager/debian/DEBIAN/config b/packager/debian/DEBIAN/config new file mode 100755 index 0000000..65f93bf --- /dev/null +++ b/packager/debian/DEBIAN/config @@ -0,0 +1,6 @@ +#!/bin/sh -e + +. /usr/share/debconf/confmodule + +db_input high agent360/user || : +db_go diff --git a/packager/debian/DEBIAN/control b/packager/debian/DEBIAN/control new file mode 100755 index 0000000..1165309 --- /dev/null +++ b/packager/debian/DEBIAN/control @@ -0,0 +1,20 @@ +Version: 1.3.1 +Source: agent360 +Section: net +Priority: extra +Maintainer: 360 monitoring <360support@webpros.com> +Build-Depends: debhelper (>=9), + python-all +Standards-Version: 3.9.5 +Homepage: https://github.com/plesk/agent360 +X-Python-Version: >= 2.6 +Package: agent360 +Architecture: amd64 +Multi-Arch: foreign +Description: 360monitoring agent + 360monitoring.com offers a web service of monitoring and displaying + your server performance statistics. + . + This software is an OS-agnostic agent. + It’s been optimized to have a very small CPU footprint and comes with + an extendable set of useful plugins. diff --git a/packager/debian/DEBIAN/postinst b/packager/debian/DEBIAN/postinst new file mode 100755 index 0000000..172a13b --- /dev/null +++ b/packager/debian/DEBIAN/postinst @@ -0,0 +1,43 @@ +#!/bin/sh -e + +. /usr/share/debconf/confmodule + +TOKEN=/etc/agent360-token.ini + +db_get agent360/user +[ -n "$RET" ] && USERID="$RET" + + +if [ -n "$USERID" ]; then + agent360 hello $USERID /etc/agent360-token.ini +else + echo 'Generic "hello" is not implemented' +fi + +if which pycompile >/dev/null 2>&1; then + pycompile -p agent360 +fi + +if [ "$(grep -c '^agent360:' /etc/passwd)" = "0" ]; then + echo "Creating user and group agent360" + addgroup --quiet --system agent360 && adduser --quiet --system --disabled-password --no-create-home --gecos "agent360 daemon" --group agent360 +else + echo "User creation skipped, user is already present" +fi + +deb-systemd-helper unmask agent360.service >/dev/null || true + +if deb-systemd-helper --quiet was-enabled agent360.service; then + # Enables the unit on first installation, creates new + # symlinks on upgrades if the unit file has changed. + deb-systemd-helper enable agent360.service >/dev/null || true +else + # Update the state file to add new symlinks (if any), which need to be + # cleaned up on purge. Also remove old symlinks. + deb-systemd-helper update-state agent360.service >/dev/null || true +fi + +if [ -d /run/systemd/system ]; then + systemctl --system daemon-reload >/dev/null || true + deb-systemd-invoke start agent360.service >/dev/null || true +fi diff --git a/packager/debian/DEBIAN/preinst b/packager/debian/DEBIAN/preinst new file mode 100755 index 0000000..c819308 --- /dev/null +++ b/packager/debian/DEBIAN/preinst @@ -0,0 +1,9 @@ +#!/bin/sh -e + +case "$1" in + install|upgrade) + touch /var/log/agent360.log && chmod a+w /var/log/agent360.log + ;; + *) + ;; +esac \ No newline at end of file