user/wikijs: new aport

This commit is contained in:
Antoine Martin 2024-06-16 21:20:24 -04:00
parent 1c7eeb3dce
commit bdb37e35ee
5 changed files with 135 additions and 0 deletions

60
user/wikijs/APKBUILD Normal file
View file

@ -0,0 +1,60 @@
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=wikijs
pkgver=2.5.303
pkgrel=0
pkgdesc="Wiki.js | A modern, lightweight and powerful wiki app built on Node.js"
license="AGPL-3.0"
arch="!armv7 x86_64"
options="!check" # No test suite
depends="
libcap-setcap
nodejs>=10.12.0
postgresql
python3
"
makedepends="
yarn
npm
"
url="https://github.com/Requarks/wiki"
subpackages="$pkgname-openrc"
install="$pkgname.post-install $pkgname.pre-install"
builddir="$srcdir"/wiki-$pkgver
pkgusers="wikijs"
pkggroups="wikijs"
source="
$pkgname-$pkgver.tar.gz::https://github.com/requarks/wiki/archive/refs/tags/v$pkgver.tar.gz
wikijs.initd
config.sample.yml.patch
"
prepare() {
default_prepare
sed -i "s|\"version.*|\"version\": \"$pkgver\",|" "$builddir"/package.json
sed -i 's|"dev": true.*|"dev": "false",|' "$builddir"/package.json
}
build() {
yarn --frozen-lockfile --non-interactive
yarn build
rm -rf node_modules
yarn --production --frozen-lockfile --non-interactive
}
package() {
install -Dm755 "$srcdir"/wikijs.initd "$pkgdir"/etc/init.d/wikijs
install -Dm644 -o 5494 -g 5494 "$builddir"/config.sample.yml "$pkgdir"/etc/wikijs/config.yml
install -Dm644 "$builddir"/package.json -t "$pkgdir"/usr/lib/bundles/wikijs
cp -aR "$builddir"/assets "$builddir"/server "$builddir"/node_modules "$pkgdir"/usr/lib/bundles/wikijs
mkdir -p "$pkgdir"/var/lib/wikijs
chown 5494:5494 "$pkgdir"/var/lib/wikijs
}
sha512sums="
a463d79ad0d8ff15dbe568b839094d697c6de0b2e991b77a4944e2a82f9789de6840e504a4673e4e0900d61596e880ca276008de86dac4f05f5823dc0427d2fc wikijs-2.5.303.tar.gz
355131ee5617348b82681cb8543c784eea59689990a268ecd3b77d44fe9abcca9c86fb8b047f0a8faeba079c650faa7790c5dd65418d313cd7561f38bb590c03 wikijs.initd
07b536c20e370d2a926038165f0e953283259c213a80a8648419565f5359ab05f528ac310e81606914013da212270df6feddb22e514cbcb2464c8274c956e4af config.sample.yml.patch
"

View file

@ -0,0 +1,13 @@
diff --git a/config.sample.yml.orig b/config.sample.yml
index 47edd8d..458472a 100644
--- a/config.sample.yml.orig
+++ b/config.sample.yml
@@ -136,7 +136,7 @@ ha: false
# Data Path
# ---------------------------------------------------------------------
# Writeable data path used for cache and temporary user uploads.
-dataPath: ./data
+dataPath: /var/lib/wikijs/data
# ---------------------------------------------------------------------
# Body Parser Limit

24
user/wikijs/wikijs.initd Normal file
View file

@ -0,0 +1,24 @@
#!/sbin/openrc-run
name="$RC_SVCNAME"
cfgfile="/etc/conf.d/$RC_SVCNAME"
pidfile="/var/run/$RC_SVCNAME.pid"
command="/usr/bin/node server"
command_args=""
command_user="wikijs"
command_group="wikijs"
supervisor="supervise-daemon"
start_stop_daemon_args=""
command_background="yes"
output_log="/var/log/$RC_SVCNAME/$RC_SVCNAME.log"
error_log="/var/log/$RC_SVCNAME/$RC_SVCNAME.err"
working_directory="/usr/lib/bundles/wikijs"
start_pre() {
checkpath --directory --owner $command_user:$command_user --mode 0775 \
/var/log/$RC_SVCNAME \
/var/lib/$RC_SVCNAME
export NODE_ENV=production
export CONFIG_FILE=/etc/wikijs/config.yml
cd "$working_directory"
}

18
user/wikijs/wikijs.post-install Executable file
View file

@ -0,0 +1,18 @@
#!/bin/sh
set -eu
group=wikijs
config_file='/etc/wikijs/config.yml'
setcap 'cap_net_bind_service=+ep' /usr/bin/node
cat >&2 <<-EOF
*
* 1. Adjust settings in /etc/wikijs/config.yml.
*
* 2. Create database for wikijs:
*
* psql -c "CREATE ROLE wikijs PASSWORD 'top-secret' INHERIT LOGIN;"
* psql -c "CREATE DATABASE wkijs OWNER wikijs ENCODING 'UTF-8';"
*
EOF

View file

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