From 73a59ba5dc15ce6b81cf0802b10002209a8b4094 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Sun, 31 Oct 2021 15:39:46 +0100 Subject: [PATCH] config in log --- joal/rootfs/run.sh | 108 ++++++++++++++++++++++++++++----------------- 1 file changed, 67 insertions(+), 41 deletions(-) diff --git a/joal/rootfs/run.sh b/joal/rootfs/run.sh index 4e4eb5b4e..d11d1bd2a 100644 --- a/joal/rootfs/run.sh +++ b/joal/rootfs/run.sh @@ -5,38 +5,38 @@ ########## if bashio::supervisor.ping; then - bashio::log.blue \ - '-----------------------------------------------------------' - bashio::log.blue " Add-on: $(bashio::addon.name)" - bashio::log.blue " $(bashio::addon.description)" - bashio::log.blue \ - '-----------------------------------------------------------' + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' - bashio::log.blue " Add-on version: $(bashio::addon.version)" - if bashio::var.true "$(bashio::addon.update_available)"; then - bashio::log.magenta ' There is an update available for this add-on!' - bashio::log.magenta \ - " Latest add-on version: $(bashio::addon.version_latest)" - bashio::log.magenta ' Please consider upgrading as soon as possible.' - else - bashio::log.green ' You are running the latest version of this add-on.' - fi + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi - bashio::log.blue " System: $(bashio::info.operating_system)" \ - " ($(bashio::info.arch) / $(bashio::info.machine))" - bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" - bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" - bashio::log.blue \ - '-----------------------------------------------------------' - bashio::log.blue \ - ' Please, share the above information when looking for help' - bashio::log.blue \ - ' or support in, e.g., GitHub, forums or the Discord chat.' - bashio::log.green \ - ' https://github.com/alexbelgium/hassio-addons' - bashio::log.blue \ - '-----------------------------------------------------------' + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums or the Discord chat.' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' fi ################ @@ -47,10 +47,10 @@ declare TOKEN TOKEN=$(bashio::config 'secret_token') VERBOSE=$(bashio::config 'verbose') || true -# check password change +# check password change 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 # download latest version @@ -74,7 +74,7 @@ bashio::log.info "Joal updated" # If config doesn't exist, create it if [ ! -f /config/joal/config.json ]; then - bashio::log.info "Symlinking config files" + bashio::log.info "Symlinking config files" mkdir -p /config/joal cp /data/joal/config.json /config/joal/config.json fi @@ -106,7 +106,7 @@ if bashio::config.has_value 'local_ip_port'; then bashio::log.info "Ingress url set. Auto connection activated." else bashio::log.info "Ingress url not set. Connection must be done manually." -fi +fi # NGINX 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 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 # ############### -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 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 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 bashio::net.wait_for 8081 localhost 900 || true -bashio::log.info "... loaded, Nginx started for Ingress" -exec nginx & \ +bashio::log.warning "Configuration for direct access (in http://homeassistant.local:${ADDONPORT}/${UIPATH}/ui):" +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 # @@ -138,9 +164,9 @@ exec nginx & \ if bashio::config.has_value 'run_duration'; then RUNTIME=$(bashio::config 'run_duration') bashio::log.info "Addon will stop after $RUNTIME" - sleep $RUNTIME && \ - bashio::log.info "Timeout achieved, addon will stop !" && \ - exit 0 + sleep $RUNTIME && + bashio::log.info "Timeout achieved, addon will stop !" && + exit 0 else bashio::log.info "Run_duration option not defined, addon will run continuously" fi