💾 Archived View for sysnull.info › guides › alpinepi.gmi captured on 2022-01-08 at 14:51:36. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

sysnull/guides - Raspberry Pi Alpine Linux + Gemini Setup

Last Updated: 2021-09-26

Installing Alpine Linux

There are a couple of headless Alpine Linux instructions out there, but some are rather outdated/overcomplicated since Alpine these days support persistent installation just fine. Generally just going to be following the following links (the instruction also hosted in GitHub):

Alpine Linux Wiki: Raspberry Pi - Headless Installation

GitHub Repo

Setting up a new user and general setup

Generally it's a good idea to not be running/placing stuff on root, so lets create a new user account. For this example, we'll create a user specifically for gemini, but the instructions are relevant for any general new user. The following command creates a new user and will prompt you for a password also:

# adduser gemini

You might also want to give root access via doas also, for the simplest setup, add the user to the group 'wheel' and set doas to allow users with the 'wheel' group to use doas. You might find the doas configuration file to be read only, just allow write before editing it then turn it back to readonly once you're done:

# adduser gemini wheel
# apk add doas
# chmod +w /etc/doas.conf
# vi /etc/doas.conf
# chmod -w /etc/doas.conf

While you're in the doas.conf file, you could see there's an example already. You can just un-comment or add the following line, which allow the group 'wheel' to become root:

permit persist :wheel

Community Repository

When Alpine sets up and install, the only repository enabled is the 'main' repo. This can be a bit too barebones and you're likely want to have more software availble to grab from. To enable the community repository, just edit /etc/apk/repositories and uncomment the line that points to `community`:

https://<mirror-server>/alpine/<version>/community

Then just update it:

# apk update

Setting up a Gemini Server

Using the user 'gemini'

The 'gemini' user created by the example earlier will have its home directory used for storing the certificates and contents.

Setting up gmnisrv

This instruction is for gmnisrv, which have quite some features like CGI and multi-domains. To keep it simple, we're simply going to try to get it up and running a simple static capsule. While the Alpine repository does not have the gmnisrv package, it can be compiled instead. It does not take quite long to compile on the Pi 2 B anyway.

gmnisrv: a Gemini server

1) Get the necessary packages:

# apk add git musl-dev gcc openssl openssl-dev mailcap

2) Git clone and just follow the instruction in gmnisrv README:

$ git clone https://git.sr.ht/~sircmpwn/gmnisrv
$ cd gmnisrv
$ mkdir build
$ cd build
$ ../configure --prefix=/usr
$ make
# make install

3) Then just setup the configuration file `/etc/gmnisrv.ini` like in the README:

# Space-separated list of hosts
listen=0.0.0.0:1965 [::]:1965

[:tls]
# Path to store certificates on disk
store=/home/gemini/certs

# Optional details for new certificates
organization=gemini

[example.org]
root=/home/gemini/contents

OpenRC script

It would be better to have OpenRC manage the startup of gmnisrv as:

Create an OpenRC file in `/etc/init.d/gmnisrv` and put in:

#!/sbin/openrc-run
name="gmnisrv"
command="/usr/bin/gmnisrv"
command_args=""
command_background="yes"
pidfile="/var/run/$SVCNAME.pid"

Make sure it's executable with:

# chmod +x /etc/init.d/gmnisrv

Add the service to startup and run it:

# rc-update add gmnisrv
# rc-service gmnisrv start

Back to guides

Homepage