mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-18 21:54:20 +01:00
configurator: Removed direct access, simplified code, bump to 4.0 (#902)
* configurator: Removed direct access from add-on * configurator: Extended list of default ingored patterns * configurator: Simplified run.sh * configurator: Bump version to 4.0 * configurator: Use the default Ingress port
This commit is contained in:
@@ -3,8 +3,7 @@ set -e
|
||||
|
||||
DIRSFIRST=$(bashio::config 'dirsfirst')
|
||||
ENFORCE_BASEPATH=$(bashio::config 'enforce_basepath')
|
||||
IGNORE_PATTERN="$(bashio::jq "/data/options.json" ".ignore_pattern")"
|
||||
WAIT_PIDS=()
|
||||
IGNORE_PATTERN="$(bashio::config 'ignore_pattern | join(",")')"
|
||||
|
||||
# If any SSH key files are defined in the configuration options, add them for use by git
|
||||
if bashio::config.has_value "ssh_keys"; then
|
||||
@@ -14,45 +13,26 @@ if bashio::config.has_value "ssh_keys"; then
|
||||
|
||||
# Add the keys defined in the configuration options
|
||||
while read -r filename; do
|
||||
if bashio::fs.file_exists "$filename"; then
|
||||
bashio::log.info "Adding SSH private key file \"$filename\""
|
||||
ssh-add -q "$filename"
|
||||
if bashio::fs.file_exists "${filename}"; then
|
||||
bashio::log.info "Adding SSH private key file \"${filename}\""
|
||||
ssh-add -q "${filename}"
|
||||
else
|
||||
bashio::log.error "SSH key file \"$filename\" not found"
|
||||
bashio::log.error "SSH key file \"${filename}\" not found"
|
||||
fi
|
||||
done <<< "$(bashio::config 'ssh_keys')"
|
||||
|
||||
# Disable strict host key checking
|
||||
mkdir -p ~/.ssh
|
||||
echo "Host *
|
||||
StrictHostKeyChecking no" > ~/.ssh/config
|
||||
{
|
||||
echo "Host *"
|
||||
echo " StrictHostKeyChecking no"
|
||||
} > ~/.ssh/config
|
||||
fi
|
||||
|
||||
# Setup and run Frontend
|
||||
sed -i "s/%%PORT%%/8080/g" /etc/nginx/nginx-ingress.conf
|
||||
sed -i "s/%%PORT_INGRESS%%/8099/g" /etc/nginx/nginx-ingress.conf
|
||||
|
||||
nginx -c /etc/nginx/nginx-ingress.conf &
|
||||
WAIT_PIDS+=($!)
|
||||
|
||||
# Setup and run configurator
|
||||
sed -i "s/%%TOKEN%%/${HASSIO_TOKEN}/g" /etc/configurator.conf
|
||||
sed -i "s/%%DIRSFIRST%%/${DIRSFIRST}/g" /etc/configurator.conf
|
||||
sed -i "s/%%ENFORCE_BASEPATH%%/${ENFORCE_BASEPATH}/g" /etc/configurator.conf
|
||||
sed -i "s/%%IGNORE_PATTERN%%/${IGNORE_PATTERN}/g" /etc/configurator.conf
|
||||
export HC_HASS_API_PASSWORD="${HASSIO_TOKEN}"
|
||||
export HC_DIRFIRST="${DIRSFIRST}"
|
||||
export HC_ENFORECE_BASEPATH="${ENFORCE_BASEPATH}"
|
||||
export HC_IGNORE_PATTERN="${IGNORE_PATTERN}"
|
||||
|
||||
hass-configurator /etc/configurator.conf &
|
||||
WAIT_PIDS+=($!)
|
||||
|
||||
# Register stop
|
||||
function stop_addon() {
|
||||
bashio::log.debug "Kill Processes..."
|
||||
kill -15 "${WAIT_PIDS[@]}"
|
||||
wait "${WAIT_PIDS[@]}"
|
||||
bashio::log.debug "Done."
|
||||
}
|
||||
trap "stop_addon" SIGTERM SIGHUP
|
||||
|
||||
# Wait until all is done
|
||||
bashio::log.info "Add-on running"
|
||||
wait "${WAIT_PIDS[@]}"
|
||||
exec hass-configurator /etc/configurator.conf
|
||||
|
||||
Reference in New Issue
Block a user