mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-03-17 02:08:19 +01:00
Fix Seafile download URLs: re-apply URL config after upstream init scripts
The upstream Docker image's write_config.sh hardcodes FILE_SERVER_ROOT = "http://<SERVER_IP>/seafhttp" in seahub_settings.py, overwriting the addon's configured value on first run. This causes download URLs to contain an incorrect /seafhttp prefix and miss the file server port. Fix by creating a helper script (apply_addon_urls.sh) that re-applies the addon's FILE_SERVER_ROOT and SERVICE_URL right before Seafile services start, after all upstream init/setup/update scripts complete. Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com>
This commit is contained in:
@@ -155,6 +155,27 @@ done
|
||||
bashio::log.info "SERVICE_URL set to ${SERVICE_URL_VALUE}"
|
||||
bashio::log.info "FILE_SERVER_ROOT set to ${FILE_SERVER_ROOT_VALUE}"
|
||||
|
||||
# The upstream write_config.sh hardcodes /seafhttp in FILE_SERVER_ROOT and
|
||||
# overwrites our settings on first run. Create a helper that re-applies the
|
||||
# addon's URL configuration right before Seafile services start, so it always
|
||||
# takes effect regardless of what the upstream init/setup scripts wrote.
|
||||
cat > /home/seafile/apply_addon_urls.sh << URLEOF
|
||||
#!/bin/bash
|
||||
for _CONF in "${DATA_LOCATION}/conf/seahub_settings.py" "${DATA_LOCATION}/seafile/conf/seahub_settings.py"; do
|
||||
if [ -f "\$_CONF" ]; then
|
||||
sed -i '/^SERVICE_URL *=/d' "\$_CONF"
|
||||
sed -i '/^FILE_SERVER_ROOT *=/d' "\$_CONF"
|
||||
echo 'SERVICE_URL = "${SERVICE_URL_VALUE}"' >> "\$_CONF"
|
||||
echo 'FILE_SERVER_ROOT = "${FILE_SERVER_ROOT_VALUE}"' >> "\$_CONF"
|
||||
fi
|
||||
done
|
||||
URLEOF
|
||||
chmod +x /home/seafile/apply_addon_urls.sh
|
||||
sed -i '/print "Launching seafile"/i /home/seafile/apply_addon_urls.sh' /home/seafile/launch.sh
|
||||
if ! grep -q 'apply_addon_urls.sh' /home/seafile/launch.sh 2>/dev/null; then
|
||||
bashio::log.warning "Could not inject URL configuration into launch.sh; URLs may use upstream defaults"
|
||||
fi
|
||||
|
||||
###################
|
||||
# Define database #
|
||||
###################
|
||||
|
||||
Reference in New Issue
Block a user