]> git.michaelhowe.org Git - packages/p/promtail.git/commitdiff
Initial packaging of promtail
authorMichael Howe <michael@michaelhowe.org>
Fri, 10 Mar 2023 10:20:52 +0000 (10:20 +0000)
committerMichael Howe <michael@michaelhowe.org>
Fri, 10 Mar 2023 10:20:52 +0000 (10:20 +0000)
19 files changed:
Makefile [new file with mode: 0644]
conf/config.yml [new file with mode: 0644]
debian/README.Debian [new file with mode: 0644]
debian/README.source [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/copyright [new file with mode: 0644]
debian/postinst [new file with mode: 0644]
debian/postrm [new file with mode: 0644]
debian/preinst [new file with mode: 0644]
debian/promtail-docs.docs [new file with mode: 0644]
debian/promtail.service [new file with mode: 0644]
debian/rules [new file with mode: 0755]
debian/source/format [new file with mode: 0644]
download/promtail-linux-amd64-v2.7.4.zip [new file with mode: 0644]
download/promtail-linux-arm-v2.7.4.zip [new file with mode: 0644]
extract/promtail-linux-amd64 [new file with mode: 0755]
extract/promtail-linux-arm [new file with mode: 0755]
update-version [new file with mode: 0755]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..fc87836
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,18 @@
+
+prefix = /usr
+
+# do some juggling to account for arm/armhf differences in names
+BUILDARCH_amd64 = amd64
+BUILDARCH_armhf = arm
+BUILDARCH = ${BUILDARCH_${DEB_BUILD_ARCH}}
+
+build:
+       # no-op
+clean:
+       # no-op
+
+install:
+       install --mode 0644 -D conf/config.yml $(DESTDIR)/etc/promtail/config.yml
+       install -D extract/promtail-linux-$(BUILDARCH) $(DESTDIR)$(prefix)/bin/promtail
+
+.PHONY: install
diff --git a/conf/config.yml b/conf/config.yml
new file mode 100644 (file)
index 0000000..354a3e2
--- /dev/null
@@ -0,0 +1,19 @@
+#
+server:
+  http_listen_port: 9080
+  grpc_listen_port: 0
+
+positions:
+  filename: /var/lib/promtail/positions.yaml
+
+clients:
+  - url: http://localhost:3100/loki/api/v1/push
+
+scrape_configs:
+- job_name: system
+  static_configs:
+  - targets:
+      - localhost
+    labels:
+      job: varlogs
+      __path__: /var/log/*log
diff --git a/debian/README.Debian b/debian/README.Debian
new file mode 100644 (file)
index 0000000..14a7416
--- /dev/null
@@ -0,0 +1,7 @@
+promtail for Debian
+------------------
+
+Hack of a package based on downloading binaries from github rather than
+building them ourselves.  Not to be published.
+
+ -- Michael Howe <michael@michaelhowe.org>  Tue, 28 Feb 2023 21:09:36 +0000
diff --git a/debian/README.source b/debian/README.source
new file mode 100644 (file)
index 0000000..9271e24
--- /dev/null
@@ -0,0 +1,17 @@
+promtail for Debian
+------------------
+
+Use update-version <version_number> to download the new version, then bump the
+changelog as appropriate and build for relevant architectures (probably amd64
+and armhf).
+
+Build for each architecture, then (where $ARMDIR contains the armhf build
+files, and $AMD64DIR the amd64 build):
+cp $ARMDIR/*armhf* $AMD64DIR
+cd $AMD64DIR
+# merge changes with something like:
+mergechanges promtail_2.7.4+internal.0_source.changes promtail_2.7.4+internal.0_armhf.changes promtail_2.7.4+internal.0_amd64.changes > promtail_2.7.4+internal.0_combined.changes
+debsign promtail_2.7.4+internal.0_combined.changes
+
+ -- Michael Howe <michael@michaelhowe.org>  Tue, 28 Feb 2023 21:09:36 +0000
+
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..50dfe8f
--- /dev/null
@@ -0,0 +1,5 @@
+promtail (2.7.4+internal.0) unstable; urgency=medium
+
+  * Initial Release.
+
+ -- Michael Howe <michael@michaelhowe.org>  Tue, 28 Feb 2023 21:09:36 +0000
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..43bd984
--- /dev/null
@@ -0,0 +1,20 @@
+Source: promtail
+Section: admin
+Priority: optional
+Maintainer: Michael Howe <michael@michaelhowe.org>
+Build-Depends: debhelper-compat (= 13)
+Standards-Version: 4.5.1
+Homepage: https://grafana.com/docs/loki/latest/clients/promtail/
+#Vcs-Browser: https://salsa.debian.org/debian/promtail
+#Vcs-Git: https://salsa.debian.org/debian/promtail.git
+Rules-Requires-Root: no
+
+Package: promtail
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
+Description: Agent which ships the contents of local logs to a Loki instance
+ Promtail is an agent which ships the contents of local logs to a private
+ Grafana Loki instance or Grafana Cloud.
+ .
+ It is usually deployed to every machine that has applications needed to be
+ monitored.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..c9e5972
--- /dev/null
@@ -0,0 +1,12 @@
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: promtail
+Upstream-Contact: https://github.com/grafana/loki
+Source: https://github.com/grafana/loki
+
+Files: *
+Copyright: 2020-2023 Grafana Labs
+License: AGPL-3.0+
+
+Files: debian/*
+Copyright: 2023 Michael Howe <michael@michaelhowe.org>
+License: GPL-3.0+
diff --git a/debian/postinst b/debian/postinst
new file mode 100644 (file)
index 0000000..67cab6d
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/sh
+# postinst script for promtail
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <postinst> `abort-remove'
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see https://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    configure)
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/postrm b/debian/postrm
new file mode 100644 (file)
index 0000000..8d7f8ea
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/sh
+# postrm script for promtail
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postrm> `remove'
+#        * <postrm> `purge'
+#        * <old-postrm> `upgrade' <new-version>
+#        * <new-postrm> `failed-upgrade' <old-version>
+#        * <new-postrm> `abort-install'
+#        * <new-postrm> `abort-install' <old-version>
+#        * <new-postrm> `abort-upgrade' <old-version>
+#        * <disappearer's-postrm> `disappear' <overwriter>
+#          <overwriter-version>
+# for details, see https://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+    ;;
+
+    purge)
+        SERVER_HOME=/var/lib/promtail
+        SERVER_GROUP=promtail
+        SERVER_USER=promtail
+        if getent passwd | grep -q "^$SERVER_USER:"; then
+            deluser --system promtail
+        fi
+        if getent group | grep -q "^$SERVER_GROU:"; then
+            delgroup --system "$SERVER_GROUP"
+        fi
+        if [ -d "$SERVER_HOME" ]; then
+            rm -rf "$SERVER_HOME"
+        fi
+    ;;
+    *)
+        echo "postrm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/preinst b/debian/preinst
new file mode 100644 (file)
index 0000000..87557c6
--- /dev/null
@@ -0,0 +1,77 @@
+#!/bin/sh
+# preinst script for promtail
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <new-preinst> `install'
+#        * <new-preinst> `install' <old-version>
+#        * <new-preinst> `upgrade' <old-version>
+#        * <old-preinst> `abort-upgrade' <new-version>
+# for details, see https://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    install|upgrade)
+        ADDGROUP="adm"
+        [ -z "$SERVER_HOME" ] && SERVER_HOME=/var/lib/promtail
+        [ -z "$SERVER_USER" ] && SERVER_USER=promtail
+        [ -z "$SERVER_NAME" ] && SERVER_NAME="Promtail User"
+        [ -z "$SERVER_GROUP" ] && SERVER_GROUP=promtail
+        # 1. create group if it doesn't exist
+        if ! getent group | grep -q "^$SERVER_GROUP:"; then
+            echo -n "Adding group $SERVER_GROUP.."
+            addgroup --quiet --system "$SERVER_GROUP" 2>/dev/null || true
+            echo "..done"
+        fi
+        # 2. create homedir if it doesn't exist
+        test -d "$SERVER_HOME" || mkdir -p "$SERVER_HOME"
+        # 3. create user if it doesn't exist
+        if ! getent passwd | grep -q "^$SERVER_USER:"; then
+            echo -n "Adding system user $SERVER_USER.."
+            adduser --quiet \
+                    --system \
+                    --ingroup "$SERVER_GROUP" \
+                    --home "$SERVER_HOME" \
+                    --no-create-home \
+                    --disabled-password \
+                    "$SERVER_USER" 2>/dev/null || true
+            echo "..done"
+        fi
+        # 4. adjust passwd entry
+        usermod -c "$SERVER_NAME" \
+                -d "$SERVER_HOME" \
+                -g "$SERVER_GROUP" \
+                "$SERVER_USER"
+        # 5. adjust file and directory permissions
+        if ! dpkg-statoverride --list "$SERVER_HOME" >/dev/null; then
+            chown "$SERVER_USER":"$SERVER_GROUP" "$SERVER_HOME"
+            chmod 0750 "$SERVER_HOME"
+        fi
+        # 6. add user to ADDGROUP group
+        if test -n "$ADDGROUP"; then
+            if ! groups "$SERVER_USER" | cut -d: -f2 | \
+                grep -qw "^$ADDGROUP"; then
+                    adduser "$SERVER_USER" "$ADDGROUP"
+            fi
+        fi
+    ;;
+
+    abort-upgrade)
+    ;;
+
+    *)
+        echo "preinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/promtail-docs.docs b/debian/promtail-docs.docs
new file mode 100644 (file)
index 0000000..efea0a6
--- /dev/null
@@ -0,0 +1,2 @@
+README.Debian
+README.source
diff --git a/debian/promtail.service b/debian/promtail.service
new file mode 100644 (file)
index 0000000..7f971b5
--- /dev/null
@@ -0,0 +1,15 @@
+[Unit]
+Description=Promtail service
+After=network.target
+
+[Service]
+Type=simple
+User=promtail
+ExecStart=/usr/bin/promtail -config.file /etc/promtail/config.yml
+# Give a reasonable amount of time for promtail to start up/shut down
+TimeoutSec=60
+Restart=on-failure
+RestartSec=2
+
+[Install]
+WantedBy=multi-user.target
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..95db21a
--- /dev/null
@@ -0,0 +1,8 @@
+#!/usr/bin/make -f
+# See debhelper(7) (uncomment to enable)
+# output every command that modifies files on the build system.
+#export DH_VERBOSE = 1
+
+
+%:
+       dh $@
diff --git a/debian/source/format b/debian/source/format
new file mode 100644 (file)
index 0000000..89ae9db
--- /dev/null
@@ -0,0 +1 @@
+3.0 (native)
diff --git a/download/promtail-linux-amd64-v2.7.4.zip b/download/promtail-linux-amd64-v2.7.4.zip
new file mode 100644 (file)
index 0000000..e036ee7
Binary files /dev/null and b/download/promtail-linux-amd64-v2.7.4.zip differ
diff --git a/download/promtail-linux-arm-v2.7.4.zip b/download/promtail-linux-arm-v2.7.4.zip
new file mode 100644 (file)
index 0000000..a1e696e
Binary files /dev/null and b/download/promtail-linux-arm-v2.7.4.zip differ
diff --git a/extract/promtail-linux-amd64 b/extract/promtail-linux-amd64
new file mode 100755 (executable)
index 0000000..842dfc8
Binary files /dev/null and b/extract/promtail-linux-amd64 differ
diff --git a/extract/promtail-linux-arm b/extract/promtail-linux-arm
new file mode 100755 (executable)
index 0000000..78aecc8
Binary files /dev/null and b/extract/promtail-linux-arm differ
diff --git a/update-version b/update-version
new file mode 100755 (executable)
index 0000000..f33d391
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+set -e
+set -u
+
+# eg v2.7.4
+VER=$1
+
+ARCHES=('amd64' 'arm')
+
+mkdir -p extract/
+mkdir -p download/
+
+for arch in "${ARCHES[@]}"; do
+    DOWNLOAD_URL="https://github.com/grafana/loki/releases/download/${VER}/promtail-linux-${arch}.zip"
+    ZIPFILE="download/promtail-linux-${arch}-${VER}.zip"
+    wget -O "${ZIPFILE}" "${DOWNLOAD_URL}"
+    unzip "${ZIPFILE}" -d extract/
+done