Skip to content

Commit

Permalink
[CPCLOUD-4591] Build debian package
Browse files Browse the repository at this point in the history
  • Loading branch information
skafandri committed Oct 30, 2024
1 parent bc65185 commit 0b87e7f
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 0 deletions.
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
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.
43 changes: 43 additions & 0 deletions packager/debian/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -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
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

0 comments on commit 0b87e7f

Please sign in to comment.