Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CPCLOUD-4591] Build debian package #71

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ env.python-version }}
- 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 agent360-${{ GITHUB_SHA }}.deb
- name: Install debian package
run: dpkg -i agent360-${{ github.ref }}.deb
- uses: actions/upload-artifact@v4
with:
name: debian package
path: agent360.deb-${{ github.ref_name }}
- name: Install pypa/build
run: >-
python -m
Expand Down
11 changes: 11 additions & 0 deletions packager/debian/DEBIAN/agent360.service
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions packager/debian/DEBIAN/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh -e

. /usr/share/debconf/confmodule

db_input high agent360/user || :
db_go
20 changes: 20 additions & 0 deletions packager/debian/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Version: 1.3.1
Source: agent360
Section: net
Priority: extra
Maintainer: 360 monitoring <[email protected]>
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.
25 changes: 25 additions & 0 deletions packager/debian/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh -e

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
9 changes: 9 additions & 0 deletions packager/debian/DEBIAN/preinst
Original file line number Diff line number Diff line change
@@ -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