#selfhost

bkoehn@diaspora.koehn.com

I wrote enough just scripts that I now have a reasonably consistent API. I can now cd into a directory and run just upgrade and the scripts will figure out what version is currently deployed and what release is current, and if they’re different will deploy the latest version, building a new Docker image if necessary. It’s really nice.

Coding up the current version was a fun exercise in shell scripting.

For postfix:

kubectl exec -n mail svc/postfix -- postconf mail_version | awk '{print $NF}'

For dovecot:

kubectl exec -n mail svc/dovecot -- dovecot --version | awk '{print $1}’

```

For synapse you can hit the HTTP endpoint:
```

Synapse releases are all prefixed with a 'v'

echo "v$(curl --silent https://koehn.com/_synapse/admin/v1/server_version | jq -r .server_version)”
```

Then finding the current release is also unique for each:

The current Postfix release comes from Debian, so I grab it from the web page (best I could find):

curl --silent https://packages.debian.org/bookworm-updates/postfix | htmlq h1 --text | grep postfix | sed 's/^.*(\([0-9.]*\)-.*$/\1/‘

For dovecot and synapse, I can get it from Github (with help from a script I found online):

curl --silent https://api.github.com/repos/$GITHUB/tags | jq -r '.[].name' | semversort | tail -n 1

But after some somewhat careful construction of the scripts, I can reuse a standard CLI. I’ll refactor to reuse a bit more code next.

#just #selfhost #shell-fu