Automation

Digital Garden

One of my needs is an easy setup for gardening. I need to be able to write notes on all of my devices, including my phone. gitea has a built-in Markdown editor, so I can edit text and work with git at the same time. The content is rendered by mdBook.

On my server I created a user

useradd --system --create-home --home-dir /var/lib/mdbook --shell /usr/sbin/nologin --comment "mdbook Digital Garden" mdbook

For this user, I create a new ssh-key. When asked where to store it, I choose /var/lib/mdbook/.ssh

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

In gitea, I use the option for deploy-keys and add above key. Deploy keys are read only for a specific repository.

To /var/lib/mdbook I add a build.sh script

#!/bin/bash
cd /var/lib/mdbook/garden
/usr/bin/git pull -q
/usr/bin/mdbook build -d /usr/share/garden /var/lib/mdbook/garden

And a cronjob in /etc/crontab

* * * * *  mdbook  /var/lib/mdbook/build.sh