config in log

This commit is contained in:
Alexandre
2021-10-31 15:39:46 +01:00
parent 5bbaafc4b0
commit 73a59ba5dc

View File

@@ -5,38 +5,38 @@
########## ##########
if bashio::supervisor.ping; then if bashio::supervisor.ping; then
bashio::log.blue \ bashio::log.blue \
'-----------------------------------------------------------' '-----------------------------------------------------------'
bashio::log.blue " Add-on: $(bashio::addon.name)" bashio::log.blue " Add-on: $(bashio::addon.name)"
bashio::log.blue " $(bashio::addon.description)" bashio::log.blue " $(bashio::addon.description)"
bashio::log.blue \ bashio::log.blue \
'-----------------------------------------------------------' '-----------------------------------------------------------'
bashio::log.blue " Add-on version: $(bashio::addon.version)" bashio::log.blue " Add-on version: $(bashio::addon.version)"
if bashio::var.true "$(bashio::addon.update_available)"; then if bashio::var.true "$(bashio::addon.update_available)"; then
bashio::log.magenta ' There is an update available for this add-on!' bashio::log.magenta ' There is an update available for this add-on!'
bashio::log.magenta \ bashio::log.magenta \
" Latest add-on version: $(bashio::addon.version_latest)" " Latest add-on version: $(bashio::addon.version_latest)"
bashio::log.magenta ' Please consider upgrading as soon as possible.' bashio::log.magenta ' Please consider upgrading as soon as possible.'
else else
bashio::log.green ' You are running the latest version of this add-on.' bashio::log.green ' You are running the latest version of this add-on.'
fi fi
bashio::log.blue " System: $(bashio::info.operating_system)" \ bashio::log.blue " System: $(bashio::info.operating_system)" \
" ($(bashio::info.arch) / $(bashio::info.machine))" " ($(bashio::info.arch) / $(bashio::info.machine))"
bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)"
bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)"
bashio::log.blue \ bashio::log.blue \
'-----------------------------------------------------------' '-----------------------------------------------------------'
bashio::log.blue \ bashio::log.blue \
' Please, share the above information when looking for help' ' Please, share the above information when looking for help'
bashio::log.blue \ bashio::log.blue \
' or support in, e.g., GitHub, forums or the Discord chat.' ' or support in, e.g., GitHub, forums or the Discord chat.'
bashio::log.green \ bashio::log.green \
' https://github.com/alexbelgium/hassio-addons' ' https://github.com/alexbelgium/hassio-addons'
bashio::log.blue \ bashio::log.blue \
'-----------------------------------------------------------' '-----------------------------------------------------------'
fi fi
################ ################
@@ -47,10 +47,10 @@ declare TOKEN
TOKEN=$(bashio::config 'secret_token') TOKEN=$(bashio::config 'secret_token')
VERBOSE=$(bashio::config 'verbose') || true VERBOSE=$(bashio::config 'verbose') || true
# check password change # check password change
if [ "$TOKEN" = "lrMY24Byhx" ]; then if [ "$TOKEN" = "lrMY24Byhx" ]; then
bashio::log.warning "The token is still the default one, please change from addon options" bashio::log.warning "The token is still the default one, please change from addon options"
fi fi
# download latest version # download latest version
@@ -74,7 +74,7 @@ bashio::log.info "Joal updated"
# If config doesn't exist, create it # If config doesn't exist, create it
if [ ! -f /config/joal/config.json ]; then if [ ! -f /config/joal/config.json ]; then
bashio::log.info "Symlinking config files" bashio::log.info "Symlinking config files"
mkdir -p /config/joal mkdir -p /config/joal
cp /data/joal/config.json /config/joal/config.json cp /data/joal/config.json /config/joal/config.json
fi fi
@@ -106,7 +106,7 @@ if bashio::config.has_value 'local_ip_port'; then
bashio::log.info "Ingress url set. Auto connection activated." bashio::log.info "Ingress url set. Auto connection activated."
else else
bashio::log.info "Ingress url not set. Connection must be done manually." bashio::log.info "Ingress url not set. Connection must be done manually."
fi fi
# NGINX # NGINX
sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf
@@ -114,22 +114,48 @@ sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf
sed -i "s/%%path%%/${UIPATH}/g" /etc/nginx/servers/ingress.conf sed -i "s/%%path%%/${UIPATH}/g" /etc/nginx/servers/ingress.conf
mkdir -p /var/log/nginx && touch /var/log/nginx/error.log mkdir -p /var/log/nginx && touch /var/log/nginx/error.log
###############
# GET ADDRESS #
###############
INGRESSURL=$(bashio::config 'local_ip_port')$(bashio::addon.ingress_url)
host_port=$(bashio::core.port)
ingress_url=$(bashio::addon.ingress_entry)
echo $INGRESSURL
echo $host_port
echo $ingress_url
############### ###############
# LAUNCH APPS # # LAUNCH APPS #
############### ###############
if [ $VERBOSE = true ]; then if [ $VERBOSE = true ]; then
nohup java -jar /joal/joal.jar --joal-conf=/data/joal --spring.main.web-environment=true --server.port="8081" --joal.ui.path.prefix=${UIPATH} --joal.ui.secret-token=$TOKEN nohup java -jar /joal/joal.jar --joal-conf=/data/joal --spring.main.web-environment=true --server.port="8081" --joal.ui.path.prefix=${UIPATH} --joal.ui.secret-token=$TOKEN
else else
nohup java -jar /joal/joal.jar --joal-conf=/data/joal --spring.main.web-environment=true --server.port="8081" --joal.ui.path.prefix=${UIPATH} --joal.ui.secret-token=$TOKEN >/dev/null nohup java -jar /joal/joal.jar --joal-conf=/data/joal --spring.main.web-environment=true --server.port="8081" --joal.ui.path.prefix=${UIPATH} --joal.ui.secret-token=$TOKEN >/dev/null
fi \ fi \
& bashio::log.info "Joal started with path http://ip/${UIPATH}/ui secret token $TOKEN" &
bashio::log.info "Please wait, loading..." bashio::log.info "Joal started with path http://ip/${UIPATH}/ui secret token $TOKEN"
bashio::log.info "Please wait, loading..."
ADDONPORT=$(bashio::addon.port "8081")
# Wait for transmission to become available # Wait for transmission to become available
bashio::net.wait_for 8081 localhost 900 || true bashio::net.wait_for 8081 localhost 900 || true
bashio::log.info "... loaded, Nginx started for Ingress" bashio::log.warning "Configuration for direct access (in http://homeassistant.local:${ADDONPORT}/${UIPATH}/ui):"
exec nginx & \ bashio::log.info "... address : homeassistant.local"
bashio::log.info "... server port : ${ADDONPORT}"
bashio::log.info "... Path prefix : ${UIPATH}"
bashio::log.info "... Secret token : $TOKEN"
bashio::log.warning "Configuration for Ingress (in app):"
bashio::log.info "... address : homeassistant.local:$host_port$ingress_url/"
bashio::log.info "... server port : $host_port"
bashio::log.info "... Path prefix : ${UIPATH}"
bashio::log.info "... Secret token : $TOKEN"
bashio::log.info "Everything loaded."
exec nginx &
########### ###########
# TIMEOUT # # TIMEOUT #
@@ -138,9 +164,9 @@ exec nginx & \
if bashio::config.has_value 'run_duration'; then if bashio::config.has_value 'run_duration'; then
RUNTIME=$(bashio::config 'run_duration') RUNTIME=$(bashio::config 'run_duration')
bashio::log.info "Addon will stop after $RUNTIME" bashio::log.info "Addon will stop after $RUNTIME"
sleep $RUNTIME && \ sleep $RUNTIME &&
bashio::log.info "Timeout achieved, addon will stop !" && \ bashio::log.info "Timeout achieved, addon will stop !" &&
exit 0 exit 0
else else
bashio::log.info "Run_duration option not defined, addon will run continuously" bashio::log.info "Run_duration option not defined, addon will run continuously"
fi fi