Skip to content

Commit

Permalink
network/gem: Added (Gemini Server).
Browse files Browse the repository at this point in the history
  • Loading branch information
G. Galdini authored and sbo-bot[bot] committed Nov 14, 2024
1 parent 0068f2d commit 817b307
Show file tree
Hide file tree
Showing 6 changed files with 233 additions and 0 deletions.
40 changes: 40 additions & 0 deletions network/gem/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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.

A special thanks for William Clark, owner of this `bonus opus`
1 change: 1 addition & 0 deletions network/gem/doinst.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setcap cap_sys_chroot+ep usr/sbin/gem
47 changes: 47 additions & 0 deletions network/gem/gem.8
Original file line number Diff line number Diff line change
@@ -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>
116 changes: 116 additions & 0 deletions network/gem/gem.SlackBuild
Original file line number Diff line number Diff line change
@@ -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}

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
10 changes: 10 additions & 0 deletions network/gem/gem.info
Original file line number Diff line number Diff line change
@@ -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"
19 changes: 19 additions & 0 deletions network/gem/slack-desc
Original file line number Diff line number Diff line change
@@ -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:

0 comments on commit 817b307

Please sign in to comment.