aboutsummaryrefslogtreecommitdiff
path: root/gmid
diff options
context:
space:
mode:
Diffstat (limited to 'gmid')
-rw-r--r--gmid/README19
-rw-r--r--gmid/doinst.sh40
-rw-r--r--gmid/files/gmid.conf.new24
-rw-r--r--gmid/files/rc.gmid.new56
-rw-r--r--gmid/gmid.SlackBuild101
-rw-r--r--gmid/gmid.info10
-rw-r--r--gmid/slack-desc21
7 files changed, 271 insertions, 0 deletions
diff --git a/gmid/README b/gmid/README
new file mode 100644
index 0000000..cbd4fdc
--- /dev/null
+++ b/gmid/README
@@ -0,0 +1,19 @@
+gmid is a server for the Gemini protocol. It has various features, among which
+Capsicum support and a "config-less" mode akin to "python -m http.server" to
+quickly serve local directories from the shell.
+
+This setup differs from the project's standard by avoiding to run the service
+as root. It comes at the cost of not supporting 'chroot'.
+
+To have the gmid daemon start and stop with your host,
+add to /etc/rc.d/rc.local:
+
+ if [ -x /etc/rc.d/rc.gmid ]; then
+ /etc/rc.d/rc.gmid start
+ fi
+
+and to /etc/rc.d/rc.local_shutdown (creating it if needed):
+
+ if [ -x /etc/rc.d/rc.gmid ]; then
+ /etc/rc.d/rc.gmid stop
+ fi
diff --git a/gmid/doinst.sh b/gmid/doinst.sh
new file mode 100644
index 0000000..c94965b
--- /dev/null
+++ b/gmid/doinst.sh
@@ -0,0 +1,40 @@
+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
+}
+
+
+if ! getent passwd gmid >/dev/null; then
+ useradd gmid \
+ --comment 'gmid gemini server' \
+ --user-group \
+ --system \
+ --home-dir /srv/gmid \
+ || true
+fi
+
+preserve_perms etc/rc.d/rc.gmid.new
+
+config etc/gmid/gmid.conf.new
+chown gmid:gmid etc/gmid/certs
+
+chown gmid:gmid var/log/gmid
diff --git a/gmid/files/gmid.conf.new b/gmid/files/gmid.conf.new
new file mode 100644
index 0000000..3b725ad
--- /dev/null
+++ b/gmid/files/gmid.conf.new
@@ -0,0 +1,24 @@
+log {
+ access /var/log/gmid/gmid.log
+}
+
+# An example of a server block:
+server "localhost" {
+ listen on * port 1965
+
+ # set the directory to serve
+ root "localhost"
+
+ # Set self-signed TLS cert and key. It's better to keep
+ # the keys outside the chroot.
+ #
+ # sudo -u gmid -- \
+ # openssl req -x509 \
+ # -newkey rsa:4096 \
+ # -nodes \
+ # -out /etc/gmid/certs/localhost.crt \
+ # -keyout /etc/gmid/certs/localhost.key \
+ # -subj "/CN=localhost"
+ cert "/etc/gmid/certs/localhost.crt"
+ key "/etc/gmid/certs/localhost.key"
+}
diff --git a/gmid/files/rc.gmid.new b/gmid/files/rc.gmid.new
new file mode 100644
index 0000000..33044b7
--- /dev/null
+++ b/gmid/files/rc.gmid.new
@@ -0,0 +1,56 @@
+#!/bin/sh
+#
+# Startup/shutdown script for the gmid gemini service.
+#
+
+create_run_dir() {
+ if [ ! -d /run/gmid/ ]; then
+ mkdir -p /run/gmid
+ chown :gmid /run/gmid
+ chmod g+wX /run/gmid
+ fi
+}
+
+start() {
+ echo "Starting gmid gemini service"
+ create_run_dir
+
+ sudo -u gmid -- gmid \
+ -c /etc/gmid/gmid.conf \
+ -P /run/gmid/gmid.pid
+}
+
+status() {
+ create_run_dir
+
+ if [ -f /run/gmid/gmid.pid ] && [ kill -0 "$(cat /run/gmid/gmid.pid)" >/dev/null ]; then
+ echo "gmid is running"
+ else
+ echo "gmid is not running"
+ fi
+}
+
+stop() {
+ echo "Stopping gmid gemini service"
+ create_run_dir
+
+ if [ -f /run/gmid/gmid.pid ]; then
+ sudo -u gmid -- kill -SIGINT "$(cat /run/gmid/gmid.pid)"
+ fi
+}
+
+case "$1" in
+start)
+ start
+ ;;
+status)
+ status
+ ;;
+stop)
+ stop
+ ;;
+*)
+ echo "Usage: $0 {start|stop|status}"
+ exit 1
+esac
+
diff --git a/gmid/gmid.SlackBuild b/gmid/gmid.SlackBuild
new file mode 100644
index 0000000..9c7169a
--- /dev/null
+++ b/gmid/gmid.SlackBuild
@@ -0,0 +1,101 @@
+#!/bin/bash
+
+cd $(dirname $0) ; CWD=$(pwd)
+
+PRGNAM=gmid
+VERSION=${VERSION:-2.1.1}
+BUILD=${BUILD:-1}
+TAG=${TAG:-_slackcoder}
+PKGTYPE=${PKGTYPE:-txz}
+
+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}
+
+set -e
+
+rm -rf $PKG
+mkdir -p $TMP $PKG $OUTPUT
+cd $TMP
+rm -rf $PRGNAM-$VERSION
+tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
+cd $PRGNAM-$VERSION
+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 {} \;
+
+
+# Your application will probably need different configure flags;
+# these are provided as an example only.
+# Be sure to build only shared libraries unless there's some need for
+# static.
+CFLAGS="$SLKCFLAGS" \
+CXXFLAGS="$SLKCFLAGS" \
+./configure \
+ --prefix=/usr \
+ --sysconfdir=/etc/gmid \
+ --mandir=/usr/man
+
+# Compile the application and install it into the $PKG directory
+make
+make install DESTDIR=$PKG
+
+# Don't ship .la files:
+rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la
+
+# Strip binaries and libraries - this can be done with 'make install-strip'
+# in many source trees, and that's usually acceptable if so, but if not,
+# use this:
+find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
+ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
+
+# Compress man pages
+# If the man pages are installed to /usr/share/man instead, you'll need to either
+# add the --mandir=/usr/man flag to configure or move them manually after the
+# make install process is run.
+find $PKG/usr/man -type f -exec gzip -9 {} \;
+for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
+
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
+cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
+cp -a \
+ ChangeLog \
+ LICENSE \
+ README.md \
+ $PKG/usr/doc/$PRGNAM-$VERSION
+cp "$CWD/README" "$PKG/usr/doc/$PRGNAM-$VERSION/README_slackware.md"
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+cat $CWD/doinst.sh > $PKG/install/doinst.sh
+
+mkdir -p "$PKG/etc/gmid"
+mkdir -p "$PKG/etc/gmid/certs"
+cp -R "$CWD/files/gmid.conf.new" "$PKG/etc/gmid/"
+
+mkdir -p "$PKG/etc/rc.d"
+cp -R "$CWD/files/rc.gmid.new" "$PKG/etc/rc.d/"
+
+mkdir -p "$PKG/srv/gmid"
+
+mkdir -p "$PKG/var/log/gmid"
+chmod u=rwX,g=rX,o= "$PKG/var/log/gmid"
+
+cd $PKG
+/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE
diff --git a/gmid/gmid.info b/gmid/gmid.info
new file mode 100644
index 0000000..d1284c8
--- /dev/null
+++ b/gmid/gmid.info
@@ -0,0 +1,10 @@
+PRGNAM="gmid"
+VERSION="2.1.1"
+HOMEPAGE="https://gmid.omarpolo.com"
+DOWNLOAD="https://ftp.omarpolo.com/gmid-2.1.1.tar.gz"
+MD5SUM="fda53ff9cd666ca1de9c5f56511a3465"
+DOWNLOAD_x86_64=""
+MD5SUM_x86_64=""
+REQUIRES=""
+MAINTAINER="Slack Coder"
+EMAIL="slackcoder@server.ky"
diff --git a/gmid/slack-desc b/gmid/slack-desc
new file mode 100644
index 0000000..ee4bd53
--- /dev/null
+++ b/gmid/slack-desc
@@ -0,0 +1,21 @@
+# 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------------------------------------------------------|
+gmid: gmid (Gemini server)
+gmid:
+gmid: gmid is a server for the Gemini protocol. It has various
+gmid: features, among which Capsicum support and a "config-less"
+gmid: mode akin to "python -m http.server" to quickly serve local
+gmid: directories from the shell.
+gmid:
+gmid:
+gmid:
+gmid:
+gmid:
+gmid:
+gmid: