fix: auto-fix linting issues

This commit is contained in:
alexbelgium
2025-06-10 10:06:17 +00:00
committed by github-actions[bot]
parent e5adbd266f
commit f728166b14
197 changed files with 5747 additions and 5714 deletions

View File

@@ -8,21 +8,21 @@ set -e
#####################
if bashio::config.true 'mqtt_autodiscover'; then
bashio::log.info "mqtt_autodiscover is defined in options, attempting autodiscovery..."
# Check if available
if ! bashio::services.available "mqtt"; then bashio::exit.nok "No internal MQTT service found. Please install Mosquitto broker"; fi
# Get variables
bashio::log.info "... MQTT service found, fetching server detail (you can enter those manually in your config file) ..."
export MQTT_HOST=$(bashio::services mqtt "host") || bashio::log.error "can't fetch bashio::services mqtt 'host'"
export MQTT_PORT=$(bashio::services mqtt "port") || bashio::log.error "can't fetch bashio::services mqtt 'port'"
export MQTT_SSL=$(bashio::services mqtt "ssl") || bashio::log.error "can't fetch bashio::services mqtt 'ssl'"
export MQTT_USERNAME=$(bashio::services mqtt "username") || bashio::log.error "can't fetch bashio::services mqtt 'username'"
export MQTT_PASSWORD=$(bashio::services mqtt "password") || bashio::log.error "can't fetch bashio::services mqtt 'password'"
bashio::log.info "mqtt_autodiscover is defined in options, attempting autodiscovery..."
# Check if available
if ! bashio::services.available "mqtt"; then bashio::exit.nok "No internal MQTT service found. Please install Mosquitto broker"; fi
# Get variables
bashio::log.info "... MQTT service found, fetching server detail (you can enter those manually in your config file) ..."
export MQTT_HOST=$(bashio::services mqtt "host") || bashio::log.error "can't fetch bashio::services mqtt 'host'"
export MQTT_PORT=$(bashio::services mqtt "port") || bashio::log.error "can't fetch bashio::services mqtt 'port'"
export MQTT_SSL=$(bashio::services mqtt "ssl") || bashio::log.error "can't fetch bashio::services mqtt 'ssl'"
export MQTT_USERNAME=$(bashio::services mqtt "username") || bashio::log.error "can't fetch bashio::services mqtt 'username'"
export MQTT_PASSWORD=$(bashio::services mqtt "password") || bashio::log.error "can't fetch bashio::services mqtt 'password'"
# Export variables
for variables in "MQTT_HOST=$MQTT_HOST" "MQTT_PORT=$MQTT_PORT" "MQTT_SSL=$MQTT_SSL" "MQTT_USERNAME=$MQTT_USERNAME" "MQTT_PASSWORD=$MQTT_PASSWORD"; do
sed -i "1a export $variables" /etc/cont-init.d/*/*run* 2>/dev/null || true
# Log
bashio::log.blue "$variables"
done
# Export variables
for variables in "MQTT_HOST=$MQTT_HOST" "MQTT_PORT=$MQTT_PORT" "MQTT_SSL=$MQTT_SSL" "MQTT_USERNAME=$MQTT_USERNAME" "MQTT_PASSWORD=$MQTT_PASSWORD"; do
sed -i "1a export $variables" /etc/cont-init.d/*/*run* 2>/dev/null || true
# Log
bashio::log.blue "$variables"
done
fi

View File

