--- /dev/null
+
+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
--- /dev/null
+#
+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
--- /dev/null
+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
--- /dev/null
+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
+
--- /dev/null
+promtail (2.7.4+internal.0) unstable; urgency=medium
+
+ * Initial Release.
+
+ -- Michael Howe <michael@michaelhowe.org> Tue, 28 Feb 2023 21:09:36 +0000
--- /dev/null
+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.
--- /dev/null
+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+
--- /dev/null
+#!/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
--- /dev/null
+#!/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
--- /dev/null
+#!/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
--- /dev/null
+README.Debian
+README.source
--- /dev/null
+[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
--- /dev/null
+#!/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 $@
--- /dev/null
+3.0 (native)
--- /dev/null
+#!/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