summaryrefslogtreecommitdiff
path: root/user/apaste
diff options
context:
space:
mode:
Diffstat (limited to 'user/apaste')
-rw-r--r--user/apaste/APKBUILD84
-rw-r--r--user/apaste/apasted-log.run5
-rw-r--r--user/apaste/apasted.confd32
-rw-r--r--user/apaste/apasted.initd64
-rw-r--r--user/apaste/apasted.pre-install7
-rw-r--r--user/apaste/apasted.run19
-rw-r--r--user/apaste/apastesd.run23
7 files changed, 234 insertions, 0 deletions
diff --git a/user/apaste/APKBUILD b/user/apaste/APKBUILD
new file mode 100644
index 000000000..99851d559
--- /dev/null
+++ b/user/apaste/APKBUILD
@@ -0,0 +1,84 @@
+# Maintainer: Laurent Bercot <ska-adelie@skarnet.org>
+pkgname=apaste
+pkgver=0.0.3.0
+pkgrel=0
+pkgdesc="A command-line pastebin"
+url="https://skarnet.org/software/apaste/"
+arch="all"
+options="!check" # No test suite.
+license="ISC"
+_skalibs_version=2.14.4
+_execline_version=2.9.7
+_s6_version=2.13.2
+_s6net_version=2.7.1
+depends="s6-networking"
+makedepends="skalibs-dev>=$_skalibs_version s6-networking-dev>=$_s6net_version"
+subpackages="apaste-doc apasted:server apasted-openrc:apasted_openrc"
+source="
+ https://skarnet.org/software/apaste/apaste-$pkgver.tar.gz
+ apasted.run
+ apastesd.run
+ apasted-log.run
+ apasted.confd
+ apasted.initd
+ "
+pkggroups="apasted"
+pkgusers="apastedlog apasted"
+
+build() {
+ ./configure \
+ --enable-shared \
+ --disable-allstatic \
+ --prefix=/usr \
+ --with-pkgconfig \
+ --enable-pkgconfig
+ make
+}
+
+_makeservicedir() {
+ name="apaste${1}d-${2}"
+ fn="$subpkgdir/var/lib/apasted/services/$name"
+ mkdir -p "$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"
+ fn="$subpkgdir/var/log/$name"
+ mkdir -p "$fn"
+ chown apastedlog:apasted "$fn"
+ chmod 02700 "$fn"
+}
+
+package() {
+ make DESTDIR="$pkgdir" install
+ install -D -m 0644 "$srcdir/apasted.confd" "$pkgdir/etc/conf.d/apasted"
+ install -D -m 0755 "$srcdir/apasted.initd" "$pkgdir/etc/init.d/apasted"
+ mkdir -p -m 0755 "$pkgdir/usr/share/doc"
+ cp -a "$builddir/doc" "$pkgdir/usr/share/doc/$pkgname"
+}
+
+server() {
+ depends="execline>=$_execline_version s6>=$_s6_version s6-networking>=$_s6net_version apasted-openrc"
+ pkgdesc="A server for the apaste command-line pastebin"
+ install="apasted.pre-install"
+ mkdir -p "$subpkgdir/usr/bin" "$subpkgdir/var/lib/apasted/services"
+ mv "$pkgdir/usr/bin/apasted" "$subpkgdir/usr/bin/"
+ for i in '' s ; do for j in 4 6 ; do
+ _makeservicedir "$i" "$j"
+ done ; done
+}
+
+apasted_openrc() {
+ depends="apasted"
+ install -D -m 0644 "$srcdir/apasted.confd" "$subpkgdir/etc/conf.d/apasted"
+ install -D -m 0755 "$srcdir/apasted.initd" "$subpkgdir/etc/init.d/apasted"
+}
+
+sha512sums="ac3031b5d43447cf33bb4300ce866716b650ed730d74e6d41fff83a7a3eff2233172d9962e13c6d624002537a7c13ac5d581715a9a49145f392139c21b921ea6 apaste-0.0.3.0.tar.gz
+970a79b6da5a7c58539cd9d47cba36855eb4f37e1e0bbd841ade15022b5fb291a077f7ad118ff662a45f3b2b59162264a180c338f23f964ea3e48364c68ac606 apasted.run
+817b276ae51e9bd769e39a8313a84449d181c65749640119ba1e4af3c21d2572152c7bdd5eec70cbcfaa3255fd6cba966dfc1dc7a818a60d329283c39ae058a8 apastesd.run
+9341c1c69c1d45b35052b0042665fffb9cff6583fad558ed37a19af574b53a5e298727c43a6c718fd40936e8f16d1a10e9c229392595ba1e06ddb21d1d8b055b apasted-log.run
+3b91225252d95d676097d337ca77ef2bdffb52baa657197efe079b82c663baeaed0882993eeed7f7ce260f051e439159c61368f8a1d4b84d1daa74fe358c39d7 apasted.confd
+f9e6dd5aa6d5efe678f370431e7b58a52f903eed9b698f60b1853d601a4d9c0a53ccb996034d401dfd7ddbe573fc2651cf5c87164de599c42f754ad015b8e302 apasted.initd"
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..f730f8012
--- /dev/null
+++ b/user/apaste/apasted.initd
@@ -0,0 +1,64 @@
+#!/sbin/openrc-run
+
+description="Start/stop the apasted services"
+
+depend()
+{
+ after net
+ after localmount
+}
+
+_get_services()
+{
+ 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.pre-install b/user/apaste/apasted.pre-install
new file mode 100644
index 000000000..27c1c1880
--- /dev/null
+++ b/user/apaste/apasted.pre-install
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+groupadd -r -- apasted 2>/dev/null
+useradd -r -d / -M -N -s /sbin/nologin -g apasted -c apastedlog -- apastedlog 2>/dev/null
+useradd -r -d / -M -N -s /sbin/nologin -g apasted -c apasted -- apasted 2>/dev/null
+
+exit 0
diff --git a/user/apaste/apasted.run b/user/apaste/apasted.run
new file mode 100644
index 000000000..8ad8aa487
--- /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 -uSi APASTED_IPv@V@
+ importas -uSi APASTED_PORT
+ importas -uSi APASTED_ROOT
+ importas -uSD "" APASTED_PREFIX
+ importas -uSD10 APASTED_MAXFILES
+ importas -uSD1048576 APASTED_MAXSIZE
+ importas -uSD10485760 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..a1205ed4c
--- /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 -uSi APASTED_IPv@V@
+ importas -uSi APASTED_TLS_PORT
+ importas -uSi APASTED_ROOT
+ importas -uSD "" APASTED_PREFIX
+ importas -uSD10 APASTED_MAXFILES
+ importas -uSD1048576 APASTED_MAXSIZE
+ importas -uSD10485760 APASTED_MAXTOTALSIZE
+ importas -uSi KEYFILE
+ importas -uSi 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}