From 60f3c3cc3213c3716352cd6f77e3a219b3907463 Mon Sep 17 00:00:00 2001 From: Giovanni Harting <539@idlegandalf.com> Date: Sat, 20 Nov 2021 17:18:13 +0100 Subject: [PATCH] added listmonk --- listmonk/PKGBUILD | 67 +++++++++++++++++++++++++++++++++++++++ listmonk/listmonk.conf | 1 + listmonk/listmonk.install | 40 +++++++++++++++++++++++ listmonk/listmonk.service | 16 ++++++++++ 4 files changed, 124 insertions(+) create mode 100644 listmonk/PKGBUILD create mode 100644 listmonk/listmonk.conf create mode 100644 listmonk/listmonk.install create mode 100644 listmonk/listmonk.service diff --git a/listmonk/PKGBUILD b/listmonk/PKGBUILD new file mode 100644 index 0000000..839894c --- /dev/null +++ b/listmonk/PKGBUILD @@ -0,0 +1,67 @@ +# Maintainer: Caleb Maclennan + +pkgname=listmonk +pkgver=2.0.0 +pkgrel=1 +pkgdesc='Self-hosted newsletter and mailing list manager with a modern dashboard' +arch=(x86_64) +url=https://listmonk.app +license=(AGPL3) +depends=(postgresql) +makedepends=(go node-gyp nodejs yarn) +backup=(etc/listmonk/config.toml) +install=$pkgname.install +source=("$pkgname-$pkgver.tar.gz::https://github.com/knadh/$pkgname/archive/v$pkgver.tar.gz" + "$pkgname.conf" + "$pkgname.service") +sha256sums=('8ec73d9ee65dd0f1c5f7a2453982692e34a5eaa588eb05d0ec30afc0635b033f' + '5cfc186438df2408ed88a5bec3a9a4b5f2afb0d3aec41c4cc63b2f5eb810b3cb' + '809ede70c932183889b2fa567b340fb82cce1ada76c7b0a0b9efb82b87c92fa0') + +prepare() { + cd "$pkgname-$pkgver/frontend" + export YARN_CACHE_FOLDER="$srcdir/node_modules" + yarn install --frozen-lockfile +} + +build() { + cd "$pkgname-$pkgver" + + export CGO_CPPFLAGS="${CPPFLAGS}" + export CGO_CFLAGS="${CFLAGS}" + export CGO_CXXFLAGS="${CXXFLAGS}" + + go build \ + -trimpath \ + -buildmode=pie \ + -mod=readonly \ + -modcacherw \ + -ldflags "-extldflags '$LDFLAGS' -X 'main.buildString=Arch Linux AUR v$pkgver-$pkgrel' -X 'main.versionString=v$pkgver'" \ + -o $pkgname \ + cmd/*.go + export YARN_CACHE_FOLDER="$srcdir/node_modules" + export VUE_APP_VERSION="v$pkgver" + pushd frontend + yarn build +} + +check() { + cd "$pkgname-$pkgver" + go test ./... +} + +package() { + cd "$pkgname-$pkgver" + install -Dm755 -t "$pkgdir/usr/bin" $pkgname + install -Dm644 config.toml.sample "$pkgdir/etc/$pkgname/config.toml" + install -Dm644 -t "$pkgdir/usr/lib/systemd/system/" "../$pkgname.service" + install -Dm644 -t "$pkgdir/usr/lib/sysusers.d/" "../$pkgname.conf" + install -Dm644 -t "$pkgdir/usr/share/$pkgname/" \ + config.toml.sample \ + schema.sql \ + queries.sql + cp -a static "$pkgdir/usr/share/$pkgname/" + mkdir -p "$pkgdir/usr/share/$pkgname/frontend/dist/" + cp -a frontend/dist/ "$pkgdir/usr/share/$pkgname/frontend/" + cp -a i18n "$pkgdir/usr/share/$pkgname/" +} diff --git a/listmonk/listmonk.conf b/listmonk/listmonk.conf new file mode 100644 index 0000000..b7e2c67 --- /dev/null +++ b/listmonk/listmonk.conf @@ -0,0 +1 @@ +u listmonk - "Listmonk mailing list and newsletter manager" diff --git a/listmonk/listmonk.install b/listmonk/listmonk.install new file mode 100644 index 0000000..be3a05e --- /dev/null +++ b/listmonk/listmonk.install @@ -0,0 +1,40 @@ +post_install() { + cat <<- EOF + WARNING: Installed with default password! + + To setup: + + Setup PostgreSQL with credentials and a database: + + \$ sudo -u postgres psql + postgres=# CREATE USER listmonk WITH PASSWORD ''; + postgres=# CREATE DATABASE listmonk; + postgres=# GRANT ALL PRIVILEGES ON DATABASE listmonk TO listmonk; + postgres=# \\q + + Then edit /etc/listmonk/config.toml with your new database credentials. + Also be sure to change the admin password from the defalut. + + Run manually once to setup the database tables: + + \$ sudo -u listmonk listmonk --config /etc/listmonk/config.toml --install + + Lastly you can enable the system service: + + \$ sudo systemctl enable --now listmonk + EOF +} + +post_upgrade() { + cat <<- EOF + To update the Listmonk database format, first backup your data, then run: + + \$ sudo -u listmonk listmonk --config /etc/listmonk/config.toml --upgrade + + Then restart the service: + + \$ sudo systemctl restart listmonk + EOF +} + +# vim: : ts=4 sw=4 noet diff --git a/listmonk/listmonk.service b/listmonk/listmonk.service new file mode 100644 index 0000000..ccc8fd4 --- /dev/null +++ b/listmonk/listmonk.service @@ -0,0 +1,16 @@ +[Unit] +Description=Listmonk mailing list and newsletter manager +Wants=network.target + +[Service] +Type=simple +WorkingDirectory=/usr/share/listmonk +ExecStart=/usr/bin/listmonk --config /etc/listmonk/config.toml +User=listmonk +Group=listmonk +Restart=on-failure +LimitNOFILE=65536 +TasksMax=infinity + +[Install] +WantedBy=multi-user.target