commit c228229c0b84da47d87db66528ac8caed2bc0d81 Author: Knut Ahlers Date: Wed Dec 13 11:46:11 2023 +0100 Initial setup diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..c113aef --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,34 @@ +# Maintainer: Knut Ahlers + +pkgname=vault-user-token +pkgver=0.6.2 +pkgrel=1 +pkgdesc="Constantly renew a Vault token derived from a role id" +arch=('i686' 'x86_64') +url="https://github.com/Luzifer/$pkgname" +license=('Apache') +makedepends=('go') +source=( + "${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz" + "vault-user-token.service" +) +sha512sums=('8009183ffcc28ea7362868536b0df866d71ca394fe706cb23eadfaa6c6c0acfec817257d64ea37a1059af91aaf4ae4776949866d7a9f885941c815a4cbd03071') + +build() { + export GO111MODULE=on + export GOPATH="${srcdir}/go" + + cd "${srcdir}/${pkgname}-${pkgver}" + + go build -a -v \ + -ldflags="-s -w -X main.version=${pkgver}" \ + -mod=readonly \ + -o "${srcdir}/${pkgname}" + + go clean -modcache +} + +package() { + install -Dm755 "${srcdir}/${pkgname}" "${pkgdir}/usr/bin/${pkgname}" + install -Dm644 "${srcdir}/vault-user-token.service" "${pkgdir}/usr/lib/systemd/user/vault-user-token.service" +} diff --git a/update_version.sh b/update_version.sh new file mode 100755 index 0000000..45e0a30 --- /dev/null +++ b/update_version.sh @@ -0,0 +1,31 @@ +#!/bin/bash +set -euxo pipefail + +# Read pkg name +PKG=$(awk -F '=' '/pkgname=/{ print $2 }' PKGBUILD) + +# Get latest version +VER=$(curl -sSfL "https://lv.luzifer.io/v1/catalog/vault-user-token/latest/version") + +# Insert latest version into PKGBUILD +sed -i \ + -e "s/^pkgver=.*/pkgver=${VER}/" \ + PKGBUILD + +# Check whether this changed anything +if (git diff --exit-code PKGBUILD); then + echo "Package ${PKG} has most recent version ${VER}" + exit 0 +fi + +# Reset pkgrel +sed -i \ + -e 's/pkgrel=.*/pkgrel=1/' \ + PKGBUILD + +# Update source hashes +updpkgsums + +# Commit changes +git add PKGBUILD +git commit -m "${PKG} v${VER}" diff --git a/vault-user-token.service b/vault-user-token.service new file mode 100644 index 0000000..3f5c827 --- /dev/null +++ b/vault-user-token.service @@ -0,0 +1,11 @@ +[Unit] +Description=Service to renew local vault token + +[Service] +EnvironmentFile=%h/.config/vault-user-token.env +ExecStart=/usr/bin/vault-user-token --log-level=debug --full-hostname=false +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=default.target