LibrePortal/containers/owncloud/scripts/owncloud_install_hooks.sh
librelad 65167463f9 fix(chat apps): tag every service so its IP actually substitutes
Installing rocketchat failed with

    invalid IPv4 address: ParseAddr("IP_DATA_2"): unable to parse IP

ipUpdateComposeTags allocates one IP per SERVICE_TAG_N annotation and fills
IP_TAG_i only where SERVICE_TAG_i exists. The four new apps tagged only their
primary service, so every sidecar — matrix's postgres, mattermost's postgres,
rocketchat's mongo, and fifteen of stoat's sixteen — kept a literal IP_DATA_n
in the deployed compose and docker refused to create the container.

Tag every service that carries an ipv4_address, index-aligned with its IP_TAG.
For stoat that also meant moving caddy from SERVICE_TAG_1 to _6 so the indices
line up with the IPs rather than the reading order.

mastodon had the same latent break (IP_TAG_2 and _3 untagged) and is fixed the
same way — it would have failed on first install for the same reason.

SERVICE_TAG carries the compose *key*, not container_name: 'libreportal app
restart <app> <service>' passes it to 'docker compose restart', which only
understands keys.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 19:48:09 +01:00

45 lines
1.6 KiB
Bash

#!/bin/bash
# OwnCloud install hooks — latest-version scrape + compose substitution.
owncloud_install_post_compose()
{
local app_name="$1"
((menu_number++))
echo ""
echo "---- $menu_number. Obtain latest version number of $app_name"
echo ""
local owncloud_version="$CFG_OWNCLOUD_VERSION"
local webpage_file="/tmp/webpage.html"
curl -s "https://doc.owncloud.com/docs/next/server_release_notes.html" > "$webpage_file"
if [ $? -eq 0 ]; then
local latest_version
latest_version=$(grep -o 'Changes in [0-9.-]*' "$webpage_file" | awk -F " " '{print $3}' | sort -V | tail -n 1)
if [ -n "$latest_version" ]; then
isSuccessful "Latest Retrieved Version: $latest_version"
isSuccessful "Using for installation"
owncloud_version="$latest_version"
else
isNotice "Failed to extract the latest version from the OwnCloud website."
isNotice "Defaulting to config value : $CFG_OWNCLOUD_VERSION."
fi
rm -f "$webpage_file"
else
isNotice "Failed to retrieve the web page."
fi
local file_path="$containers_dir$app_name/docker-compose.yml"
local file_name="docker-compose.yml"
local result
result=$(runFileOp sed -i \
-e "s|OWNCLOUD_SETUP_VERSION|$owncloud_version|g" \
-e "s|OWNCLOUD_SETUP_ADMIN_USERNAME|$CFG_OWNCLOUD_ADMIN_USERNAME_1|g" \
-e "s|OWNCLOUD_SETUP_ADMIN_PASSWORD|$CFG_OWNCLOUD_ADMIN_PASSWORD_1|g" \
-e "s|OWNCLOUD_SETUP_HTTP_PORT|$usedport1|g" \
"$file_path")
checkSuccess "Updating $file_name for $app_name"
}