diff --git a/ilot/uptime-kuma/APKBUILD b/ilot/uptime-kuma/APKBUILD new file mode 100644 index 0000000..cea07d0 --- /dev/null +++ b/ilot/uptime-kuma/APKBUILD @@ -0,0 +1,49 @@ +# Contributor: Antoine Martin (ayakael) +# Maintainer: Antoine Martin (ayakael) +pkgname=uptime-kuma +pkgver=1.23.13 +pkgrel=0 +pkgdesc='A fancy self-hosted monitoring tool' +arch="all" +url="https://github.com/louislam/uptime-kuma" +license="MIT" +depends="nodejs" +makedepends="npm" +source=" + uptime-kuma-$pkgver.tar.gz::https://github.com/louislam/uptime-kuma/archive/refs/tags/$pkgver.tar.gz + uptime-kuma.openrc + uptime-kuma.conf + " +subpackages="$pkgname-doc $pkgname-openrc" +install="$pkgname.pre-install" + +build() { + npm ci + npm run build + rm -Rf "$builddir"/node_modules + npm ci --omit=dev +} + +package() { + install -dm 755 \ + "$pkgdir"/usr/share/webapps \ + "$pkgdir"/usr/share/doc \ + "$pkgdir"/usr/share/licenses/uptime-kuma \ + "$pkgdir"/etc/init.d \ + "$pkgdir"/etc/conf.d + + # install + cp -a "$builddir" "$pkgdir/usr/share/webapps/uptime-kuma" + + # openrc + install -Dm755 "$srcdir"/uptime-kuma.openrc "$pkgdir"/etc/init.d/uptime-kuma + install -Dm755 "$srcdir"/uptime-kuma.conf "$pkgdir"/etc/conf.d/uptime-kuma + + # docs and licenses + mv "$pkgdir"/usr/share/webapps/uptime-kuma/LICENSE "$pkgdir"/usr/share/licenses/uptime-kuma/. +} +sha512sums=" +9045cdc69d46ce34011f7866844a8d1866eee21850be6eede3226e77b9c0d3ecc0190481671f04f25da40345b29cc2d13de07bcc27e7baeff7901b4bd9c8b93f uptime-kuma-1.23.13.tar.gz +0ceddb98a6f318029b8bd8b5a49b55c883e77a5f8fffe2b9b271c9abf0ac52dc7a6ea4dbb4a881124a7857f1e43040f18755c1c2a034479e6a94d2b65a73d847 uptime-kuma.openrc +1dbae536b23e3624e139155abbff383bba3209ff2219983da2616b4376b1a5041df812d1e5164716fc6e967a8446d94baae3b96ee575d400813cc6fdc2cc274e uptime-kuma.conf +" diff --git a/ilot/uptime-kuma/uptime-kuma.conf b/ilot/uptime-kuma/uptime-kuma.conf new file mode 100644 index 0000000..f816a99 --- /dev/null +++ b/ilot/uptime-kuma/uptime-kuma.conf @@ -0,0 +1,47 @@ +# uptime-kuma config +# for more info +# see https://github.com/louislam/uptime-kuma/wiki/Environment-Variables + +# Set the directory where the data should be stored (could be relative) +# DATA_DIR=/var/lib/uptime-kuma + +# Host to bind to, could be an ip. +# UPTIME_KUMA_HOST=:: + +# Port to listen to +# UPTIME_KUMA_PORT=3001 + +# Path to SSL key +# UPTIME_KUMA_SSL_KEY= + +# Path to SSL certificate +# UPTIME_KUMA_SSL_CERT= + +# SSL Key Passphrase +# UPTIME_KUMA_SSL_KEY_PASSPHRASE= + +# Cloudflare Tunnel Token +# UPTIME_KUMA_CLOUDFLARED_TOKEN= + +# By default, Uptime Kuma is not allowed in iframe if the domain name is not +# the same as the parent. It protects your Uptime Kuma to be a phishing +# website. If you don't need this protection, you can set it to true +# UPTIME_KUMA_DISABLE_FRAME_SAMEORIGIN=false + +# By default, Uptime Kuma is verifying that the websockets ORIGIN-Header +# matches your servers hostname. If you don't need this protection, you can +# set it to bypass. See GHSA-mj22-23ff-2hrr for further context. +# UPTIME_KUMA_WS_ORIGIN_CHECK=cors-like + +# Allow to specify any executables as Chromium +# UPTIME_KUMA_ALLOW_ALL_CHROME_EXEC=0 + +# Add your self-signed ca certs. +# NODE_EXTRA_CA_CERTS= + +# Ignore all TLS errors +# NOTE_TLS_REJECT_UNAUTHORIZED=0 + +# Set it to --insecure-http-parser, if you encountered error Invalid header +# value char when your website using WAF +# NODE_OPTIONS= diff --git a/ilot/uptime-kuma/uptime-kuma.openrc b/ilot/uptime-kuma/uptime-kuma.openrc new file mode 100644 index 0000000..ce7b00e --- /dev/null +++ b/ilot/uptime-kuma/uptime-kuma.openrc @@ -0,0 +1,48 @@ +#!/sbin/openrc-run + +description="Uptime Kuma self-hosted monitoring tool" + +# Change $directory to path to uptime-kuma +directory=${directory:-/usr/share/webapps/uptime-kuma} +pidfile=${pidfile:-/run/$RC_SVCNAME.pid} +DATA_DIR=${DATA_DIR:-/var/lib/uptime-kuma} + +log_dir="/var/log/$RC_SVCNAME" +logfile=${logfile:-$log_dir/$RC_SVCNAME.log} +output_log="${output_log:-$logfile}" +error_log="${error_log:-$logfile}" + +command=${command:-/usr/bin/node} +command_args="$directory/server/server.js" +command_user=${command_user:-uptime-kuma:uptime-kuma} +command_background=true + +depend() { + need net +} + +start_pre() { + checkpath --owner=$command_user --directory $log_dir \ + $DATA_DIR \ + $DATA_DIR/upload + checkpath --owner=$command_user --file $logfile \ + $DATA_DIR/error.log + + [ ! -e $DATA_DIR/kuma.db ] && + cp $directory/db/kuma.db $DATA_DIR + + checkpath --owner=$command_user --mode 600 --file $DATA_DIR/kuma.db* + + cd $directory + + export DATA_DIR UPTIME_KUMA_HOST UPTIME_KUMA_PORT UPTIME_KUMA_SSL_KEY \ + UPTIME_KUMA_SSL_CERT UPTIME_KUMA_SSL_KEY_PASSPHRASE \ + UPTIME_KUMA_CLOUDFLARED_TOKEN UPTIME_KUMA_DISABLE_FRAME_SAMEORIGIN \ + UPTIME_KUMA_WS_ORIGIN_CHECK UPTIME_KUMA_ALLOW_ALL_CHROME_EXEC \ + NODE_EXTRA_CA_CERTS NODE_TLS_REJECT_UNAUTHORIZED NODE_OPTIONS +} + +start_post() { + # Wait for the server to be started + sleep 10 +} diff --git a/ilot/uptime-kuma/uptime-kuma.pre-install b/ilot/uptime-kuma/uptime-kuma.pre-install new file mode 100755 index 0000000..0217278 --- /dev/null +++ b/ilot/uptime-kuma/uptime-kuma.pre-install @@ -0,0 +1,25 @@ +#!/bin/sh + +DATADIR='/var/lib/uptime-kuma' + +if ! getent group uptime-kuma 1>/dev/null; then + echo '* Creating group uptime-kuma' 1>&2 + + addgroup -S uptime-kuma +fi + +if ! id uptime-kuma 2>/dev/null 1>&2; then + echo '* Creating user uptime-kuma' 1>&2 + + adduser -DHS -G uptime-kuma -h "$DATADIR" -s /bin/sh \ + -g "added by apk for uptime-kuma" uptime-kuma + passwd -u uptime-kuma 1>/dev/null # unlock +fi + +if ! id -Gn uptime-kuma | grep -Fq www-data; then + echo '* Adding user uptime-kuma to group www-data' 1>&2 + + addgroup uptime-kuma www-data +fi + +exit 0