user/listmonk: new aport #410

Merged
ayakael merged 1 commit from listmonk/initial into edge 2024-02-23 06:21:18 +00:00
6 changed files with 161 additions and 0 deletions
Showing only changes of commit 28d52cbcc7 - Show all commits

71
user/listmonk/APKBUILD Normal file
View file

@ -0,0 +1,71 @@
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=listmonk
pkgver=3.0.0
pkgrel=0
pkgdesc='Self-hosted newsletter and mailing list manager with a modern dashboard'
arch="all"
url=https://listmonk.app
license="AGPL3"
depends="
libcap-setcap
postgresql
procps
"
makedepends="go npm nodejs yarn"
source="
$pkgname-$pkgver.tar.gz::https://github.com/knadh/listmonk/archive/v$pkgver.tar.gz
listmonk.sh
listmonk.openrc
"
install="$pkgname.pre-install $pkgname.post-install $pkgname.post-upgrade"
subpackages="$pkgname-openrc"
pkgusers="listmonk"
pkggroups="listmonk"
build() {
go build \
-trimpath \
-buildmode=pie \
-mod=readonly \
-modcacherw \
-ldflags "-extldflags '$LDFLAGS' -X 'main.buildString=Alpine Linux v$pkgver-$pkgrel' -X 'main.versionString=v$pkgver'" \
-o $pkgname \
cmd/*.go
(
cd frontend
export YARN_CACHE_FOLDER="$srcdir/node_modules"
export VUE_APP_VERSION="v$pkgver"
yarn install --frozen-lockfile
yarn build
)
}
check() {
go test ./...
}
package() {
install -Dm755 "$srcdir"/listmonk.sh "$pkgdir"/usr/bin/listmonk
install -Dm644 config.toml.sample "$pkgdir"/etc/listmonk/config.toml
install -Dm644 -t "$pkgdir"/usr/share/webapps/listmonk/ \
schema.sql \
queries.sql \
config.toml.sample
install -Dm755 listmonk "$pkgdir"/usr/share/webapps/listmonk/
install -Dm644 -t "$pkgdir"/usr/share/webapps/listmonk/frontend/dist/ \
frontend/dist/static/favicon.png
cp -a frontend/dist/static "$pkgdir"/usr/share/webapps/listmonk/frontend/dist/static
cp -a frontend/dist/index.html "$pkgdir"/usr/share/webapps/listmonk/frontend/dist/index.html
cp -a static "$pkgdir"/usr/share/webapps/listmonk/
cp -a i18n "$pkgdir"/usr/share/webapps/listmonk/
install -Dm755 "$srcdir"/$pkgname.openrc \
"$pkgdir"/etc/init.d/$pkgname
ln -s /etc/listmonk/config.toml "$pkgdir"/usr/share/webapps/listmonk/config.toml
}
sha512sums="
afd0ea1d4d2b2753c3043526590cf09c45a541a2d818f5d1581644ffd10818326fd553a3b04bca59494860a7bb6e96364b08afd33d337a9fc5c71bedd1a5ee6c listmonk-3.0.0.tar.gz
939450af4b23708e3d23a5a88fad4c24b957090bdd21351a6dd520959e52e45e5fcac117a3eafa280d9506616dae39ad3943589571f008cac5abe1ffd8062424 listmonk.sh
8e9c0b1f335c295fb741418246eb17c7566e5e4200a284c6483433e8ddbf5250aa692435211cf062ad1dfcdce3fae9148def28f03f2492d33fe5e66cbeebd4bd listmonk.openrc
"

View file

@ -0,0 +1,29 @@
#!/sbin/openrc-run
name="$RC_SVCNAME"
cfgfile="/etc/conf.d/$RC_SVCNAME.conf"
pidfile="/run/$RC_SVCNAME.pid"
working_directory="/usr/share/webapps/listmonk"
command="/usr/share/webapps/listmonk/listmonk"
command_user="listmonk"
command_group="listmonk"
start_stop_daemon_args=""
command_background="yes"
output_log="/var/log/listmonk/$RC_SVCNAME.log"
error_log="/var/log/listmonk/$RC_SVCNAME.err"
depend() {
need postgresql
}
start_pre() {
cd "$working_directory"
checkpath --directory --owner $command_user:$command_group --mode 0775 \
/var/log/listmonk \
/var/lib/listmonk
}
stop_pre() {
ebegin "Killing child processes"
kill $(ps -o pid= --ppid $(cat $pidfile)) || true
}

View file

@ -0,0 +1,27 @@
#!/bin/sh
set -eu
setcap 'cap_net_bind_service=+ep' /usr/share/webapps/listmonk/listmonk
if [ "${0##*.}" = 'post-upgrade' ]; then
cat >&2 <<-EOF
*
* To finish Listmonk upgrade run:
*
* listmonk --upgrade
*
EOF
else
cat >&2 <<-EOF
*
* 1. Adjust settings in /etc/listmonk/config.toml.
*
* 2. Create database for Listmonk:
*
* psql -c "CREATE ROLE listmonk PASSWORD 'top-secret' INHERIT LOGIN;"
* psql -c "CREATE DATABASE listmonk OWNER listmonk ENCODING 'UTF-8';"
*
* 3. Run "listmonk --install"
*
EOF
fi

View file

@ -0,0 +1 @@
listmonk.post-install

View file

@ -0,0 +1,21 @@
#!/bin/sh
# It's very important to set user/group correctly.
listmonk_dir='/var/lib/listmonk'
if ! getent group listmonk 1>/dev/null; then
echo '* Creating group listmonk' 1>&2
addgroup -S listmonk
fi
if ! id listmonk 2>/dev/null 1>&2; then
echo '* Creating user listmonk' 1>&2
adduser -DHS -G listmonk -h "$listmonk_dir" -s /bin/sh \
-g "added by apk for listmonk" listmonk
passwd -u listmonk 1>/dev/null # unlock
fi
exit 0

12
user/listmonk/listmonk.sh Normal file
View file

@ -0,0 +1,12 @@
#!/bin/sh
BUNDLE_DIR='/usr/share/webapps/listmonk'
cd $BUNDLE_DIR
if [ "$(id -un)" != 'listmonk' ]; then
exec su listmonk -c '"$0" "$@"' -- ./listmonk "$@"
else
exec ./listmonk "$@"
fi