-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapps-disable.sh
executable file
·42 lines (31 loc) · 1.21 KB
/
apps-disable.sh
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/sh
# This script assumes to be located in /IONOS as submodule within the Nextcloud server
# repository.
# Since this script modifies the shipped.json file, it should not be executed for every
# nextcloud pod in K8s. Also, since we do not use any pvc it would need to be applied for
# each nc-pod individually. Therefore this script should be executed during the image
# build.
BDIR="$( dirname ${0} )"
SHIPPED_JSON="${BDIR}/../core/shipped.json"
. ${BDIR}/disabled-apps.inc.sh
fail() {
echo "${*}"
exit 1
}
main() {
if ! which jq 2>&1 >/dev/null; then
fail "Error: jq is required"
fi
# alwaysEnabled should be the only attribute in this json file which really matters,
# since it is the only attribute, which is checked for which app can be disabled or not.
# defaultEnabled is only used during installation, but not for updates.
echo "Remove apps from 'shipped' list ..."
for app in ${DISABLED_APPS}; do
echo "Unship app '${app}' ..."
cat ${SHIPPED_JSON} \
| jq --arg toUnforce "${app}" 'del(.defaultEnabled[] | select(. == $toUnforce))' \
| jq --arg toUnforce "${app}" 'del(.alwaysEnabled[] | select(. == $toUnforce))' > ${SHIPPED_JSON}.tmp \
&& mv ${SHIPPED_JSON}.tmp ${SHIPPED_JSON}
done
}
main