add tools for Debian

This commit is contained in:
Johann150 2021-02-05 08:26:24 +01:00
parent 742a423021
commit 86e0fe665d
No known key found for this signature in database
GPG key ID: 9EE6577A2A06F8F1
6 changed files with 153 additions and 0 deletions

2
tools/README.md Normal file
View file

@ -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.

30
tools/debian/README.md Normal file
View file

@ -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!

2
tools/debian/gemini.conf Normal file
View file

@ -0,0 +1,2 @@
if $programname == 'gemini' then /var/log/gemini.log
& stop

View file

@ -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

10
tools/debian/geminilogs Normal file
View file

@ -0,0 +1,10 @@
/var/log/gemini.log {
daily
missingok
rotate 14
compress
delaycompress
notifempty
create 0640 root adm
sharedscripts
}

81
tools/debian/install.sh Executable file
View file

@ -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