summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-adelie@skarnet.org>2024-02-24 08:53:33 +0000
committerLaurent Bercot <ska-adelie@skarnet.org>2024-02-24 08:57:44 +0000
commitf6caef65cb23c157fa195a56a648235a8af37531 (patch)
tree1b1d7541270b3f5fb603187e34d7a0aacd2640c6
parentca35fa1a22f117398f176d5ecbb2259aab28ab4c (diff)
downloadpackages-f6caef65cb23c157fa195a56a648235a8af37531.tar.gz
packages-f6caef65cb23c157fa195a56a648235a8af37531.tar.bz2
packages-f6caef65cb23c157fa195a56a648235a8af37531.tar.xz
packages-f6caef65cb23c157fa195a56a648235a8af37531.zip
user/apaste: new package
-rw-r--r--user/apaste/APKBUILD75
-rw-r--r--user/apaste/apaste-server.post-install7
-rw-r--r--user/apaste/apaste-server.pre-install7
-rw-r--r--user/apaste/apasted-log.run5
-rw-r--r--user/apaste/apasted.confd32
-rw-r--r--user/apaste/apasted.initd65
-rw-r--r--user/apaste/apasted.run19
-rw-r--r--user/apaste/apastesd.run23
8 files changed, 233 insertions, 0 deletions
diff --git a/user/apaste/APKBUILD b/user/apaste/APKBUILD
new file mode 100644
index 000000000..23a289a3e
--- /dev/null
+++ b/user/apaste/APKBUILD
@@ -0,0 +1,75 @@
+# Contributor: Laurent Bercot <ska-adelie@skarnet.org>
+# Maintainer: Laurent Bercot <ska-adelie@skarnet.org>
+pkgname=apaste
+pkgver=0.0.2.0
+pkgrel=0
+pkgdesc="A command-line pastebin"
+url="https://skarnet.org/software/apaste/"
+arch="all"
+options="!check" # No test suite.
+license="ISC"
+depends="s6-networking"
+makedepends="skalibs-dev>=2.14.1.1 s6-networking-dev>=2.7.0.2"
+subpackages="apasted:server apasted-openrc:openrc"
+source="
+ https://skarnet.org/software/apaste/apaste-$pkgver.tar.gz
+ apasted.run
+ apastesd.run
+ apasted-log.run
+ apasted.confd
+ apasted.initd
+ "
+
+build() {
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --localstatedir=/var
+ make
+}
+
+_makeservicedir() {
+ name="apaste${1}d-${2}"
+ fn="$subpkgdir/var/lib/apasted/services/$name"
+ mkdir -p -m 0755 "$fn/log"
+ echo 3 > "$fn/log/notification-fd"
+ sed -e "s/@S@/${1}/g; s/@V@/${2}/g;" "$srcdir/apasted-log.run" > "$fn/log/run"
+ chmod 0755 "$fn/log/run"
+ echo 3 > "$fn/notification-fd"
+ sed -e "s/@V@/${2}/g;" "$srcdir/apaste${1}d.run" > "$fn/run"
+ chmod 0755 "$fn/run"
+}
+
+package() {
+ make DESTDIR="$pkgdir" install
+}
+
+server() {
+ depends="execline s6 s6-networking>=2.7.0.2 apasted-openrc"
+ pkgdesc="A server for the apaste command-line pastebin"
+ install="apaste-server.pre-install"
+ mkdir -p -m 0755 "$subpkgdir/usr/bin" "$subpkgdir/var/lib/apasted/services"
+ mv "$pkgdir/usr/bin/apasted" "$subpkgdir/usr/bin/"
+ _makeservicedir "" 4
+ _makeservicedir "" 6
+ _makeservicedir s 4
+ _makeservicedir s 6
+}
+
+openrc() {
+ depends="apasted"
+ mkdir -p -m 0755 "$subpkgdir/etc/conf.d" "$subpkgdir/etc/init.d"
+ cp "$srcdir/apasted.confd" "$subpkgdir/etc/conf.d/apasted"
+ cp "$srcdir/apasted.initd" "$subpkgdir/etc/init.d/apasted"
+ chmod 0755 "$subpkgdir/etc/init.d/apasted"
+}
+
+sha512sums="b1550d738801ddee528d0ce62333aa9a8fc9824183a61be295e767fbcdb1ae4d15a5e34295754cc5e8c51c8b410a56972bac28c5812099652fb8bb5140fb4c15 apaste-0.0.2.0.tar.gz
+27f6b3ac98f52a6ed11d225ea19e34160b1fef2dd980a32a43ff03499e121b6418612be4c94d1139388bee47b14a5ea24edc383fcfcfe55abe7daf12be2d514c apasted.run
+8cd74ba6c6579912083f9605056b46ca2887faaf23a0d1981043a5ac4d6e724def51a7c087fb719f2b0189e6b0a0d9469a1e955fcbf04c8ea9f2d818649c122e apastesd.run
+9341c1c69c1d45b35052b0042665fffb9cff6583fad558ed37a19af574b53a5e298727c43a6c718fd40936e8f16d1a10e9c229392595ba1e06ddb21d1d8b055b apasted-log.run
+3b91225252d95d676097d337ca77ef2bdffb52baa657197efe079b82c663baeaed0882993eeed7f7ce260f051e439159c61368f8a1d4b84d1daa74fe358c39d7 apasted.confd
+da909cfc4aaa6571dda2fa0e4713e61c1b7f18ca35907ce4d0e3aa639596c69d801d6369b43ce67b20aa8d8a4050f46d98823b6158f80170866263b7b7a79e5b apasted.initd"
diff --git a/user/apaste/apaste-server.post-install b/user/apaste/apaste-server.post-install
new file mode 100644
index 000000000..aba532a62
--- /dev/null
+++ b/user/apaste/apaste-server.post-install
@@ -0,0 +1,7 @@
+#!/bin/sh -e
+
+mkdir -p -m 0755 /var/log
+list="/var/log/apasted-4 /var/log/apasted-6 /var/log/apastesd-4 /var/log/apastesd-6"
+mkdir -p -m 0755 $list
+chown apastedlog:apasted $list
+chmod 02755 $list
diff --git a/user/apaste/apaste-server.pre-install b/user/apaste/apaste-server.pre-install
new file mode 100644
index 000000000..32782d21f
--- /dev/null
+++ b/user/apaste/apaste-server.pre-install
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+addgroup -S apasted 2>/dev/null
+adduser -S -D -h / -H -s /sbin/nologin -G apasted -g apastedlog apastedlog 2>/dev/null
+adduser -S -D -h / -H -s /sbin/nologin -G apasted -g apasted apasted 2>/dev/null
+
+exit 0
diff --git a/user/apaste/apasted-log.run b/user/apaste/apasted-log.run
new file mode 100644
index 000000000..4d10c72b1
--- /dev/null
+++ b/user/apaste/apasted-log.run
@@ -0,0 +1,5 @@
+#!/bin/execlineb -S1
+
+s6-envuidgid apastedlog
+exec -c
+s6-log -d3 -- t /var/log/apaste@S@d-@V@
diff --git a/user/apaste/apasted.confd b/user/apaste/apasted.confd
new file mode 100644
index 000000000..df57ce121
--- /dev/null
+++ b/user/apaste/apasted.confd
@@ -0,0 +1,32 @@
+# apasted configuration
+
+# The IPs you want the apasted server to listen on.
+# Comment to disable.
+APASTED_IPv4=0.0.0.0
+APASTED_IPv6=::
+
+# The ports for plaintext service and TLS-tunneled service.
+# Comment to disable.
+APASTED_PORT=9999
+# APASTED_TLS_PORT=9997
+
+# If APASTED_TLS_PORT is present, KEYFILE should point to
+# your private key, and CERTFILE should point to your certificate.
+# KEYFILE=
+# CERTFILE=
+
+# Where the pastes are stored. Make sure this directory exists
+# and is writable by the apasted user.
+APASTED_ROOT=/var/tmp/apaste
+
+# If you want a prefix for the slugs.
+# APASTED_PREFIX=
+
+# Maximum number of client files stored at once. Default is 10.
+# APASTED_MAXFILES=10
+
+# Maximum client file size, in bytes. Default is 1048576 (1 MB).
+# APASTED_MAXSIZE=1048576
+
+# Maximum total size of a transaction, in bytes. Default is 10485760 (10 MB).
+# APASTED_MAXTOTALSIZE=10485760
diff --git a/user/apaste/apasted.initd b/user/apaste/apasted.initd
new file mode 100644
index 000000000..106c2b11a
--- /dev/null
+++ b/user/apaste/apasted.initd
@@ -0,0 +1,65 @@
+#!/sbin/openrc-run
+
+description="Start/stop the apasted services"
+
+depend()
+{
+ after net
+ after localmount
+}
+
+_get_services()
+{
+ . /etc/conf.d/apasted
+ list=
+ if test -n "$APASTED_PORT" ; then
+ if test -n "$APASTED_IPv4" ; then
+ list="apasted-4"
+ fi
+ if test -n "$APASTED_IPv6" ; then
+ list="$list apasted-6"
+ fi
+ fi
+ if test -n "$APASTED_TLS_PORT" ; then
+ if test -n "$APASTED_IPV4" ; then
+ list="apastesd-4"
+ fi
+ if test -n "$APASTED_IPV6" ; then
+ list="$list apastesd-6"
+ fi
+ fi
+ echo $list
+}
+
+stop()
+{
+ ebegin "Stopping the apasted services"
+ for i in `_get_services` ; do
+ s6-svunlink /run/service "$i"
+ done
+ eend $?
+}
+
+start()
+{
+ ebegin "Starting the apasted services"
+ for i in `_get_services` ; do
+ s6-svlink -t10000 /run/service "/var/lib/apasted/services/$i"
+ done
+ eend $?
+}
+
+status()
+{
+ for i in `_get_services` ; do
+ echo -n "${i}: "
+ s6-svstat "/run/service/${i}"
+ done
+}
+
+restart()
+{
+ for i in `_get_services` ; do
+ s6-svc -rwR "/run/service/$i"
+ done
+}
diff --git a/user/apaste/apasted.run b/user/apaste/apasted.run
new file mode 100644
index 000000000..4b49c6320
--- /dev/null
+++ b/user/apaste/apasted.run
@@ -0,0 +1,19 @@
+#!/bin/execlineb -S1
+
+fdmove -c 2 1
+emptyenv -p
+fdmove 1 3
+envfile /etc/conf.d/apasted
+multisubstitute
+{
+ importas -ui APASTED_IPv@V@ APASTED_IPv@V@
+ importas -ui APASTED_PORT APASTED_PORT
+ importas -ui APASTED_ROOT APASTED_ROOT
+ importas -uD "" APASTED_PREFIX APASTED_PREFIX
+ importas -uD 10 APASTED_MAXFILES APASTED_MAXFILES
+ importas -uD 1048576 APASTED_MAXSIZE APASTED_MAXSIZE
+ importas -uD 10485760 APASTED_MAXTOTALSIZE APASTED_MAXTOTALSIZE
+}
+s6-envuidgid apasted
+s6-tcpserver -1 -U -- ${APASTED_IPv@V@} ${APASTED_PORT}
+apasted -r 10000 -w 10000 -d ${APASTED_ROOT} -p ${APASTED_PREFIX} -n ${APASTED_MAXFILES} -s ${APASTED_MAXSIZE} -S ${APASTED_MAXTOTALSIZE}
diff --git a/user/apaste/apastesd.run b/user/apaste/apastesd.run
new file mode 100644
index 000000000..b5d0813f6
--- /dev/null
+++ b/user/apaste/apastesd.run
@@ -0,0 +1,23 @@
+#!/bin/execlineb -S1
+
+fdmove -c 2 1
+emptyenv -p
+fdmove 1 3
+envfile /etc/conf.d/apasted
+multisubstitute
+{
+ importas -ui APASTED_IPv@V@ APASTED_IPv@V@
+ importas -ui APASTED_TLS_PORT APASTED_TLS_PORT
+ importas -ui APASTED_ROOT APASTED_ROOT
+ importas -uD "" APASTED_PREFIX APASTED_PREFIX
+ importas -uD 10 APASTED_MAXFILES APASTED_MAXFILES
+ importas -uD 1048576 APASTED_MAXSIZE APASTED_MAXSIZE
+ importas -uD 10485760 APASTED_MAXTOTALSIZE APASTED_MAXTOTALSIZE
+ importas -ui KEYFILE KEYFILE
+ importas -ui CERTFILE CERTFILE
+}
+s6-envuidgid apasted
+export TLS_UID 65534
+export TLS_GID 65534
+s6-tlsserver -1 -U -H -l0 -K 5000 -- ${APASTED_IPv@V@} ${APASTED_TLS_PORT}
+apasted -r 10000 -w 10000 -d ${APASTED_ROOT} -p ${APASTED_PREFIX} -n ${APASTED_MAXFILES} -s ${APASTED_MAXSIZE} -S ${APASTED_MAXTOTALSIZE}