mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-09-30 21:42:42 +02:00
bashio now emits deprecation warnings for bashio::addon.* calls. This migrates all 227 call-sites across 86 files to use the new bashio::app.* API. Cross-compatibility is preserved in two ways: 1. bashio-standalone.sh: adds bashio::app.* functions that forward to bashio::addon.* (used when running without HA Supervisor). Also adds the missing ingress_url, restart and stop stubs. 2. ha_entrypoint.sh: injects a one-liner compat shim after the shebang of every cont-init and service script at container startup. On old bashio installations (bashio::app.* absent) the shim defines bashio::app.* as thin wrappers around bashio::addon.*; on new bashio the guard condition is true so the block is a no-op. The probe script in ha_entrypoint.sh is also updated to try bashio::app.version before falling back to bashio::addon.version. https://claude.ai/code/session_011FWFBhYQ6VS5FauSqv4UMo
69 lines
1.8 KiB
Bash
Executable File
69 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bashio
|
|
# shellcheck shell=bash
|
|
|
|
############
|
|
# TIMEZONE #
|
|
############
|
|
|
|
if bashio::config.has_value 'TZ'; then
|
|
TIMEZONE=$(bashio::config 'TZ')
|
|
bashio::log.info "Setting timezone to $TIMEZONE"
|
|
if [ -f /usr/share/zoneinfo/"$TIMEZONE" ]; then
|
|
ln -snf /usr/share/zoneinfo/"$TIMEZONE" /etc/localtime
|
|
echo "$TIMEZONE" > /etc/timezone
|
|
else
|
|
bashio::log.fatal "$TIMEZONE not found, are you sure it is a valid timezone?"
|
|
fi
|
|
fi
|
|
|
|
#################
|
|
# NGINX SETTING #
|
|
#################
|
|
|
|
#declare port
|
|
#declare certfile
|
|
declare ingress_interface
|
|
declare ingress_port
|
|
#declare keyfile
|
|
|
|
FB_BASEURL="$(bashio::app.ingress_entry)"
|
|
export FB_BASEURL
|
|
|
|
declare ADDON_PROTOCOL=http
|
|
# Generate Ingress configuration
|
|
if bashio::config.true 'ssl'; then
|
|
ADDON_PROTOCOL=https
|
|
fi
|
|
|
|
#port=$(bashio::app.port 80)
|
|
ingress_port=$(bashio::app.ingress_port)
|
|
ingress_interface=$(bashio::app.ip_address)
|
|
sed -i "s|%%protocol%%|${ADDON_PROTOCOL}|g" /etc/nginx/servers/ingress.conf
|
|
sed -i "s|%%port%%|${ingress_port}|g" /etc/nginx/servers/ingress.conf
|
|
sed -i "s|%%interface%%|${ingress_interface}|g" /etc/nginx/servers/ingress.conf
|
|
sed -i "s|%%subpath%%|${FB_BASEURL}/|g" /etc/nginx/servers/ingress.conf
|
|
mkdir -p /var/log/nginx && touch /var/log/nginx/error.log
|
|
|
|
# Correct baseurl
|
|
for file in /config/hypercorn.toml $(find /usr -name hypercorn.toml.default); do
|
|
if [ -f "$file" ]; then
|
|
sed -i "/root_path/d" "$file"
|
|
sed -i "1a root_path = \"${FB_BASEURL}\"" "$file"
|
|
fi
|
|
done
|
|
|
|
##############
|
|
# LAUNCH APP #
|
|
##############
|
|
|
|
bashio::log.warning "Default password admin:admin..."
|
|
bashio::log.info "Starting..."
|
|
|
|
# shellcheck disable=SC2086
|
|
/./usr/local/bin/codex &
|
|
true
|
|
|
|
bashio::net.wait_for 9810 localhost 900 || true
|
|
bashio::log.info "Started !"
|
|
exec nginx
|