system-maintenance: Download workstation OSTree repo from GitHub
[bin.git] / system-maintenance
1 #!/bin/sh
2 set -eux
3
4 rpm-ostree cleanup --rollback || true
5 rpm-ostree cleanup --repomd
6 rpm-ostree cleanup --pending
7 rpm-ostree cleanup --base
8
9 # download latest repo build
10 REPO=$(mktemp -d -t repo.XXXXXX)
11 trap "rm -rf '$REPO'" EXIT INT QUIT PIPE
12 CURL="curl -u token:$(cat ~martin/.config/github-token) --show-error --fail"
13 RESPONSE=$($CURL --silent https://api.github.com/repos/martinpitt/ostree-pitti-workstation/actions/artifacts)
14 ZIP=$(echo "$RESPONSE" | jq --raw-output '.artifacts | map(select(.name == "repository"))[0].archive_download_url')
15 echo "INFO: Downloading $ZIP ..."
16 [ -e /tmp/repository.zip ] || $CURL -L -o /tmp/repository.zip "$ZIP"
17 rm -rf "$REPO"
18 mkdir -p "$REPO"
19 unzip -p /tmp/repository.zip | tar -xzC "$REPO"
20 rm /tmp/repository.zip
21
22 # upgrade
23 ostree remote add --no-gpg-verify tmp-local "file://$REPO"
24 rpm-ostree rebase tmp-local:
25 ostree remote delete tmp-local
26
27 # fix fonts between Fedora releases
28 rm -rf ~martin/.cache/fontconfig
29
30 fstrim -av