Normalize Seafile URL configuration

This commit is contained in:
Alexandre
2025-12-18 10:36:56 +01:00
parent 7debca49fe
commit b833d9fd3c
5 changed files with 31 additions and 7 deletions

View File

@@ -2,6 +2,9 @@
- Added support for configuring extra environment variables via the `env_vars` add-on option alongside config.yaml. See https://github.com/alexbelgium/hassio-addons/wiki/Add-Environment-variables-to-your-Addon-2 for details. - Added support for configuring extra environment variables via the `env_vars` add-on option alongside config.yaml. See https://github.com/alexbelgium/hassio-addons/wiki/Add-Environment-variables-to-your-Addon-2 for details.
## 12.0.15 (18-12-2025)
- Normalize `SERVICE_URL` and `FILE_SERVER_ROOT` values in `conf/seahub_settings.py` based on the add-on configuration to generate valid download links.
## 12.0.14 (13-09-2025) ## 12.0.14 (13-09-2025)
- Update to latest version from franchetti/seafile-arm - Update to latest version from franchetti/seafile-arm

View File

@@ -64,7 +64,7 @@ Webui can be found at <http://homeassistant:8000> (Seahub) and <http://homeassis
3. Configure database (SQLite default, MariaDB recommended for production) 3. Configure database (SQLite default, MariaDB recommended for production)
4. Set proper file server root URL for external access 4. Set proper file server root URL for external access
> **File server URL**: The add-on now writes `SERVICE_URL` and `FILE_SERVER_ROOT` directly to `conf/seahub_settings.py` using `SERVER_IP` (default `homeassistant.local`), the web UI port `8000`, and the file server port (`PORT`, default `8082`). If you are not using a reverse proxy, keep `FILE_SERVER_ROOT` set to `http://<your host>:8082` so download links point to the correct file server endpoint. > **File server URL**: The add-on now writes `SERVICE_URL` and `FILE_SERVER_ROOT` directly to `conf/seahub_settings.py`. `SERVICE_URL` uses the `url` option when set (otherwise `SERVER_IP` with port `8000`), while `FILE_SERVER_ROOT` follows the `FILE_SERVER_ROOT` option (defaulting to `http://<your host>:8082`). Keep `FILE_SERVER_ROOT` aligned with your accessible file server endpoint so download links resolve correctly.
### Options ### Options

View File

@@ -128,5 +128,5 @@ services:
slug: seafile slug: seafile
udev: true udev: true
url: https://github.com/alexbelgium/hassio-addons/tree/master/seafile url: https://github.com/alexbelgium/hassio-addons/tree/master/seafile
version: 12.0.14 version: 12.0.15
webui: http://[HOST]:[PORT:8000] webui: http://[HOST]:[PORT:8000]

View File

@@ -71,11 +71,32 @@ sed -i "s|/shared|$DATA_LOCATION|g" /home/seafile/*.sh
bashio::log.info "Configuring Seafile URLs" bashio::log.info "Configuring Seafile URLs"
DEFAULT_HOST=${SERVER_IP:-homeassistant.local} SERVER_IP_CONFIG=$(bashio::config 'SERVER_IP')
DEFAULT_FILE_PORT=${PORT:-8082} SERVICE_URL_CONFIG=$(bashio::config 'url')
FILE_SERVER_ROOT_CONFIG=$(bashio::config 'FILE_SERVER_ROOT')
FILE_PORT_CONFIG=$(bashio::config 'PORT')
SERVICE_URL_VALUE="http://${DEFAULT_HOST}:8000" DEFAULT_HOST=${SERVER_IP_CONFIG:-homeassistant.local}
FILE_SERVER_ROOT_VALUE=${FILE_SERVER_ROOT:-"http://${DEFAULT_HOST}:${DEFAULT_FILE_PORT}"} DEFAULT_FILE_PORT=${FILE_PORT_CONFIG:-8082}
normalize_url() {
local raw_url="${1%/}"
local default_scheme="$2"
if [[ -z "${raw_url}" || "${raw_url}" == "null" ]]; then
echo ""
return
fi
if [[ "${raw_url}" =~ ^https?:// ]]; then
echo "${raw_url}"
else
echo "${default_scheme}://${raw_url}"
fi
}
SERVICE_URL_VALUE=$(normalize_url "${SERVICE_URL_CONFIG:-${DEFAULT_HOST}:8000}" "http")
FILE_SERVER_ROOT_VALUE=$(normalize_url "${FILE_SERVER_ROOT_CONFIG:-${DEFAULT_HOST}:${DEFAULT_FILE_PORT}}" "http")
SEAHUB_SETTINGS_FILE="${DATA_LOCATION}/conf/seahub_settings.py" SEAHUB_SETTINGS_FILE="${DATA_LOCATION}/conf/seahub_settings.py"
mkdir -p "$(dirname "${SEAHUB_SETTINGS_FILE}")" mkdir -p "$(dirname "${SEAHUB_SETTINGS_FILE}")"

View File

@@ -1,6 +1,6 @@
{ {
"github_fulltag": "true", "github_fulltag": "true",
"last_update": "13-09-2025", "last_update": "18-12-2025",
"paused": false, "paused": false,
"repository": "alexbelgium/hassio-addons", "repository": "alexbelgium/hassio-addons",
"slug": "seafile", "slug": "seafile",