This commit is contained in:
parent
47b5ae14af
commit
f84419de0d
7 changed files with 87 additions and 3 deletions
25
Makefile
25
Makefile
|
@ -1,15 +1,34 @@
|
||||||
.PHONY: all client server
|
.PHONY: all client server
|
||||||
|
|
||||||
|
BUILDDIR?=./build
|
||||||
|
VERSION?=$(shell echo "$$(date +'%Y%m%d')-$$(git rev-parse --short=8 HEAD)")
|
||||||
|
|
||||||
all: client server
|
all: client server
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf ./build
|
rm -rf $(BUILDDIR)
|
||||||
|
|
||||||
client:
|
client:
|
||||||
go build -o ./build/client ./cmd/client
|
go build -o $(BUILDDIR)/client ./cmd/client
|
||||||
|
|
||||||
server:
|
server:
|
||||||
go build -o ./build/server ./cmd/server
|
go build -o $(BUILDDIR)/server ./cmd/server
|
||||||
|
|
||||||
test:
|
test:
|
||||||
go test -v ./...
|
go test -v ./...
|
||||||
|
|
||||||
|
debpkg_server_prepare: server
|
||||||
|
rm -rf $(BUILDDIR)/debpkg
|
||||||
|
mkdir -p $(BUILDDIR)/debpkg/usr/bin $(BUILDDIR)/debpkg/DEBIAN $(BUILDDIR)/debpkg/etc/systemd/system $(BUILDDIR)/debpkg/etc/sys-exporter
|
||||||
|
install -m 755 -o root -g root $(BUILDDIR)/server $(BUILDDIR)/debpkg/usr/bin/
|
||||||
|
install -m 644 -o root -g root debian/sys-exporter/etc/systemd/system/sys-exporter.service $(BUILDDIR)/debpkg/etc/systemd/system/
|
||||||
|
install -m 644 -o root -g root debian/sys-exporter/etc/sys-exporter/config.yml $(BUILDDIR)/debpkg/etc/sys-exporter/
|
||||||
|
install -m 644 -o root -g root debian/sys-exporter/control $(BUILDDIR)/debpkg/DEBIAN/control
|
||||||
|
install -m 755 -o root -g root debian/sys-exporter/postinst $(BUILDDIR)/debpkg/DEBIAN/postinst
|
||||||
|
|
||||||
|
debpkg_server: debpkg_server_prepare
|
||||||
|
dpkg-deb --build $(BUILDDIR)/debpkg/ $(BUILDDIR)/sys-exporter.deb
|
||||||
|
|
||||||
|
debpkg_server_docker: server
|
||||||
|
docker build -t debian-builder ./debian/tools
|
||||||
|
docker run -t -e PACKAGE_VERSION="$(VERSION)" -v $(BUILDDIR):/build/ -v ./debian:/debian debian-builder
|
||||||
|
|
5
debian/sys-exporter/control
vendored
Normal file
5
debian/sys-exporter/control
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
Package: sys-exporter
|
||||||
|
Version: ${PACKAGE_VERSION}
|
||||||
|
Architecture: amd64
|
||||||
|
Maintainer: Melora Hugues <dev@faercol.me>
|
||||||
|
Description: System information exporter
|
7
debian/sys-exporter/etc/sys-exporter/config.yml
vendored
Normal file
7
debian/sys-exporter/etc/sys-exporter/config.yml
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
logging:
|
||||||
|
level: info
|
||||||
|
collectors:
|
||||||
|
- system.loadavg
|
||||||
|
- system.meminfo
|
||||||
|
- services.systemd
|
||||||
|
- system.uptime
|
16
debian/sys-exporter/etc/systemd/system/sys-exporter.service
vendored
Normal file
16
debian/sys-exporter/etc/systemd/system/sys-exporter.service
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
[Unit]
|
||||||
|
Description=System information exporter daemon
|
||||||
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
|
StartLimitIntervalSec=0
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/usr/bin/sys-exporter
|
||||||
|
TimeoutStartSec=10
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=60s
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
RequiredBy=multi-user.target
|
4
debian/sys-exporter/postinst
vendored
Normal file
4
debian/sys-exporter/postinst
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
systemctl enable sys-exporter.service
|
||||||
|
systemctl start sys-exporter.service
|
16
debian/tools/Dockerfile
vendored
Normal file
16
debian/tools/Dockerfile
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
FROM debian:bookworm
|
||||||
|
|
||||||
|
RUN set -ex \
|
||||||
|
&& sed -i -- 's/Types: deb/Types: deb deb-src/g' /etc/apt/sources.list.d/debian.sources \
|
||||||
|
&& apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
build-essential \
|
||||||
|
cdbs \
|
||||||
|
devscripts \
|
||||||
|
equivs \
|
||||||
|
fakeroot \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /tmp/* /var/tmp/*
|
||||||
|
|
||||||
|
COPY build.sh /root/
|
||||||
|
ENTRYPOINT [ "/root/build.sh" ]
|
17
debian/tools/build.sh
vendored
Executable file
17
debian/tools/build.sh
vendored
Executable file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
|
rm -rf /build/debpkg
|
||||||
|
mkdir -p /build/debpkg/usr/bin /build/debpkg/DEBIAN /build/debpkg/etc/systemd/system /build/debpkg/etc/sys-exporter
|
||||||
|
install -m 755 -o root -g root /build/server /build/debpkg/usr/bin/
|
||||||
|
install -m 644 -o root -g root /debian/sys-exporter/etc/systemd/system/sys-exporter.service /build/debpkg/etc/systemd/system/
|
||||||
|
install -m 644 -o root -g root /debian/sys-exporter/etc/sys-exporter/config.yml /build/debpkg/etc/sys-exporter/
|
||||||
|
install -m 644 -o root -g root /debian/sys-exporter/control /build/debpkg/DEBIAN/control
|
||||||
|
install -m 755 -o root -g root /debian/sys-exporter/postinst /build/debpkg/DEBIAN/postinst
|
||||||
|
|
||||||
|
envsubst < /debian/sys-exporter/control > /build/debpkg/DEBIAN/control
|
||||||
|
|
||||||
|
dpkg-deb --build /build/debpkg/ /build/sys-exporter.deb
|
Loading…
Reference in a new issue