The idea is to setup mirrors of this wiki across dn42, using anycast to provide redundancy and load-balancing. The local webserver is monitored with a simple shell script (below) working in conjuction with ExaBGP, announcing/withdrawing the assigned route if the service is up/down.

Checklist:

  • Install gollum.
  • Clone the dn42 wiki repo:

    git clone ssh://[email protected]/dn42/wiki /home/wiki.dn42/

  • Generate a CSR and send to [email protected]. Wait for a reply containing internal.dn42/wiki.dn42 certificates.
  • Start two gollum instances, read-only and editing on 127.0.0.1:

    gollum --css /home/wiki.dn42/custom.css --gollum-path /home/wiki.dn42/public_html/ --host 127.0.0.1 --port 4568 --no-edit

#####gollum-watchdog.sh:

#!/bin/bash

URL=( "http://172.23.0.80" "https://172.23.0.80" )

VALIDATE_KEYWORD='gollum'
ROUTE='172.23.0.80/28'
NEXTHOP='172.22.177.72'

INTERVAL=60

###########################

RUN_STATE=0

check_urls() {
	for url in "${URL[@]}"; do
		curl --insecure -L -o - ${url} | egrep -q "${VALIDATE_KEYWORD}" || {
			return 1
		}
	done
	return 0
}

while [ 1 ]; do
	if [ ${RUN_STATE} -eq 0 ]; then
		check_urls && {
			RUN_STATE=1
			echo "announce route ${ROUTE} next-hop ${NEXTHOP}"
		}
	else
		check_urls || {
			RUN_STATE=0
			echo "withdraw route ${ROUTE} next-hop ${NEXTHOP}"
		}
	fi

	sleep ${INTERVAL}

done

exit 0