agate

Simple gemini server for static files
git clone https://github.com/mbrubeck/agate.git
Log | Files | Refs | README

commit 86e0fe665d7fda4f09755ff682cea8dc03b0000a
parent 742a423021155eafe1122962a68f90ca3b044ec2
Author: Johann150 <johann.galle@protonmail.com>
Date:   Fri,  5 Feb 2021 08:26:24 +0100

add tools for Debian

Diffstat:
Atools/README.md | 2++
Atools/debian/README.md | 30++++++++++++++++++++++++++++++
Atools/debian/gemini.conf | 2++
Atools/debian/gemini.service | 28++++++++++++++++++++++++++++
Atools/debian/geminilogs | 10++++++++++
Atools/debian/install.sh | 81+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 153 insertions(+), 0 deletions(-)

diff --git a/tools/README.md b/tools/README.md @@ -0,0 +1,2 @@ +This directory contains some useful tools if you want to use Agate like service files or installer scripts. If you use Agate on a system not present here, your pull request is welcome! +We also welcome pull requests for other files for tools you might find helpful to use in conjunction with Agate. diff --git a/tools/debian/README.md b/tools/debian/README.md @@ -0,0 +1,30 @@ +If you want to run agate on a pretty much standard Debian install, this +directory contains some additional materials that may help you. + +Please keep in mind that there is no warranty whatsoever provided for this +software as specified in the disclaimer in the MIT license or section 7 of +the Apache license respectively. + +To run Agate as a service with systemd, put the `gemini.service` file +in the directory `/etc/systemd/system/` (copy or move it there). + +This service file has some comments you may want to look at before using it! + +If you use the service file and want the agate logs in a separate file, +using the gemini.conf file and putting it in the directory +`/etc/rsyslog.d/` will make the agate log messages appear in a file +called `/var/log/gemini.log`. + +If you use Debians `logrotate` and want to automatically rotate these log files, +you can use the `geminilogs` file and put it in `/etc/logrotate.d/`. + +You can also use the `install.sh` file which will check if these systems +are installed (but not if they are running) and copy the files to their +described locations. Please ensure your systems hostname is set correctly +(i.e. `uname -n` should give your domain name). + +You will have to run this with elevated privileges, i.e. `sudo ./install.sh` +to work correctly. This install script will also create the necessary content +directories and the certificate and private key in the `/srv/gemini/` +directory. After the script is done sucessfully, you can start by putting +content in `/srv/gemini/content/`, the server is running already! diff --git a/tools/debian/gemini.conf b/tools/debian/gemini.conf @@ -0,0 +1,2 @@ +if $programname == 'gemini' then /var/log/gemini.log +& stop diff --git a/tools/debian/gemini.service b/tools/debian/gemini.service @@ -0,0 +1,28 @@ +# This file is part of the Agate software and licensed under either the +# MIT license or Apache license at your option. +# +# Please keep in mind that there is no warranty whatsoever provided for this +# software as specified in the disclaimer in the MIT license or section 7 of +# the Apache license respectively. + +[Unit] +Description=Agate gemini server + +[Service] +# you should place the certificate and key file in this directory +# and place the contents to be displayed in /srv/gemini/content +WorkingDirectory=/srv/gemini/ +# assumes the device hostname is set correctly +ExecStart=agate --hostname $(uname -n) --lang en + +Restart=always +RestartSec=1 + +StandardOutput=syslog +StandardError=syslog +# adds a syslog identifier so you can have these logs filtered into +# a separate file +SyslogIdentifier=gemini + +[Install] +WantedBy=multi-user.target diff --git a/tools/debian/geminilogs b/tools/debian/geminilogs @@ -0,0 +1,10 @@ +/var/log/gemini.log { + daily + missingok + rotate 14 + compress + delaycompress + notifempty + create 0640 root adm + sharedscripts +} diff --git a/tools/debian/install.sh b/tools/debian/install.sh @@ -0,0 +1,81 @@ +#!/bin/bash +# This file is part of the Agate software and licensed under either the +# MIT license or Apache license at your option. +# +# Please keep in mind that there is not warranty whatsoever provided for this +# software as specified in the disclaimer in the MIT license or section 7 of +# the Apache license respectively. + +echo -n "checking:agate......." +if command -v agate >/dev/null +then + echo "found" +else + echo "FAILED" + echo "Agate is probably not in your PATH variable." + echo "If you installed it with cargo, try linking the binary to /usr/local/bin with something like this:" + echo " ln -s $HOME/.cargo/bin/agate /usr/local/bin/agate" + echo "or what seems reasonable to you." + exit 1 +fi + +echo -n "checking:systemd....." +if [[ "$(cat /proc/1/comm)" != "systemd" ]] +then + echo "NOT THE INIT PROCESS" + echo "Your system seems to not use systemd, sorry. Aborting." + exit 1 +else + echo "installed and running" +fi + +echo -n "checking:rsyslogd...." +if command -v rsyslogd >/dev/null +then + echo -n "installed" + if ps cax | grep -q "rsyslogd" + then + echo " and running" + else + echo " but not running!" + echo "You should enable rsyslogd to use this functionality." + fi +else + echo "NOT INSTALLED!" + echo "Aborting." + exit 1 +fi + +echo -n "checking:logrotate..." +if type logrotate >/dev/null 2>&1 +then + echo "installed, but I cannot check if it is enabled" +else + echo "NOT INSTALLED!" + echo "Aborting." + exit 1 +fi + +# immediately exit if one of the following commands fails +set -e + +echo "copying config files..." +cp gemini.service /etc/systemd/system/ +cp gemini.conf /etc/rsyslog.d/ +cp geminilogs /etc/logrotate.d/ + +echo "setting up content files..." +mkdir -p /srv/gemini/content +openssl req -x509 -newkey rsa:4096 -keyout /srv/gemini/key.rsa -out /srv/gemini/cert.pem \ + -days 3650 -nodes -subj "/CN=$(uname -n)" + +echo "starting service..." +systemctl daemon-reload +systemctl restart rsyslog +systemctl enable gemini +systemctl start gemini + +echo "setup done, checking..." +# wait until the restarts would have timed out +sleep 10 +systemctl status gemini