@@ -10,7 +10,7 @@ set -e
CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION")
# Check CONFIGSOURCE ends with config.yaml
if [ "$(basename "$CONFIGSOURCE")" != "config.yaml" ]; then
bashio::log.error "Watchout: your CONFIG_LOCATION should end by config.yaml, and instead it is $(basename "$CONFIGSOURCE")"
bashio::log.error "Watchout: your CONFIG_LOCATION should end by config.yaml, and instead it is $(basename "$CONFIGSOURCE")"
fi
DATABASESOURCE="$(dirname "${CONFIGSOURCE}")/cache.db"
@@ -22,8 +22,8 @@ chmod 777 -R "$(dirname "${DATABASESOURCE}")"
# Check absence of config file
if [ -f /data/config.yaml ] && [ ! -L /data/config.yaml ]; then
bashio::log.warning "A current config was found in /data, it is backuped to ${CONFIGSOURCE}.bak"
mv /data/config.yaml "$CONFIGSOURCE".bak
bashio::log.warning "A current config was found in /data, it is backuped to ${CONFIGSOURCE}.bak"
mv /data/config.yaml "$CONFIGSOURCE".bak
fi
#########################################################
@@ -31,24 +31,24 @@ fi
#########################################################
if [ -f /config/addons_config/enedisgateway2mqtt_dev/config.yaml ]; then
mv /config/addons_config/enedisgateway2mqtt_dev/* "$(dirname "${CONFIGSOURCE}")"/
rm -r /config/addons_config/enedisgateway2mqtt_dev
mv /config/addons_config/enedisgateway2mqtt_dev/* "$(dirname "${CONFIGSOURCE}")"/
rm -r /config/addons_config/enedisgateway2mqtt_dev
fi
# If migration was performed, save file in config folder
if [ -f /data/enedisgateway.db.migrate ]; then
bashio::log.warning "Migration performed, enedisgateway.db.migrate copied in $(dirname "${CONFIGSOURCE}")"
mv /data/enedisgateway.db.migrate "$(dirname "${CONFIGSOURCE}")"
bashio::log.warning "Migration performed, enedisgateway.db.migrate copied in $(dirname "${CONFIGSOURCE}")"
mv /data/enedisgateway.db.migrate "$(dirname "${CONFIGSOURCE}")"
fi
# If migration was performed, save file in config folder
if [ -f /data/cache.db ] && [ ! -f "$DATABASESOURCE" ]; then
mv /data/cache.db "$(dirname "${CONFIGSOURCE}")"
mv /data/cache.db "$(dirname "${CONFIGSOURCE}")"
fi
# If migration was not performed, enable migration
if [ -f "$(dirname "${CONFIGSOURCE}")"/enedisgateway.db ]; then
mv "$(dirname "${CONFIGSOURCE}")"/enedisgateway.db /data
mv "$(dirname "${CONFIGSOURCE}")"/enedisgateway.db /data
fi
############
@@ -57,15 +57,15 @@ fi
# Check if database is here or create symlink
if [ -f "$DATABASESOURCE" ]; then
# Create symlink if not existing yet
ln -sf "${DATABASESOURCE}" /data && echo "creating symlink"
bashio::log.info "Using database file found in $(dirname "${CONFIGSOURCE}")"
# Create symlink if not existing yet
ln -sf "${DATABASESOURCE}" /data && echo "creating symlink"
bashio::log.info "Using database file found in $(dirname "${CONFIGSOURCE}")"
else
# Create symlink for addon to create database
mkdir -p "$(dirname "$DATABASESOURCE")"
touch "${DATABASESOURCE}"
ln -sf "$DATABASESOURCE" /data
rm "$DATABASESOURCE"
# Create symlink for addon to create database
mkdir -p "$(dirname "$DATABASESOURCE")"
touch "${DATABASESOURCE}"
ln -sf "$DATABASESOURCE" /data
rm "$DATABASESOURCE"
fi
##########
@@ -74,35 +74,36 @@ fi
# Check if config file is there, or create one from template
if [ -f "$CONFIGSOURCE" ]; then
# Create symlink if not existing yet
# shellcheck disable=SC2015
[ -f /data/config.yaml ] && rm /data/config.yaml || true
ln -sf "$CONFIGSOURCE" /data || true
bashio::log.info "Using config file found in $CONFIGSOURCE"
# Create symlink if not existing yet
# shellcheck disable=SC2015
[ -f /data/config.yaml ] && rm /data/config.yaml || true
ln -sf "$CONFIGSOURCE" /data || true
bashio::log.info "Using config file found in $CONFIGSOURCE"
# Check if yaml is valid
EXIT_CODE=0
yamllint -d relaxed "$CONFIGSOURCE" &>ERROR || EXIT_CODE=$?
if [ "$EXIT_CODE" = 0 ]; then
echo "Config file is a valid yaml"
else
cat ERROR
bashio::log.fatal "Config file has an invalid yaml format. Please check the file in $CONFIGSOURCE. Errors list above. You can check yaml validity with the online tool yamllint.com"
fi
# Check if yaml is valid
EXIT_CODE=0
yamllint -d relaxed "$CONFIGSOURCE" &>ERROR || EXIT_CODE=$?
if [ "$EXIT_CODE" = 0 ]; then
echo "Config file is a valid yaml"
else
cat ERROR
bashio::log.fatal "Config file has an invalid yaml format. Please check the file in $CONFIGSOURCE. Errors list above. You can check yaml validity with the online tool yamllint.com"
fi
else
# Create symlink for addon to create config
cp /templates/config.yaml "$(dirname "${CONFIGSOURCE}")"/
ln -sf "$CONFIGSOURCE" /data
rm "$CONFIGSOURCE"
# Need to restart
bashio::log.fatal "Config file not found. The addon will create a new one, then stop. Please customize the file in $CONFIGSOURCE before restarting."
# Create symlink for addon to create config
cp /templates/config.yaml "$(dirname "${CONFIGSOURCE}")"/
ln -sf "$CONFIGSOURCE" /data
rm "$CONFIGSOURCE"
# Need to restart
bashio::log.fatal "Config file not found. The addon will create a new one, then stop. Please customize the file in $CONFIGSOURCE before restarting."
fi
##############
# Launch App #
##############
echo " "
nginx & bashio::log.info "Starting nginx"
nginx &
bashio::log.info "Starting nginx"
echo " "
bashio::log.info "Starting the app"
echo " "