mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-25 08:46:03 +02:00
Update run.txt
This commit is contained in:
@@ -59,67 +59,6 @@ if [[ "$(bashio::config "DATA_DIR")" == "/config/addons_config/mealie_data" ]];
|
|||||||
bashio::addon.restart
|
bashio::addon.restart
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###############
|
|
||||||
# CONFIG YAML #
|
|
||||||
###############
|
|
||||||
|
|
||||||
CONFIGSOURCE="/config/config.yaml"
|
|
||||||
|
|
||||||
if [ -f "$CONFIGSOURCE" ]; then
|
|
||||||
bashio::log.info "config.yaml found in $CONFIGSOURCE, exporting variables"
|
|
||||||
|
|
||||||
# Helper function
|
|
||||||
function parse_yaml {
|
|
||||||
local prefix=$2 || local prefix=""
|
|
||||||
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @ | tr @ '\034')
|
|
||||||
sed -ne "s|^\($s\):|\1|" \
|
|
||||||
-e "s| #.*$||g" \
|
|
||||||
-e "s|#.*$||g" \
|
|
||||||
-e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
|
|
||||||
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
|
|
||||||
awk -F$fs '{
|
|
||||||
indent = length($1)/2;
|
|
||||||
vname[indent] = $2;
|
|
||||||
for (i in vname) {if (i > indent) {delete vname[i]}}
|
|
||||||
if (length($3) > 0) {
|
|
||||||
vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
|
|
||||||
printf("%s%s%s=\"%s\"\n", "'$prefix'",vn, $2, $3);
|
|
||||||
}
|
|
||||||
}'
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get list of parameters in a file
|
|
||||||
parse_yaml "$CONFIGSOURCE" "" >/tmpfile
|
|
||||||
|
|
||||||
while IFS= read -r line; do
|
|
||||||
# Clean output
|
|
||||||
line="${line//[\"\']/}"
|
|
||||||
# Check if secret
|
|
||||||
if [[ "${line}" == *'!secret '* ]]; then
|
|
||||||
echo "secret detected"
|
|
||||||
secret=${line#*secret }
|
|
||||||
# Check if single match
|
|
||||||
secretnum=$(sed -n "/$secret:/=" /config/secrets.yaml)
|
|
||||||
[[ $(echo $secretnum) == *' '* ]] && bashio::exit.nok "There are multiple matches for your password name. Please check your secrets.yaml file"
|
|
||||||
# Get text
|
|
||||||
secret=$(sed -n "/$secret:/p" /config/secrets.yaml)
|
|
||||||
secret=${secret#*: }
|
|
||||||
line="${line%%=*}='$secret'"
|
|
||||||
fi
|
|
||||||
# Data validation
|
|
||||||
if [[ "$line" =~ ^.+[=].+$ ]]; then
|
|
||||||
export "$line"
|
|
||||||
# Show in log
|
|
||||||
if ! bashio::config.false "verbose"; then bashio::log.blue "$line"; fi
|
|
||||||
else
|
|
||||||
bashio::exit.nok "$line does not follow the correct structure. Please check your yaml file."
|
|
||||||
fi
|
|
||||||
done <"/tmpfile"
|
|
||||||
|
|
||||||
else
|
|
||||||
bashio::log.info "No config.yaml found in $CONFIGSOURCE, using default parameters"
|
|
||||||
fi
|
|
||||||
|
|
||||||
###############
|
###############
|
||||||
# PERMISSIONS #
|
# PERMISSIONS #
|
||||||
###############
|
###############
|
||||||
|
|||||||
Reference in New Issue
Block a user