summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--user/tipidee/APKBUILD80
-rw-r--r--user/tipidee/httpd.run19
-rw-r--r--user/tipidee/httpsd.run23
-rw-r--r--user/tipidee/logger.run5
-rw-r--r--user/tipidee/tipidee.conf18
-rw-r--r--user/tipidee/tipidee.confd33
-rw-r--r--user/tipidee/tipidee.initd65
-rw-r--r--user/tipidee/tipidee.post-install7
-rw-r--r--user/tipidee/tipidee.pre-install7
9 files changed, 257 insertions, 0 deletions
diff --git a/user/tipidee/APKBUILD b/user/tipidee/APKBUILD
new file mode 100644
index 000000000..593b19dae
--- /dev/null
+++ b/user/tipidee/APKBUILD
@@ -0,0 +1,80 @@
+# Contributor: Laurent Bercot <ska-adelie@skarnet.org>
+# Maintainer: Laurent Bercot <ska-adelie@skarnet.org>
+pkgname=tipidee
+pkgver=0.0.4.0
+pkgrel=0
+pkgdesc="The skarnet.org web server"
+url="https://skarnet.org/software/tipidee/"
+arch="all"
+options="!check" # No test suite.
+license="ISC"
+depends="execline s6 s6-networking"
+makedepends="skalibs-dev>=2.14.1.1"
+subpackages="tipidee-dev tipidee-libs tipidee-doc tipidee-openrc"
+source="
+ https://skarnet.org/software/tipidee/tipidee-$pkgver.tar.gz
+ httpd.run
+ httpsd.run
+ logger.run
+ tipidee.conf
+ tipidee.confd
+ tipidee.initd
+ "
+install="
+ tipidee.pre-install
+ tipidee.post-install
+ "
+
+build() {
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --enable-shared \
+ --enable-static \
+ --disable-allstatic \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --libdir=/usr/lib \
+ --libexecdir="/usr/lib/$pkgname" \
+ --with-dynlib=/lib
+ make
+}
+
+_makeservicedir() {
+ name="http${1}d-${2}"
+ fn="$pkgdir/var/lib/tipidee/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/logger.run" > "$fn/log/run"
+ chmod 0755 "$fn/log/run"
+ echo 3 > "$fn/notification-fd"
+ sed -e "s/@V@/${2}/g;" "$srcdir/http${1}d.run" > "$fn/run"
+ chmod 0755 "$fn/run"
+}
+
+package() {
+ mkdir -p -m 0755 "$pkgdir/etc" "$pkgdir/usr/share/doc" "$pkgdir/var/lib/tipidee/docroot"
+ make DESTDIR="$pkgdir" install
+ cp "$srcdir/tipidee.conf" "$pkgdir/etc/tipidee.conf"
+ for i in '' s ; do for j in 4 6 ; do
+ _makeservicedir "$i" "$j"
+ done ; done
+ install -m 0644 -D "$srcdir/tipidee.confd" "$pkgdir/etc/conf.d/tipidee"
+ install -m 0755 -D "$srcdir/tipidee.initd" "$pkgdir/etc/init.d/tipidee"
+ cp -a "$builddir/doc" "$pkgdir/usr/share/doc/$pkgname"
+}
+
+dev() {
+ default_dev
+
+ # default_dev please stop being stupid
+ mv "$subpkgdir/usr/bin/tipidee-config" "$pkgdir/usr/bin/tipidee-config"
+}
+
+sha512sums="d177f4c00db9855792dbddc4c96d2c75bd302443f29376e1d35d511d56964e5de11dd2cf4af3190d7465404c429eedfc17264715e4850d6b830a9e492ff25741 tipidee-0.0.4.0.tar.gz
+0de0d6bd39adfd6e65694335e9cf06cec7625032e6af5cf5e54ced5c009707ca4e27b2dbdff8b7825575fbef7cd98ac0333e07b1924f24fda23019c92c08023f httpd.run
+65cdbfb5a6485aed0203ed910af124b202994d5253cb365ed25432f0c906471dd30f96eb862b6f25004c6ec8ec4cb38a5b49cde717e7a00d7c9d7fd07025f225 httpsd.run
+b5af306fe7040f966b13da84bfb0c4b528683c03205519d08fe429ee826ffad27c9ddb32be8c8bf8b42ce7964ef15572e3c66a96494aed833ee951c769f81bd2 logger.run
+bb2681a3000133724bb8fd4918bc3209ea676c2e4f96ad8b298d8e7302aeebd6876341ea205f2d808f34e4c9b5c138bba032694c6069c17026b0ddf23702f9ba tipidee.conf
+7a999200ad21b2b0737ce82136bc8e055d7ab4a865b7727e6dc8df0eaeea6ace11eb5756b64231ce7938d11b5ec218944173ea1df3db059d033bf3f848c9a608 tipidee.confd
+13e27b5c9f8ed6b1186b41bce6ffc280146643cb7b568958f24b63a4d73fcb7a147b68cd7cf74812ca55a2a5ae3b3717f177ea1546be7d30a86ff09954d9ec0f tipidee.initd"
diff --git a/user/tipidee/httpd.run b/user/tipidee/httpd.run
new file mode 100644
index 000000000..356ad9952
--- /dev/null
+++ b/user/tipidee/httpd.run
@@ -0,0 +1,19 @@
+#!/bin/execlineb -S1
+
+fdmove -c 2 1
+emptyenv -p
+fdmove 1 3
+envfile /etc/conf.d/tipidee
+unexport HTTP
+unexport HTTPS
+multisubstitute
+{
+ importas -ui TIPIDEED_IPv@V@ TIPIDEED_IPv@V@
+ importas -ui TIPIDEED_ROOT TIPIDEED_ROOT
+ importas -u -D1000 TIPIDEED_CONCURRENCY TIPIDEED_CONCURRENCY
+ importas -u -D10 TIPIDEED_LOCAL_CONCURRENCY TIPIDEED_LOCAL_CONCURRENCY
+}
+s6-envuidgid tipideed
+cd ${TIPIDEED_ROOT}
+s6-tcpserver -1 -U -c ${TIPIDEED_CONCURRENCY} -C ${TIPIDEED_LOCAL_CONCURRENCY} -- ${TIPIDEED_IPv@V@} 80
+tipideed
diff --git a/user/tipidee/httpsd.run b/user/tipidee/httpsd.run
new file mode 100644
index 000000000..9d710158a
--- /dev/null
+++ b/user/tipidee/httpsd.run
@@ -0,0 +1,23 @@
+#!/bin/execlineb -S1
+
+fdmove -c 2 1
+emptyenv -p
+fdmove 1 3
+envfile /etc/conf.d/tipidee
+unexport HTTP
+unexport HTTPS
+multisubstitute
+{
+ importas -ui TIPIDEED_IPv@V@ TIPIDEED_IPv@V@
+ importas -ui TIPIDEED_ROOT TIPIDEED_ROOT
+ importas -ui KEYFILE KEYFILE
+ importas -ui CERTFILE CERTFILE
+ importas -u -D1000 TIPIDEED_CONCURRENCY TIPIDEED_CONCURRENCY
+ importas -u -D10 TIPIDEED_LOCAL_CONCURRENCY TIPIDEED_LOCAL_CONCURRENCY
+}
+s6-envuidgid tipideed
+export TLS_UID 65534
+export TLS_GID 65534
+cd ${TIPIDEED_ROOT}
+s6-tlsserver -1 -U -K 5000 -c ${TIPIDEED_CONCURRENCY} -C ${TIPIDEED_LOCAL_CONCURRENCY} -- ${TIPIDEED_IPv@V@} 443
+tipideed
diff --git a/user/tipidee/logger.run b/user/tipidee/logger.run
new file mode 100644
index 000000000..3f1785703
--- /dev/null
+++ b/user/tipidee/logger.run
@@ -0,0 +1,5 @@
+#!/bin/execlineb -S1
+
+s6-setuidgid tipideelog
+exec -c
+s6-log -d3 -- t s1000000 /var/log/http@S@d-@V@
diff --git a/user/tipidee/tipidee.conf b/user/tipidee/tipidee.conf
new file mode 100644
index 000000000..40bba13f9
--- /dev/null
+++ b/user/tipidee/tipidee.conf
@@ -0,0 +1,18 @@
+# This is where the behaviour of the tipidee web server is
+# configured.
+# See https://skarnet.org/software/tipidee/tipidee.conf.html
+# for the full documentation of the syntax.
+
+# The defaults work well, but here are some example directives that
+# you can uncomment if you find them applicable to your setup.
+
+# global read_timeout 60000
+# global write_timeout 60000
+# global cgi_timeout 5000
+# index-file index.html index.cgi
+# log start ip hostname request resource answer answer_size
+# custom-header always Strict-Transport-Security max-age=63072000; includeSubDomains; preload
+#
+# domain example.com
+# nph-prefix nph-
+# cgi /cgi-bin/
diff --git a/user/tipidee/tipidee.confd b/user/tipidee/tipidee.confd
new file mode 100644
index 000000000..d47fb589f
--- /dev/null
+++ b/user/tipidee/tipidee.confd
@@ -0,0 +1,33 @@
+# Configuration for the tipidee web server.
+
+# The IPs you want the tipidee server to listen on.
+# Comment to disable.
+TIPIDEED_IPv4=0.0.0.0
+TIPIDEED_IPv6=::
+
+# Serve plaintext HTTP? true or false
+HTTP=true
+
+# Serve HTTPS? true or false
+HTTPS=false
+
+# If HTTPS is true, KEYFILE should point to
+# your private key, and CERTFILE should point to your certificate.
+# KEYFILE=
+# CERTFILE=
+
+# Total authorized concurrent connections. Don't go above 5000 or so.
+TIPIDEED_CONCURRENCY=1000
+
+# Authorized concurrent connections *per IP*.
+TIPIDEED_LOCAL_CONCURRENCY=10
+
+# The server root. Make sure this directory exists, is readable by
+# the tipideed user, and does *not* belong to the tipideed user.
+# The documents need to be stored under subdirectories of TIPIDEED_ROOT,
+# one subdirectory per virtual domain you're serving.
+TIPIDEED_ROOT=/var/lib/tipidee/docroot
+
+# Also check the /etc/tipidee.conf file for detailed configuration of
+# logging, document attributes, etc.
+# Run tipidee-config after editing /etc/tipidee.conf.
diff --git a/user/tipidee/tipidee.initd b/user/tipidee/tipidee.initd
new file mode 100644
index 000000000..ebd0787a7
--- /dev/null
+++ b/user/tipidee/tipidee.initd
@@ -0,0 +1,65 @@
+#!/sbin/openrc-run
+
+description="Start/stop the tipidee services"
+
+depend()
+{
+ after net
+ after localmount
+}
+
+_get_services()
+{
+ . /etc/conf.d/tipidee
+ list=
+ if "$HTTP" ; then
+ if test -n "$TIPIDEED_IPv4" ; then
+ list="httpd-4"
+ fi
+ if test -n "$TIPIDEED_IPv6" ; then
+ list="$list httpd-6"
+ fi
+ fi
+ if "$HTTPS" ; then
+ if test -n "$TIPIDEED_IPV4" ; then
+ list="httpsd-4"
+ fi
+ if test -n "$TIPIDEED_IPV6" ; then
+ list="$list httpsd-6"
+ fi
+ fi
+ echo $list
+}
+
+stop()
+{
+ ebegin "Stopping the tipidee services"
+ for i in `_get_services` ; do
+ s6-svunlink /run/service "$i"
+ done
+ eend $?
+}
+
+start()
+{
+ ebegin "Starting the tipidee services"
+ for i in `_get_services` ; do
+ s6-svlink -t10000 /run/service "/var/lib/tipidee/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/tipidee/tipidee.post-install b/user/tipidee/tipidee.post-install
new file mode 100644
index 000000000..9ff3c9691
--- /dev/null
+++ b/user/tipidee/tipidee.post-install
@@ -0,0 +1,7 @@
+#!/bin/sh -e
+
+list="/var/log/httpd-4 /var/log/httpd-6 /var/log/httpsd-4 /var/log/httpsd-6"
+mkdir -p -m 0755 $list
+chown tipideelog:tipidee $list
+chmod 02755 $list
+exec tipidee-config
diff --git a/user/tipidee/tipidee.pre-install b/user/tipidee/tipidee.pre-install
new file mode 100644
index 000000000..0ef043441
--- /dev/null
+++ b/user/tipidee/tipidee.pre-install
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+addgroup -S tipidee 2>/dev/null
+adduser -S -D -h / -H -s /sbin/nologin -G tipidee -g tipideelog tipideelog 2>/dev/null
+adduser -S -D -h / -H -s /sbin/nologin -G tipidee -g tipideed tipideed 2>/dev/null
+
+exit 0