diff options
author | G. Galdini <jake@dioniso.com.br> | 2024-11-14 22:55:07 +0700 |
---|---|---|
committer | Willy Sudiarto Raharjo <willysr@slackbuilds.org> | 2024-11-15 06:53:28 +0700 |
commit | af83d7e149dc3676c2a05ec979a5a3b384c8fd0c (patch) | |
tree | 8f6ec0d7ae2374e92a233b232762b7c51fc185b5 /network | |
parent | 80667651987afa50ff5df53a9efece46a110b381 (diff) |
network/gem: Added (Gemini Server).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'network')
-rw-r--r-- | network/gem/README | 38 | ||||
-rw-r--r-- | network/gem/doinst.sh | 26 | ||||
-rw-r--r-- | network/gem/gem.8 | 47 | ||||
-rw-r--r-- | network/gem/gem.SlackBuild | 116 | ||||
-rw-r--r-- | network/gem/gem.info | 10 | ||||
-rw-r--r-- | network/gem/rc.gem | 31 | ||||
-rw-r--r-- | network/gem/slack-desc | 19 |
7 files changed, 287 insertions, 0 deletions
diff --git a/network/gem/README b/network/gem/README new file mode 100644 index 000000000000..e9f43260b41b --- /dev/null +++ b/network/gem/README @@ -0,0 +1,38 @@ +a simple gemini server + +It supports: + * mime types + * directory listing + * chunked file transfer + * passes most gemini-diagnostics tests + * user-defined charset/lang meta attributes + +The script will create ssl certificate with CN=localhost +If you wish change domain of ssl certificate: use DOMAIN variable +before execution of SlackBuild script. + + DOMAIN=slackbuilds.org ./gem.SlackBuild + +Is created 'gmi' directory as database in /var +Certificates are saved in /var/gmi/tls path. +Capsule content must be save in /var/gmi/capsule path. + +Overview: + +/var/gmi [ root:root | 755 ] +├── capsule [ root:users | 775 ] +├── log [ root:users | 664 ] +└── tls [ root:root | 755 ] + ├── server.crt [ root:root | 644 ] + └── server.key [ root:users | 640 ] + +* daemon: that SlackBuild package have script for /etc/rc.d + +NOTE: Here is already existent gem binary (package manager for Ruby), +then create alias for gem (gemini server): + + alias gem="/usr/sbin/gem" + alias gemd="(ba)sh /etc/rc.d/rc.gem" - /bin/sh already appoint for bash +on Slackware. + +* run gem as regular user, preferably - security questions. diff --git a/network/gem/doinst.sh b/network/gem/doinst.sh new file mode 100644 index 000000000000..e984b1b8cecb --- /dev/null +++ b/network/gem/doinst.sh @@ -0,0 +1,26 @@ +config() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + # If there's no config file by that name, mv it over: + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then + # toss the redundant copy + rm $NEW + fi + # Otherwise, we leave the .new copy for the admin to consider... +} + +preserve_perms() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + if [ -e $OLD ]; then + cp -a $OLD ${NEW}.incoming + cat $NEW > ${NEW}.incoming + mv ${NEW}.incoming $NEW + fi + config $NEW +} + +preserve_perms etc/rc.d/rc.gem.new +setcap cap_sys_chroot+ep usr/sbin/gem diff --git a/network/gem/gem.8 b/network/gem/gem.8 new file mode 100644 index 000000000000..26e9466359d1 --- /dev/null +++ b/network/gem/gem.8 @@ -0,0 +1,47 @@ +.TH GEM 8 "12 November 2024" + +.SH NAME +gem \- a simple gemini server + +.SH SYNOPSIS +.B gem +[\fI\,OPTION\/\fR]... + +.SH DESCRIPTION +gemini server with TLS and script for generating working TLS certs + +It supports: mime types; directory listing; chunked file transfer; +passes most gemini-diagnostics tests; user-defined charset/lang meta +attributes. + +.SH OPTIONS +.TP 5 +\fB\,-k\/\fR [\fI\,pub key path\/\fR] +(default: /var/gmi/tls/server.crt) +.TP 5 +\fB\,-c\/\fR [\fI\,priv key path\/\fR] +(default: /var/gmi/tls/server.key) +.TP 5 +\fB\,-h\/\fR [\fI\,hostname\/\fR] +(default: localhost) +.TP 5 +\fB\,-p\/\fR [\fI\,port\/\fR] +(default: 1965) +.TP 5 +\fB\,-d\/\fR [\fI\,doc root\/\fR] +(default: \fB\,null\/\fR) +.TP 5 +\fB\,-i\/\fR [\fI\,index file\/\fR] +(default: index.gmi) +.TP 5 +.BR -e +enumerate directories without an index file +.TP 5 +.BR -a +permit requests with a different hostname +.TP 5 +.BR -v +verbose: print request information + +.SH AUTHOR +William Clark <wrvc96@gmail.com> diff --git a/network/gem/gem.SlackBuild b/network/gem/gem.SlackBuild new file mode 100644 index 000000000000..30914a13c7f4 --- /dev/null +++ b/network/gem/gem.SlackBuild @@ -0,0 +1,116 @@ +#!/bin/bash + +# Slackware build script for gem + +# Copyright 2024 G. Galdini <jake@dioniso.com.br> Brazil +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +cd $(dirname $0) ; CWD=$(pwd) + +PRGNAM=gem +VERSION=${VERSION:-20241113_d1a2873} +COMMIT="d1a287326225a0596f3698013374953c33502218" +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} +PKGTYPE=${PKGTYPE:-tgz} + +if [ -z "$ARCH" ]; then + case "$( uname -m )" in + i?86) ARCH=i586 ;; + arm*) ARCH=arm ;; + *) ARCH=$( uname -m ) ;; + esac +fi + +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE" + exit 0 +fi + +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +if [ "$ARCH" = "i586" ]; then + SLKCFLAGS="-O2 -march=i586 -mtune=i686" +elif [ "$ARCH" = "i686" ]; then + SLKCFLAGS="-O2 -march=i686 -mtune=i686" +elif [ "$ARCH" = "x86_64" ]; then + SLKCFLAGS="-O2 -fPIC" +elif [ "$ARCH" = "aarch64" ]; then + SLKCFLAGS="-O2 -fPIC" +else + SLKCFLAGS="-O2" +fi + +: ${DOMAIN:=localhost} + +set -e + +rm -rf $PKG +mkdir -p $TMP $PKG $OUTPUT +cd $TMP +rm -rf $PRGNAM-$COMMIT +tar xvf $CWD/$PRGNAM-$COMMIT.tar.gz +cd $PRGNAM-$COMMIT +chown -R root:root . +find -L . \ + \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ + -o -perm 511 \) -exec chmod 755 {} \; -o \ + \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ + -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; + +if [ "$DOMAIN" != 'localhost' ]; then + sed -i "s/localhost/$DOMAIN/" Makefile $CWD/rc.${PRGNAM} +fi + +sed -i \ + -e "s,-O3,$SLKCFLAGS," \ + -e "s,tls,$PKG/var/gmi/tls,g" \ +Makefile + +sed -i 's,tls/,/var/gmi/tls/,g' config.h main.c + +make ssl +make + +chmod 640 $PKG/var/gmi/tls/server.key +mkdir -m 775 $PKG/var/gmi/capsule +> $PKG/var/gmi/log && chmod 664 $PKG/var/gmi/log +chown root:users $PKG/var/gmi/{log,capsule,tls/server.key} + +install -m 755 -D $PRGNAM $PKG/usr/sbin/$PRGNAM +install -m 644 -D $CWD/$PRGNAM.8 $PKG/usr/man/man8/$PRGNAM.8 +install -m 644 -D $CWD/rc.${PRGNAM} $PKG/etc/rc.d/rc.${PRGNAM}.new + +strip --strip-unneeded $PKG/usr/sbin/$PRGNAM +gzip -9 $PKG/usr/man/man?/*.? + +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION +cp -a README.md \ + $PKG/usr/doc/$PRGNAM-$VERSION +cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc +cat $CWD/doinst.sh > $PKG/install/doinst.sh + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE diff --git a/network/gem/gem.info b/network/gem/gem.info new file mode 100644 index 000000000000..12e854b94d31 --- /dev/null +++ b/network/gem/gem.info @@ -0,0 +1,10 @@ +PRGNAM="gem" +VERSION="20241113_d1a2873" +HOMEPAGE="https://github.com/wrclark/gem" +DOWNLOAD="https://github.com/wrclark/gem/archive/d1a2873/gem-d1a287326225a0596f3698013374953c33502218.tar.gz" +MD5SUM="6040fcc9a63632527a68cd5ebe6285f7" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +REQUIRES="" +MAINTAINER="G. Galdini" +EMAIL="jake@dioniso.com.br" diff --git a/network/gem/rc.gem b/network/gem/rc.gem new file mode 100644 index 000000000000..7fba29fa43f9 --- /dev/null +++ b/network/gem/rc.gem @@ -0,0 +1,31 @@ +#!/bin/sh +# +# /etc/rc.d/rc.gem: start/stop/status gem daemon +# +# Written by G. Galdini <jake@dioniso.com.br> + +case "$1" in + start) + ( /usr/sbin/gem -d /var/gmi/capsule -h localhost -aev \ + >> /var/gmi/log 2>&1 ) & + ;; + stop) + pid="$(pidof gem)" + [ -z "$pid" ] && { echo "already stop" ; exit 1 ;} + kill -9 "$pid" + ;; + restart) + sh $0 stop + sh $0 start + ;; + status) + if &>/dev/null pidof 'gem' ; then + echo "running" + else + echo "stop" + fi + ;; + *) + echo "usage: $0 [start|stop|restart|status]" + ;; +esac diff --git a/network/gem/slack-desc b/network/gem/slack-desc new file mode 100644 index 000000000000..83baa1c6edf9 --- /dev/null +++ b/network/gem/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. +# Line up the first '|' above the ':' following the base package name, and +# the '|' on the right side marks the last column you can put a character in. +# You must make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +gem: gem (a simple gemini server) +gem: +gem: gemini server with TLS and script for generating working TLS certs +gem: +gem: It supports: mime types; directory listing; chunked file transfer; +gem: passes most gemini-diagnostics tests; user-defined charset/lang +gem: meta attributes. +gem: +gem: Homepage: https://github.com/wrclark/gem +gem: +gem: |