Skip to content

Commit

Permalink
Merge pull request #42 from mdegat01/variable-refactor
Browse files Browse the repository at this point in the history
Move constants up top in scripts
  • Loading branch information
mdegat01 authored Apr 11, 2021
2 parents 54f5d27 + e8de1f5 commit 2b44cca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
14 changes: 8 additions & 6 deletions loki/rootfs/etc/cont-init.d/nginx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# Home Assistant Add-on: Loki
# This file configures nginx
# ==============================================================================
readonly NGINX_SERVERS=/etc/nginx/servers
readonly NGINX_CONF="${NGINX_SERVERS}/direct.conf"
declare certfile
declare keyfile

Expand Down Expand Up @@ -37,14 +39,14 @@ if bashio::config.true 'ssl'; then
bashio::exit.nok
fi

mv /etc/nginx/servers/direct-mtls.disabled /etc/nginx/servers/direct.conf
sed -i "s#%%cafile%%#${cafile}#g" /etc/nginx/servers/direct.conf
mv "${NGINX_SERVERS}/direct-mtls.disabled" "${NGINX_CONF}"
sed -i "s#%%cafile%%#${cafile}#g" "${NGINX_CONF}"
else
mv /etc/nginx/servers/direct-ssl.disabled /etc/nginx/servers/direct.conf
mv "${NGINX_SERVERS}/direct-ssl.disabled" "${NGINX_CONF}"
fi

sed -i "s#%%certfile%%#${certfile}#g" /etc/nginx/servers/direct.conf
sed -i "s#%%keyfile%%#${keyfile}#g" /etc/nginx/servers/direct.conf
sed -i "s#%%certfile%%#${certfile}#g" "${NGINX_CONF}"
sed -i "s#%%keyfile%%#${keyfile}#g" "${NGINX_CONF}"
else
mv /etc/nginx/servers/direct.disabled /etc/nginx/servers/direct.conf
mv "${NGINX_SERVERS}/direct.disabled" "${NGINX_CONF}"
fi
9 changes: 6 additions & 3 deletions loki/rootfs/etc/services.d/loki/run
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
# Runs Loki
# ==============================================================================

bashio::log.info 'Starting Loki...'
readonly BIND_ADDR=127.0.0.1
readonly HTTP_PORT=8080
loki_config='/etc/loki/default-config.yaml'

bashio::log.info 'Starting Loki...'

if bashio::config.exists 'config_path'; then
loki_config=$(bashio::config 'config_path')
bashio::log.info "Using config at ${loki_config}"
Expand Down Expand Up @@ -39,8 +42,8 @@ bashio::log.info "Loki log level set to ${log_level}"
loki_args=(
"-config.expand-env=true"
"-config.file=${loki_config}"
"-server.http-listen-address=127.0.0.1"
"-server.http-listen-port=8080"
"-server.http-listen-address=${BIND_ADDR}"
"-server.http-listen-port=${HTTP_PORT}"
"-log.level=${log_level}"
)
if [ "${log_level}" == "debug" ]; then
Expand Down

0 comments on commit 2b44cca

Please sign in to comment.