Ikiwiki Setup (part 2)
Created by Steven Baltakatei Sandoval on 2020-12-23T02:35Z under a CC BY-SA 4.0 license and last updated on 2020-12-23T15:15Z.
Update
I figured out how to migrate the git repository containing my legacy reboil.com website (an Amazon Web Services S3 bucket using Route 53 DNS routing (see this reference)) to an ikiwiki blog (this blog post you should be reading as of 2020-12-23). Using this handy procedure, I found it to be possible to maintain a line of continuity in git commit and log data in the git repository that the default ikiwiki configuration on my Freedombox uses.
I spent the past few hours figuring out how to get ikiwiki, git,
and cron to play nicely together so I can push blog posts like this
using a git push operation from my personal laptop without having to
login as root to my Freedombox via ssh. I think I have something
working. Even if my configuration changes in the near future, the
ability to version-control my blog posts gives me peace of mind that I
can preserve an roll back my blog's content.
Here are steps that I used to set this up.
Setup Procedure
The setup basically consists of the following steps:
Create a
ikiwikiblog.Creating a
gitwebbare repository to initially mirror theikiwikirepository.Push the initial
ikiwikirepositorymasterbranch to thegitwebrepo.Add the
gitwebrepository as a remote in theikiwikirepository.Create a
rootusercronjob on the Freedombox to periodically perform the required pushes, pulls, andikiwikirebuilds.
With all these preparations in place, it will then be possible to create a new blog post via two methods:
Creation, committing, and signing of a new blog post markdown file in a local clone of the
gitwebrepository on a personal computer.Creation or editing of a markdown file via
ikiwiki's webCGI interface. (note: the commit is not signed and may later be manually pulled from/merged/pushed to thegitwebrepository).
The following sections will explain these steps in detail for a blog
named blog-test. Once a working setup is confirmed functional,
repeat the steps for a blog named blog.
Setup
ikiwikiapplicationInstall
ikiwikivia the Freedombox plinth menus.Create a blog named
blog-test. This will cause the URL of the blog to be shorter (i.e.https://reboil.com/ikiwiki/blog-test).Setup
gitwebapplicationInstall
gitwebvia the Freedombox plinth menus.Create a git repository named
ikiwiki-blog-test.Setup
ikiwikirepositoryCreate a backup git bundle of the blog's initial state via:
$ sudo su - # pushd /var/lib/ikiwiki/blog-test # git bundle create ~/$(date --iso-8601=seconds)..blog-test.bundle --allAdd the
gitwebremote (a local directory) via:# git remote add localgitweb /var/lib/git/ikiwiki-blog-test.gitThe
ikiwikirepo remote list should read:/var/lib/ikiwiki/blog-test# git remote -v localgitweb /var/lib/git/ikiwiki-blog-test.git (fetch) localgitweb /var/lib/git/ikiwiki-blog-test.git (push) origin /var/lib/ikiwiki/blog-test.git (fetch) origin /var/lib/ikiwiki/blog-test.git (push)The
ikiwikirepo branch list should read:/var/lib/ikiwiki/blog-test# git branch --all * master remotes/localgitweb/master remotes/origin/masterSetup
gitwebrepositoryIn the Freedombox Plinth webUI, under Apps, under Gitweb, create a repository named
ikiwiki-blog-test.From the
ikiwikirepo working directory, push the blogmasterbranch to thegitwebrepo.# pushd /var/lib/ikiwiki/blog-test /var/lib/ikiwiki/blog-test# git push localgitweb master Enumerating objects: 12, done. Counting objects: 100% (12/12), done. Delta compression using up to 2 threads Compressing objects: 100% (11/11), done. Writing objects: 100% (12/12), 1.65 KiB | 141.00 KiB/s, done. Total 12 (delta 0), reused 0 (delta 0) To /var/lib/git/ikiwiki-blog-test.git * [new branch] master -> masterCreate and push the
ikiwikirepo'smasterbranch to themasterbranch on thegitwebrepo.# git push localgitweb master:masterThe
ikiwikirepo branches should look something like this:/var/lib/ikiwiki/blog-test# git branch --all /var/lib/ikiwiki/blog# git branch --all ikiwiki_revert_337dd2a3446701388bafc9616bccfaac659ca44a * master remotes/localgitweb/master remotes/origin/masterSetup
rootusercronjobCreate a bash script file at
/root/ikiwiki_blog-test_update.sh. The script should perform the following pseudocode functions:#!/bin/bash # Fetch updates echo "STATUS:Fetching updates." 1>&2 pushd /var/lib/ikiwiki/blog-test git fetch --all git checkout master # Push ikiwiki repo 'master' to gitweb repo 'master' # Ref/Attrib: https://stackoverflow.com/a/3206144 echo "STATUS:Pushing ikiwiki-master to gitweb-master." 1>&2 git push localgitweb master:master # Pull gitweb repo 'master' to ikiwiki repo 'master' # Ref/Attrib: https://stackoverflow.com/a/8888015 echo "STATUS:Pulling gitweb-master to ikiwiki-master" 1>&2 git pull localgitweb master:master # Push changes echo "STATUS:Push to ikiwiki" 1>&2 git push origin echo "STATUS:Rendering ikiwiki." 1>&2 ikiwiki --setup /var/lib/ikiwiki/blog-test.setup --rebuild --verbose --gettime popdCreate a
cronjob.# crontab -eHave it contain the following line.
0 * * * * /bin/bash /root/ikiwiki_blog_update.sh 1>/dev/null 2>&1You may have to manually perform an initial merge, but the
/var/lib/ikiwiki/blog-testikiwiki git repository should now automatically synchronize with the/var/lib/git/ikiwiki-blog-test.gitgitweb repository at the top of every hour.
Summary
Using a Freedombox, ikiwiki, git, gitweb, and cron, it is
possible to set up a blog that can be updated remotely via git push.
This work by Steven Baltakatei Sandoval is licensed under CC BY-SA 4.0