Skip to content

Commit

Permalink
[update-(helm|yaml).sh] update
Browse files Browse the repository at this point in the history
- [update-yaml.sh] Change sed command option from -e to -E
- [update-helm.sh] Add check for docker image tag as first argument, exit 2 if missing
- [update-helm.sh] Modify snap command to run with sudo
- [update-helm.sh] Add new sed commands:
  - [sed] Convert `- AB_CD_EFG` to `- AB_CD_EFG=${AB_CD_EFG}`
  - [sed] Apply conversion only to uppercase variables
  - [sed] Exclude NET_RAW, SYS_NICE, NET_ADMIN, and MKNOD capabilities from conversion
  • Loading branch information
flll committed Oct 24, 2024
1 parent 57d03d8 commit 9774fcd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion manual-install/latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ services:
environment:
- NC_DOMAIN
- TZ=${TIMEZONE}
- RECORDING_SECRET=${RECORDING_SECRET}
- RECORDING_SECRET
- INTERNAL_SECRET=${TALK_INTERNAL_SECRET}
shm_size: 2147483648
restart: unless-stopped
Expand Down
8 changes: 3 additions & 5 deletions manual-install/update-yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ OUTPUT="$(echo "$OUTPUT" | jq 'del(.services[] | select(.container_name == "next
OUTPUT="$(echo "$OUTPUT" | jq '.services[] |= if has("depends_on") then .depends_on |= if contains(["nextcloud-aio-docker-socket-proxy"]) then del(.[index("nextcloud-aio-docker-socket-proxy")]) else . end else . end')"
OUTPUT="$(echo "$OUTPUT" | jq '.services[] |= if has("depends_on") then .depends_on |= map({ (.): { "condition": "service_started", "required": false } }) else . end' | jq '.services[] |= if has("depends_on") then .depends_on |= reduce .[] as $item ({}; . + $item) else . end')"

snap install yq
sudo snap install yq
mkdir -p ./manual-install
echo "$OUTPUT" | yq -P > ./manual-install/containers.yml

Expand All @@ -42,7 +42,6 @@ sed -i '/AIO_TOKEN/d' containers.yml
sed -i '/AIO_URL/d' containers.yml
sed -i '/DOCKER_SOCKET_PROXY_ENABLED/d' containers.yml
sed -i '/ADDITIONAL_TRUSTED_PROXY/d' containers.yml
sed -ie 's/\( *- \(\w*\)\)=\${\2\}/\1/' containers.yml

TCP="$(grep -oP '[%A-Z0-9_]+/tcp' containers.yml | sort -u)"
mapfile -t TCP <<< "$TCP"
Expand Down Expand Up @@ -145,9 +144,8 @@ networks:
driver: bridge
NETWORK

cat containers.yml > latest.yml
mv containers.yml latest.yml
sed -i "/image:/s/$/:latest/" latest.yml

rm containers.yml
sed -i 's/\( *- \(\w*\)\)=\${\2\}/\1/' latest.yml

set +ex
11 changes: 7 additions & 4 deletions nextcloud-aio-helm-chart/update-helm.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash

[ -z "$1" ] && { echo "Error: Docker tag is not specified. Usage: ./nextcloud-aio-helm-chart/update-helm.sh <Docker tag>"; exit 2; }

DOCKER_TAG="$1"

# The logic needs the files in ./helm-chart
mv ./nextcloud-aio-helm-chart ./helm-chart
cp -r ./nextcloud-aio-helm-chart ./helm-chart

# Clean
rm -f ./helm-chart/values.yaml
Expand All @@ -15,13 +17,15 @@ chmod +x kompose
sudo mv ./kompose /usr/local/bin/kompose

# Install yq
snap install yq
sudo snap install yq

set -ex

# Conversion of docker-compose
cd manual-install
cp latest.yml latest.yml.backup

sed -i -E '/^( *- )(NET_RAW|SYS_NICE|MKNOD|SYS_ADMIN)$/!s/( *- )([A-Z_]+)$/\1\2=${\2}/' latest.yml
cp sample.conf /tmp/
sed -i 's|^|export |' /tmp/sample.conf
# shellcheck disable=SC1091
Expand All @@ -41,8 +45,7 @@ sed -i "/NEXTCLOUD_DATADIR/d" latest.yml
sed -i "/\${NEXTCLOUD_MOUNT}/d" latest.yml
sed -i "/^volumes:/a\ \ nextcloud_aio_nextcloud_trusted_cacerts:\n \ \ \ \ name: nextcloud_aio_nextcloud_trusted_cacerts" latest.yml
sed -i "s|\${NEXTCLOUD_TRUSTED_CACERTS_DIR}:|nextcloud_aio_nextcloud_trusted_cacerts:|g#" latest.yml
sed -i 's|\${|{{ .Values.|g' latest.yml
sed -i 's|}| }}|g' latest.yml
sed -i 's/\${/{{ .Values./g; s/}/ }}/g' latest.yml
yq -i 'del(.services.[].profiles)' latest.yml
# Delete read_only and tmpfs setting while https://github.com/kubernetes/kubernetes/issues/48912 is not fixed
yq -i 'del(.services.[].read_only)' latest.yml
Expand Down

0 comments on commit 9774fcd

Please sign in to comment.