blob: aac5001f8652c77dc5a76673873a49cd9fb2ec54 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#!/bin/bash
INST_NAME="$1"
VERSION="$2"
if [ -z "$INST_NAME" ] || [ -z "$VERSION" ]; then
echo "Usage: $0 <instance> <version>"
exit 1
fi
set -eu
K8S_MANIFEST_D="/etc/kubernetes/manifests/"
K8S_MANIFEST_FILE="$K8S_MANIFEST_D/nextcloud-$INST_NAME.yml"
if [ ! -e "$K8S_MANIFEST_FILE" ]; then
echo "could not find manifest file: $K8S_MANIFEST_FILE"
exit 2
fi
TMP_D=$(mktemp -d -t nextcloud-upgrade.XXXXXXX)
function cleanup {
rm -rf "$TMP_D"
}
trap cleanup EXIT
echo "*** Pre-Pulling the image"
echo ""
ctr -n k8s.io image pull "docker.io/library/nextcloud:$VERSION"
echo ""
echo "*** Patching manifest file"
echo ""
sed "s#image: \"nextcloud:.*\"#image: \"nextcloud:$VERSION\"#" "$K8S_MANIFEST_FILE" > "$TMP_D/upgraded.yml"
set +e
diff -u "$K8S_MANIFEST_FILE" "$TMP_D/upgraded.yml"
if [ $? -eq 0 ]; then
echo "patching file failed?"
exit 2
fi
cat "$TMP_D/upgraded.yml" > "$K8S_MANIFEST_FILE"
echo ""
exit 0
|